cfimage watermask

I've developed one simple image manipulation with cfimage yesterday. It's about how to make watermask. PS : for output image format, use "PNG" instead of "JPEG" because "PNG" is high resolution ever.

It's original image

Original Image

It's watermask image

Watermask Image

Coding

view plain print about
1<!--- it's original image --->
2<cfimage source="PP.png" name="image">
3
4<!--- it's watermask image --->
5<cfimage source="CF.jpg" name="watermark">
6
7<!--- It's paste watermask image into original image --->
8<cfset ImagePaste(image, watermark, 165, 160) />
9
10<!--- finally, it will be output as follow --->
11<cfimage source="#image#" action="writeToBrowser" format="png">

Watermask

ValueList

Before time, I always use ListAppend tag whenever I want to create list value from Database. Today I surf coding of our in-house software, I found they use ValueList tag by accident. When I saw this tag, I don't know how does it work and how to use. After reading, documentation from Adobe then it's incredible.

view plain print about
1<cfquery name="qryUsers" datasource="MyDsn">
2    SELECT NAME FROM tblUsers
3</cfquery>
4
5<cfset = ValueList(qryUser.Name)>

Twitter Search with jQuery

Last week, I've attended Webcamps seminar organized by Microsoft in Singapore. Describing my previous thread, they're focus on MS visual studio 2010, IIS7 and MVC 2. Meanwhile, James Senior (actually he's main person for this seminar) let us know how to create "twitter search with jQuerytemplate ". It's absolutely cool and we don't need any server-side programming for it.

Here you go: http://www.jamessenior.com/post/Twitter-Search-with-jQuery-Templating.aspx

Tagged like facebook

When I started using facebook, everybody can tag their friends' names in photo and after tagging it, Alternate text will occur when mouse-over on this photo. It's very impressive for me and want to know how it's developed. When I deep woring tag of HTML, it's very simple to do like facebook. My idea of how to create this tagged in facebook is:

  • selected A (it's someone or something) choose in this pic
  • note x,y coordinate of A
  • save x,y coordinate and caption of A
  • display this pic by
  • mouse-over on coordinate then display caption

view plain print about
1<html>
2<head>
3<invalidTag type="text/javascript">
4function writeText(txt)
5{
6document.getElementById("desc").innerHTML=txt;
7}
8</script>
9</head>
10<body>
11<img src="b1.jpg" width="145" height="126" alt="Planets" usemap="#planetmap" />
12<map name="planetmap">
13<area shape ="rect" coords ="0,0,82,126" onMouseOver="writeText('The Sun and the gas giant planets like Jupiter are by far the largest objects in our Solar System.')" href ="sun.htm" target ="_blank" alt="Sun" />
14<area shape ="circle" coords ="90,58,3" onMouseOver="writeText('The planet Mercury is very difficult to study from the Earth because it is always so close to the Sun.')" href ="mercur.htm" target ="_blank" alt="Mercury" />
15<area shape ="circle" coords ="124,58,8" onMouseOver="writeText('Until the 1960s, Venus was often considered a twin sister to the Earth because Venus is the nearest planet to us, and because the two planets seem to share many characteristics.')" href ="venus.htm" target ="_blank" alt="Venus" />
16</map>
17<p id="desc">
18</body>
19</html>

Ref for : http://www.w3schools.com/js/js_image_maps.asp

ParagraphFormat and StripCR

ParagraphFormat and StripCR are displaying data as HTML format from textarea. ParagraphFormat is for displaying entered data in textarea input. StripCR is for displaying entered data as HTML format from textarea.

ToScript

Before time, when I need CF value to know javascript, I need to create hidden or input then set cf value to in. When I know ToScript, I don't need to do a lot of stuff just like before. Using this tag is simple,

ToScript([coldfusion_var], [new_javascript_name], [outputformat optional], [ASFormat optional])

view plain print about
1<cfset thisString="hello world">
2<invalidTag type="text/javascript" language="JavaScript">
3<cfoutput>
4var #toScript(thisString, "jsVar")#;
5</cfoutput>
6</script>

Compare list in Coldfusion

I'm trying to compare 2 lists and output the different value and same value of these 2 lists. Normally, CF doesn't have complete function of compare 2 lists. That's why I gotta create my own UDF for comparing 2 lists. How does it work :

  • ListGetDifferent(List1, List2, "Same/Differ")
  • If you defined "Same", then will return Same value of main list after comparing with second list.
  • If you defined "Different", then will return different value of main list after comparing with second list as well.

Function UDF

view plain print about
1<cffunction name="ListGetDifferent" output="yes">
2    <cfargument name="mainList" required="Yes" />
3    <cfargument name="compareList" required="Yes" />
4    <cfargument name="CompareType" required="Yes" default="Same" />
5    <cfset ReturnList = "" />
6    <cfif CompareType EQ "Same">
7        <cfloop list="#mainList#" index="i">
8            <cfif ListFindNoCase(compareList,i)>
9                <cfset ReturnList = ListAppend(ReturnList,i) />
10            </cfif>
11        </cfloop>
12    <cfelse>
13        <cfloop list="#mainList#" index="i">
14            <cfif NOT ListFindNoCase(compareList,i)>
15                <cfset ReturnList = ListAppend(ReturnList,i) />
16            </cfif>
17        </cfloop>
18    </cfif>
19    <cfreturn ReturnList />
20</cffunction>
Get from Same Value
view plain print about
1#ListGetDifferent("1,2,3,4,5", "1,3,5", "Same")# Return : 1,3,5

Get from Different Value

view plain print about
1#ListGetDifferent("1,2,3,4,5", "1,3,5", Differ")#
2Return : 2,4

Adobe ColdFusion 8 Developer Certification Examination Specification

I've created this post for who's planning to take CF8 exam. It's specification of CF8 exam which can be found as PDF format in Adobe Website. I've copied those all specifications from Centrasoft.com as well.

1. Programming Fundamentals

  • Given a type of variable, explain how to create and use that variable by using implicit and explicit syntax
  • Control the flow of a program by using conditionals and boolean expressions
  • Manage program iteration by using tags
  • Given a task, select and use the appropriate built-in function to perform that task
  • Create a user-defined function by using tags

2. Working with the Application framework

  • Given an Application.cfc method identify the use of that method
  • List and describe the differences between application scope variables and Application.cfc variables

3. Handling exceptions

  • Handle exceptions by using cftry, cfcatch, cfthrow, and cfrethrow
  • Handle exceptions by using the onError method of Application.cfc
  • Handle exceptions by using cferror
  • Handle exceptions by using the site wide error handler server setting

4. Interacting with databases

  • Create, read, update, and delete data by using cfquery
  • Create dynamic queries by using conditional clauses, variables, the like operator, and wildcards
  • Return data by performing a Query of Queries
  • List and describe the properties of the RESULT structure of a query object
  • Manage access to data by using cfldap
  • List and describe the information returned by the cfdbinfo tag
  • Implement database transactions by using cftransaction
  • Use cfqueryparam in SQL statements
  • Use cfstoredproc, cfprocparam, and cfprocresult to interact with database stored procedures

5. Working with XML

  • List and describe the differences between an XML document and an XML object
  • Parse XML data by using cfxml or xmlParse()
  • Extract an XML document from an XML object by using the toString() method

6. Reusing code

  • Include one page of code into another page of code by using the cfinclude tag
  • Given an approach, reuse code by using a custom tag. (Approaches include: using the cf_..., or cfmodule tags
  • Reuse code by creating user-defined functions. (User-defined functions written with either cffunction or within a cfscript block
  • Resuse code by creating ColdFusion Components (CFCs)
  • Control public or private access to CFC properties and methods by using scope prefixes for properties and the access attribute for methods
  • Understand the options available for instantiating CFCs and invoking CFC methods

7. Managing client state

  • List and describe the available variable scopes
  • Enable an application to use application and/or session scoped variables
  • Explain when you should lock variables by using

8. Interacting with remote systems

  • Given a scenario, create a Web service proxy and interact with that Web service
  • Explain how to expose a CFC method as a Web service
  • Create and read Atom and RSS feeds by using cffeed
  • Programmatically retrieve information from a remote server by using cfhttp

9. Managing files

  • Upload, read, write, and delete files by using cffile and file functions
  • Create directories on an application server by using cfdirectory

10. Tuning application performance

  • Manage application performance by using query caching
  • Use the cfcache tag to cache static content
  • List and describe the use of the cfthread tag and the associated actions: join, run, sleep, and terminate

11. Delivering and presenting information

  • Create and manipulate PDF documents by using cfdocument and cfpdf
  • Create and manipulate images by using cfimage
  • Expose a Rich Text editor by using cftextarea richText="true"

IsDefined in javascript

Sometimes, javascript errors are very kinda complicated to manipulate. What would you do if you need to check whether variable is passed by URL from other form? Do you'll have to declare this variable in your form? Nope, it's no need. Use typeof function of javascript.

view plain print about
1if (typeof(myval) != "undefined")
2{
3    alert(myval + "is here")
4}

escape() javascript

When we need to pass some parameters to another page with javascript, we should use escape() function of javascript. Unless, some of your parameters will be lost if included space and any special characters. Using this function will encode our parameters to ASCII characters like to %20.

view plain print about
1/*normal string format*/
2document.write ("this is ppshein")
output : this is ppshein
view plain print about
1/*encode string format with escape()*/
2document.write (escape("this is ppshein"))
output : this%20is%20ppshein

Top of Page