<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: ColdFusion code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 02:24:08 GMT</pubDate>
    <description>DZone Snippets: ColdFusion code</description>
    <item>
      <title>Directory Compare</title>
      <link>http://snippets.dzone.com/posts/show/4864</link>
      <description>ColdFusion - Compare two directories and report: &lt;br /&gt;1. What files exist in folder A, but not B. &lt;br /&gt;2. What files exist in folder B, but not A.&lt;br /&gt;3. What files exist in both, but appear different.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfsetting requesttimeout="9999"&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfparam name="FORM.DevelopmentDirectory" default="/kkkkkk/lllll/bbbb/ccc"&gt;&lt;br /&gt;&lt;cfparam name="FORM.ProductionDirectory" default="/mmmmmm/ggggg/bbbb/ccc"&gt;&lt;br /&gt;&lt;cfparam name="FORM.CommonDirectory" default="/ccc"&gt;&lt;br /&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;&lt;br /&gt;&lt;title&gt;Directory Compare&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Directory Compare&lt;/h3&gt;&lt;br /&gt;&lt;form name="directoryCompare" action="index.cfm" method="post"&gt;&lt;br /&gt;&lt;table&gt;&lt;br /&gt;	&lt;tr&gt;&lt;br /&gt;    	&lt;td&gt;Development Directory&lt;/td&gt;&lt;br /&gt;        &lt;td&gt;&lt;input name="DevelopmentDirectory" id="DevelopmentDirectory" type="text" value="&lt;cfoutput&gt;#FORM.DevelopmentDirectory#&lt;/cfoutput&gt;" size="70"&gt;&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;	&lt;tr&gt;&lt;br /&gt;    	&lt;td&gt;Production Directory&lt;/td&gt;&lt;br /&gt;        &lt;td&gt;&lt;input name="ProductionDirectory" id="ProductionDirectory" type="text" value="&lt;cfoutput&gt;#FORM.ProductionDirectory#&lt;/cfoutput&gt;" size="70"&gt;&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;	&lt;tr&gt;&lt;br /&gt;    	&lt;td&gt;Common Directory&lt;/td&gt;&lt;br /&gt;        &lt;td&gt;&lt;input name="CommonDirectory" id="CommonDirectory" type="text" value="&lt;cfoutput&gt;#FORM.CommonDirectory#&lt;/cfoutput&gt;" size="40"&gt;&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;    	&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;br /&gt;        &lt;td&gt;&lt;input type="submit" name="submit" value="submit"&gt;&lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfif isdefined('FORM.submit')&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfdirectory action="list" directory="#FORM.ProductionDirectory#" name="prodDir" recurse="yes"&gt;&lt;br /&gt;&lt;!--- &lt;cfdump var="#prodDir#"&gt; ---&gt;&lt;br /&gt;&lt;cfdirectory action="list" directory="#FORM.DevelopmentDirectory#" name="devDir" recurse="yes"&gt;&lt;br /&gt;&lt;!--- &lt;cfdump var="#devDir#"&gt; ---&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--- Need common directory base to compare ---&gt;&lt;br /&gt;&lt;cfset dev_strip = Mid(FORM.DevelopmentDirectory,1,FindNoCase(FORM.CommonDirectory,FORM.DevelopmentDirectory))&gt;&lt;br /&gt;&lt;cfset prod_strip = Mid(FORM.ProductionDirectory,1,FindNoCase(FORM.CommonDirectory,FORM.ProductionDirectory))&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--- o = Output Container ---&gt;&lt;br /&gt;&lt;cfset o = StructNew()&gt;&lt;br /&gt;&lt;cfset o.keys = ArrayNew(1)&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfloop query="prodDir"&gt;&lt;br /&gt;&lt;br /&gt;	&lt;!--- Put array string in the order that will sort correctly ---&gt;&lt;br /&gt;	&lt;cfset L = prodDir.TYPE &amp; "|" &amp; ReplaceNoCase(prodDir.DIRECTORY,prod_strip,"","all") &amp; "/" &amp; prodDir.NAME &gt;&lt;br /&gt;	&lt;!--- Turn the type/dir/name into something that makes a valid variable name ---&gt;&lt;br /&gt;	&lt;cfset k = "K" &amp; cfusion_encrypt(L,"key")&gt;&lt;br /&gt;&lt;br /&gt;	&lt;!--- Have we encountered this entry before? ---&gt;&lt;br /&gt;	&lt;!--- This also filters duplicates between the two queries. ---&gt;&lt;br /&gt;	&lt;cfif not StructKeyExists(o,k)&gt;&lt;br /&gt;		&lt;!--- Add to list of valid values ---&gt;&lt;br /&gt;		&lt;cfset ArrayAppend(o.keys,L &amp; "|" &amp; k)&gt;&lt;br /&gt;        &lt;cfset o[k] = StructNew()&gt;&lt;br /&gt;		&lt;cfset o[k].prod_path = ""&gt;&lt;br /&gt;		&lt;cfset o[k].prod_type = ""&gt;&lt;br /&gt;		&lt;cfset o[k].prod_size = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_path = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_type = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_size = ""&gt;&lt;br /&gt;	&lt;/cfif&gt;&lt;br /&gt;&lt;br /&gt;	&lt;cfset o[k].prod_path = prodDir.DIRECTORY &amp; "/" &amp; prodDir.NAME&gt;&lt;br /&gt;	&lt;cfset o[k].prod_type = prodDir.TYPE&gt;&lt;br /&gt;	&lt;cfset o[k].prod_size = prodDir.SIZE&gt;&lt;br /&gt;&lt;br /&gt;&lt;/cfloop&gt;&lt;br /&gt;&lt;!--- &lt;cfdump var="#o#"&gt; ---&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfloop query="devDir"&gt;&lt;br /&gt;&lt;br /&gt;	&lt;!--- Put array string in the order that will sort correctly ---&gt;&lt;br /&gt;	&lt;cfset L = devDir.TYPE &amp; "|" &amp; ReplaceNoCase(devDir.DIRECTORY,dev_strip,"","all") &amp; "/" &amp; devDir.NAME &gt;&lt;br /&gt;	&lt;!--- Turn the type/dir/name into something that makes a valid variable name ---&gt;&lt;br /&gt;	&lt;cfset k = "K" &amp; cfusion_encrypt(L,"key")&gt;&lt;br /&gt;&lt;br /&gt;	&lt;!--- Have we encountered this entry before? ---&gt;&lt;br /&gt;	&lt;!--- This also filters duplicates between the two queries. ---&gt;&lt;br /&gt;	&lt;cfif not StructKeyExists(o,k)&gt;&lt;br /&gt;		&lt;!--- Add to list of valid values ---&gt;&lt;br /&gt;		&lt;cfset ArrayAppend(o.keys,L &amp; "|" &amp; k)&gt;&lt;br /&gt;        &lt;cfset o[k] = StructNew()&gt;&lt;br /&gt;		&lt;cfset o[k].prod_path = ""&gt;&lt;br /&gt;		&lt;cfset o[k].prod_type = ""&gt;&lt;br /&gt;		&lt;cfset o[k].prod_size = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_path = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_type = ""&gt;&lt;br /&gt;		&lt;cfset o[k].dev_size = ""&gt;&lt;br /&gt;	&lt;/cfif&gt;&lt;br /&gt;&lt;br /&gt;	&lt;cfset o[k].dev_path = devDir.DIRECTORY &amp; "/" &amp; devDir.NAME&gt;&lt;br /&gt;	&lt;cfset o[k].dev_type = devDir.TYPE&gt;&lt;br /&gt;	&lt;cfset o[k].dev_size = devDir.SIZE&gt;&lt;br /&gt;&lt;br /&gt;&lt;/cfloop&gt;&lt;br /&gt;&lt;!--- &lt;cfdump var="#o#"&gt; ---&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfset ArraySort(o.keys,"textnocase","asc")&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfoutput&gt;&lt;br /&gt;&lt;table cellspacing="0" border="0" cellpadding="3"&gt;&lt;br /&gt;	&lt;tr&gt;&lt;br /&gt;        &lt;th&gt;Development&lt;/th&gt;&lt;br /&gt;    	&lt;th&gt;Production&lt;/th&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;	&lt;cfloop index="i" from="1" to="#ArrayLen(o.keys)#"&gt;&lt;br /&gt;	    &lt;cfset k = ListLast(o.keys[i],"|")&gt;&lt;br /&gt;	&lt;tr&gt;&lt;br /&gt;    	&lt;!--- DEV ---&gt;&lt;br /&gt;        &lt;td style="border-bottom:1px solid ##CCCCCC;"&gt;&lt;br /&gt;        	&lt;cfif o[k].prod_path EQ ""&gt;&lt;br /&gt;            	&lt;!--- On Dev NOT on Prod ---&gt;&lt;br /&gt;				&lt;span style="color:##0000FF; font-weight:bold;"&gt;&lt;br /&gt;            &lt;cfelse&gt;&lt;br /&gt;            	&lt;cfif o[k].prod_size NEQ o[k].dev_size&gt;&lt;br /&gt;                	&lt;!--- On Dev and On Prod, but Differnet ---&gt;&lt;br /&gt;					&lt;span style="color:##FF9900; font-weight:bold;"&gt;&lt;br /&gt;                &lt;cfelse&gt;&lt;br /&gt;                	&lt;!--- On Dev and On Prod and The Same (probably) ---&gt;&lt;br /&gt;					&lt;span&gt;&lt;br /&gt;				&lt;/cfif&gt;&lt;br /&gt;			&lt;/cfif&gt;&lt;br /&gt;        	#o[k].dev_path#&amp;nbsp;&lt;br /&gt;            &lt;/span&gt;&lt;br /&gt;			&lt;cfif o[k].dev_path NEQ ""&gt;&lt;br /&gt;            &lt;span style="font-size:smaller; color:##999999;"&gt;(#o[k].dev_size#)&lt;/span&gt;&lt;br /&gt;            &lt;/cfif&gt;&lt;br /&gt;        &lt;/td&gt;&lt;br /&gt;        &lt;!--- PROD ---&gt;&lt;br /&gt;    	&lt;td style="border-bottom:1px solid ##CCCCCC;"&gt;&lt;br /&gt;        	&lt;cfif o[k].dev_path EQ ""&gt;&lt;br /&gt;            	&lt;!--- On Prod NOT On Dev ---&gt;&lt;br /&gt;				&lt;span style="color:##FF0000; font-weight:bold;"&gt;&lt;br /&gt;            &lt;cfelse&gt;&lt;br /&gt;            	&lt;cfif o[k].prod_size NEQ o[k].dev_size&gt;&lt;br /&gt;                	&lt;!--- On Dev and On Prod, but Differnet ---&gt;&lt;br /&gt;					&lt;span style="color:##FF9900; font-weight:bold;"&gt;&lt;br /&gt;                &lt;cfelse&gt;&lt;br /&gt;                	&lt;!--- On Dev and On Prod and The Same (probably) ---&gt;&lt;br /&gt;					&lt;span&gt;&lt;br /&gt;				&lt;/cfif&gt;&lt;br /&gt;			&lt;/cfif&gt;&lt;br /&gt;        	#o[k].prod_path#&amp;nbsp;&lt;br /&gt;            &lt;/span&gt;&lt;br /&gt;			&lt;cfif o[k].prod_path NEQ ""&gt;&lt;br /&gt;            &lt;span style="font-size:smaller; color:##999999;"&gt;(#o[k].prod_size#)&lt;/span&gt;&lt;br /&gt;            &lt;/cfif&gt;&lt;br /&gt;        &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;    &lt;/cfloop&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/cfoutput&gt;&lt;br /&gt;&lt;/cfif&gt;&lt;br /&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 08 Dec 2007 02:23:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4864</guid>
      <author>brixon (Kris Brixon)</author>
    </item>
    <item>
      <title>Email a JavaScript Error using ColdFusion</title>
      <link>http://snippets.dzone.com/posts/show/3156</link>
      <description>This script emails an administrator when an error occurs, and could easily be adapted to log the error instead&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/*&lt;br /&gt;wwJsError (requires prototype.js)&lt;br /&gt;		send:	sends javascript error output email via coldfusion&lt;br /&gt;		--------------------&lt;br /&gt;			path:		relative path from the calling page to the coldfusion&lt;br /&gt;					email handler for this application (usually processJSerror.cfm)&lt;br /&gt;			funcname:	name of the JavaScript function that threw an error&lt;br /&gt;			name:		JavaScript error name (usually e.name in a catch block)&lt;br /&gt;			message:	JavaScript error message (usually e.message in a catch block)&lt;br /&gt;*/&lt;br /&gt;var wwJsError = {&lt;br /&gt;	send: function(path,funcname,name,message) {&lt;br /&gt;		try {&lt;br /&gt;&lt;br /&gt;			var url = path;&lt;br /&gt;&lt;br /&gt;			var pars = 'message=' + escape(message) + '&amp;name=' +&lt;br /&gt;					escape(name) + '&amp;funcname=' + escape(funcname);&lt;br /&gt;			&lt;br /&gt;			var httpMail = new Ajax.Request (&lt;br /&gt;				url, &lt;br /&gt;				{&lt;br /&gt;					method: 'post', &lt;br /&gt;					parameters: pars, &lt;br /&gt;					onComplete: Prototype.emptyFunction&lt;br /&gt;				}&lt;br /&gt;			);&lt;br /&gt;	&lt;br /&gt;		} catch (e) {&lt;br /&gt;			//if sending the email fails, just die quietly w/ no browser error&lt;br /&gt;			Prototype.emptyFunction();&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}; //end wwJsError&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Sample server-side script in ColdFusion&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfmail to="#application.administratoremail#" from="#application.administratoremail#"&lt;br /&gt;		subject="#application.apptitle# Error" type="HTML"&gt;&lt;br /&gt;	&lt;strong&gt;JavaScript Error:&lt;/strong&gt; #form.funcname# threw the following error:&lt;br /&gt;&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;Error name:&lt;/strong&gt; #form.name#&lt;br /&gt;&lt;br /&gt;	&lt;strong&gt;Error:&lt;/strong&gt; #form.message#&lt;br /&gt;&lt;/cfmail&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Generate the error&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function makeError() {&lt;br /&gt;	try {&lt;br /&gt;		alert(anError);&lt;br /&gt;	} catch(e) {&lt;br /&gt;		wwJsError.send('cf/processJSerror.cfm','makeError()',e.name,e.message);&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Result by email&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JavaScript Error:&lt;/b&gt; makeError threw the following error:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Error name:&lt;/b&gt; TypeError&lt;br /&gt;&lt;b&gt;Error:&lt;/b&gt; 'anError' is undefined&lt;br /&gt;</description>
      <pubDate>Fri, 15 Dec 2006 04:13:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3156</guid>
      <author>werewolves (KRK)</author>
    </item>
    <item>
      <title>Current year</title>
      <link>http://snippets.dzone.com/posts/show/1858</link>
      <description>// outputs current year&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#year(now())#.&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 07 Apr 2006 13:40:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1858</guid>
      <author>nataliedowne (Natalie Downe)</author>
    </item>
    <item>
      <title>Clean magic quoting in ColdFusion 5 and later</title>
      <link>http://snippets.dzone.com/posts/show/1711</link>
      <description>I'm updating my weblog software and needed some code to properly convert typewriter quotes to proper typographer's quotes.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;function magicQuote(txt) {&lt;br /&gt;    // Left quotes&lt;br /&gt;    txt = REReplace(txt, "(^|[ " &amp; Chr(9) &amp; Chr(10) &amp; Chr(13) &amp; "'])""", "\1&amp;##8220;", "ALL");&lt;br /&gt;    txt = REReplace(txt, "(^|[ " &amp; Chr(9) &amp; Chr(10) &amp; Chr(13) &amp; "]|&amp;##8220;)'",  "\1&amp;##8216;", "ALL");&lt;br /&gt;&lt;br /&gt;    // Right quotes&lt;br /&gt;    txt = Replace(txt, """",        "&amp;##8221;",  "ALL");&lt;br /&gt;    txt = Replace(txt, "'&amp;##8220;", "'&amp;##8221;", "ALL");&lt;br /&gt;    txt = Replace(txt, "'",         "&amp;##8217;",  "ALL");&lt;br /&gt;&lt;br /&gt;    return txt;&lt;br /&gt;}&lt;br /&gt;&lt;/cfscript&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;ColdFusion 5 has problems with &lt;em&gt;\s&lt;/em&gt;, and the character class is a workaround for this.</description>
      <pubDate>Fri, 17 Mar 2006 23:53:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1711</guid>
      <author>keith (Keith Gaughan)</author>
    </item>
    <item>
      <title>My ColdFusion Tagging Engine/Library</title>
      <link>http://snippets.dzone.com/posts/show/1700</link>
      <description>//via:http://www.whatspop.com/blog/2005/12/my-coldfusion-tagging-enginelibrary.cfm&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfset tags_list = " CaMELCaSE comma, 'singlequoted' &lt;b&gt;bold&lt;/b&gt; ""doublequoted"" double double this should be over the limit now " /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfset amount = 10 /&gt;&lt;br /&gt;&lt;cfset length = 20 /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfset tags_list = trim(tags_list) /&gt;&lt;br /&gt;&lt;cfset tags_list = lcase(tags_list) /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfset tags_struct = structnew() /&gt;&lt;br /&gt;&lt;cfloop index="tag" list="#tags_list#" delimiters=" "&gt;&lt;br /&gt;&lt;cfset tags_struct[tag] = "" /&gt;&lt;br /&gt;&lt;/cfloop&gt;&lt;br /&gt;&lt;cfset tags_list = structkeylist(tags_struct," ") /&gt;&lt;br /&gt;&lt;cfset tags_list = listsort(tags_list, "textnocase", "asc", " ") /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfif tags_list neq ""&gt;&lt;br /&gt;&lt;cfif listlen(tags_list," ") lte amount&gt;&lt;br /&gt;&lt;cfset amount = listlen(tags_list," ") /&gt;&lt;br /&gt;&lt;/cfif&gt;&lt;br /&gt;&lt;cfloop from="1" to="#amount#" index="tag"&gt;&lt;br /&gt;/* Perform a database upload here */&lt;br /&gt;&lt;cfoutput&gt;#htmleditformat(left(listgetat(tags_list,tag," "),length))#&lt;/cfoutput&gt;&lt;br /&gt;&lt;/cfloop&gt;&lt;br /&gt;&lt;cfelse&gt;&lt;br /&gt;Sorry, you need to provide at least one tag&lt;br /&gt;&lt;/cfif&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 15 Mar 2006 07:59:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1700</guid>
      <author>Mozier (Kenny Xiao)</author>
    </item>
    <item>
      <title>Customtag to remove blank lines</title>
      <link>http://snippets.dzone.com/posts/show/1648</link>
      <description>// description of your code here&lt;br /&gt;Coldfusion output has a lot of useless blank lines and makes the HTML code hard to read. I use this customtag to remove the blank lines. &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfif thisTag.ExecutionMode IS "end"&gt;&lt;br /&gt;	&lt;cfset thisTag.generatedContent =  ReReplaceNoCase(thisTag.generatedContent, '(?m)^\s+\r\n', '', "ALL")&gt;&lt;br /&gt;&lt;/cfif&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 07 Mar 2006 18:26:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1648</guid>
      <author>browzer (Constandinos)</author>
    </item>
    <item>
      <title>Creating a PDF using iText and ColdFusion</title>
      <link>http://snippets.dzone.com/posts/show/1646</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;// create document&lt;br /&gt;document 		= CreateObject("java", "com.lowagie.text.Document");&lt;br /&gt;document.init();&lt;br /&gt;&lt;br /&gt;// writer&lt;br /&gt;fileIO 			= CreateObject("java", "java.io.FileOutputStream");&lt;br /&gt;fileIO.init(pdf_path);&lt;br /&gt;writer 			= CreateObject("java", "com.lowagie.text.pdf.PdfWriter");&lt;br /&gt;writer.getInstance(document, fileIO);&lt;br /&gt;document.open();&lt;br /&gt;&lt;br /&gt;// newsinfo header image&lt;br /&gt;Image 			= CreateObject("java", "com.lowagie.text.Image");&lt;br /&gt;jpg 			= Image.getInstance(header_image);&lt;br /&gt;jpg.setAbsolutePosition(28, 713);&lt;br /&gt;jpg.setDpi(300,300);&lt;br /&gt;document.add(jpg);&lt;br /&gt;&lt;br /&gt;// top margin; dumb i know but i was in a hurry&lt;br /&gt;paragraph = CreateObject("java", "com.lowagie.text.Paragraph");&lt;br /&gt;paragraph.init(" ");&lt;br /&gt;for (i=0; i lt 9; i=i+1) {&lt;br /&gt;	document.add(paragraph);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// the fonts&lt;br /&gt;FontFactory 	= createobject("java", "com.lowagie.text.FontFactory");&lt;br /&gt;Font 			= createObject("java", "com.lowagie.text.Font");&lt;br /&gt;TimesLargeBI 	= Font.init(Font.TIMES_ROMAN, 14.0, Font.BOLDITALIC);&lt;br /&gt;TimesNormal 	= Font.init(Font.TIMES_ROMAN, 12.0);&lt;br /&gt;&lt;br /&gt;// all the text&lt;br /&gt;paragraph 		= CreateObject("java", "com.lowagie.text.Paragraph");&lt;br /&gt;&lt;br /&gt;paragraph.init("Hello World!", TimesLargeBI);&lt;br /&gt;paragraph.setIndentationLeft(indentation_left);&lt;br /&gt;paragraph.setIndentationRight(indentation_right);&lt;br /&gt;document.add(paragraph);&lt;br /&gt;&lt;br /&gt;paragraph.init("#dateFormat(now(), 'long')#", TimesNormal);&lt;br /&gt;paragraph.setIndentationLeft(indentation_left);&lt;br /&gt;paragraph.setIndentationRight(indentation_right);&lt;br /&gt;document.add(paragraph);&lt;br /&gt;&lt;br /&gt;document.close();&lt;br /&gt;&lt;/cfscript&gt; &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 07 Mar 2006 01:54:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1646</guid>
      <author>jnunemaker ()</author>
    </item>
    <item>
      <title>Coldfusion Whois component</title>
      <link>http://snippets.dzone.com/posts/show/1610</link>
      <description>A whois cfc for querying a whois client.&lt;br /&gt;&lt;br /&gt;whois.cfc&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfcomponent name="WhoIs" output="true"&gt;&lt;br /&gt;&lt;br /&gt;   &lt;!--- the host to connect to ---&gt;&lt;br /&gt;   &lt;cfset variables.server = ""&gt;&lt;br /&gt;   &lt;!--- port on server to connect to ---&gt;&lt;br /&gt;   &lt;cfset variables.port = ""&gt;&lt;br /&gt;   &lt;!--- the whois query to run ---&gt;&lt;br /&gt;   &lt;cfset variables.whoisQuery = ""&gt;&lt;br /&gt;   &lt;!--- socket timeout in seconds ---&gt;&lt;br /&gt;   &lt;cfset variables.connTimeout = 0&gt;&lt;br /&gt;   &lt;!--- the result of the server response ---&gt;&lt;br /&gt;   &lt;cfset variables.response = ""&gt;&lt;br /&gt;&lt;br /&gt;   &lt;cffunction name="init" access="public" returntype="WhoIs" hint=""&gt;&lt;br /&gt;      &lt;cfargument name="server" type="string" default="whois.geektools.com"/&gt;&lt;br /&gt;      &lt;cfargument name="port" type="numeric" default="43"/&gt;&lt;br /&gt;      &lt;cfargument name="connTimeout" type="numeric" default="30" hint="Socket timeout in seconds"/&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;cfscript&gt;&lt;br /&gt;         variables.server = arguments.server;&lt;br /&gt;         variables.port = JavaCast("int",arguments.port);&lt;br /&gt;         variables.connTimeout = (arguments.connTimeout * 1000);&lt;br /&gt;         &lt;br /&gt;         //create before use          variables.connection = createObject("java","java.net.Socket").init(variables.server,variables.port);&lt;br /&gt;         &lt;br /&gt;         //dump(variables.connection,true);       &lt;/cfscript&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;cfreturn this&gt;&lt;br /&gt;   &lt;/cffunction&gt;&lt;br /&gt;   &lt;br /&gt;   &lt;cffunction name="lookup" access="public" returntype="any" hint=""&gt;&lt;br /&gt;      &lt;cfargument name="whoisQuery" type="string" required="true"/&gt;&lt;br /&gt;      &lt;cfset var line = ""&gt;&lt;br /&gt;      &lt;cfset var eof = false&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;cfscript&gt;&lt;br /&gt;         variables.whoisQuery = arguments.whoisQuery;&lt;br /&gt;         variables.connection.setSoTimeout(JavaCast("int",variables.connTimeout));&lt;br /&gt;         out = createObject("java","java.io.PrintStream").init(variables.connection.getOutputStream());&lt;br /&gt;         //send the query to the server          out.println(variables.whoisQuery);&lt;br /&gt;         variables.response = variables.response &amp; "Connection made to: " &amp; "[" &amp; variables.server &amp; ":" &amp; variables.port &amp; "]";&lt;br /&gt;         &lt;br /&gt;         instream = createObject("java","java.io.BufferedReader").init(createObject("java","java.io.InputStreamReader").init(variables.connection.getInputStream() ));&lt;br /&gt;         &lt;br /&gt;         &lt;br /&gt;         try {&lt;br /&gt;            //output results             while(not eof) {&lt;br /&gt;               line = instream.readLine();&lt;br /&gt;               variables.response = variables.response &amp; line &amp; "#chr(10)#";&lt;br /&gt;            }&lt;br /&gt;         }   &lt;br /&gt;         //coldfusion cant check for null so check for an UndefinedVariableException          catch(coldfusion.runtime.UndefinedVariableException exception) {&lt;br /&gt;               eof = true;&lt;br /&gt;         }&lt;br /&gt;         catch(Any e){&lt;br /&gt;            writeOutput("Catch All Exception: " &amp; e);&lt;br /&gt;         }&lt;br /&gt;         out.close();&lt;br /&gt;         instream.close();&lt;br /&gt;         variables.connection.close();&lt;br /&gt;      &lt;/cfscript&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;cfreturn variables.response&gt;&lt;br /&gt;      &lt;br /&gt;   &lt;/cffunction&gt;&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;   &lt;cffunction name="dump" access="public" returntype="void" output="true" hint=""&gt;&lt;br /&gt;      &lt;cfargument name="var" type="any" required="true"/&gt;&lt;br /&gt;      &lt;cfargument name="abort" type="boolean" default="false"/&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;cfdump var="#arguments.var#" label="#arguments.var#"&gt;&lt;br /&gt;      &lt;cfif arguments.abort&gt;&lt;cfabort&gt;&lt;/cfif&gt;&lt;br /&gt;   &lt;/cffunction&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;/cfcomponent&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;index.cfm&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;   wi = createObject("component","WhoIs").init("whois.geektools.com",43,10);&lt;br /&gt;   results = wi.lookup("google.com");&lt;br /&gt;   writeOutput(htmlCodeFormat(results));&lt;br /&gt;&lt;/cfscript&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 02 Mar 2006 09:09:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1610</guid>
      <author>danvega (Dan Vega)</author>
    </item>
    <item>
      <title>Simple Cold Fusion Script That Generates HTML Select List Combo</title>
      <link>http://snippets.dzone.com/posts/show/868</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- ## Simple Cold Fusion Script That Generates HTML Select List Combo ## --&gt;&lt;br /&gt;&lt;!-- ## That Allows User To Enter Date Of Birth ## --&gt;&lt;br /&gt;&lt;!-- ## Uploaded by James Cullin (james.cullin@humber.ca) ## --&gt;&lt;br /&gt;&lt;!-- ## http://jamescullin.com ## --&gt;&lt;br /&gt;&lt;br /&gt;&lt;cfoutput&gt;&lt;br /&gt;&lt;br /&gt;&lt;select&gt;&lt;br /&gt;	&lt;option&gt; - Month - &lt;/option&gt;&lt;br /&gt;	&lt;cfloop index="m" list="January, February, March, April, May, June, July, August, September, October, November, December" delimiters=","&gt;&lt;br /&gt;	&lt;option value="#m#"&gt;#m#&lt;/option&gt;&lt;br /&gt;	&lt;/cfloop&gt;&lt;br /&gt;&lt;/select&gt;&lt;br /&gt;&lt;br /&gt;&lt;select&gt;&lt;br /&gt;	&lt;option&gt; - Day - &lt;/option&gt;&lt;br /&gt;	&lt;cfloop index="d" from="1" to="31" step="1"&gt;&lt;br /&gt;	&lt;option value="#d#"&gt;#d#&lt;/option&gt;&lt;br /&gt;	&lt;/cfloop&gt;&lt;br /&gt;&lt;/select&gt;&lt;br /&gt;&lt;br /&gt;&lt;select&gt;&lt;br /&gt;	&lt;option&gt; - Year - &lt;/option&gt;&lt;br /&gt;	&lt;cfloop index="y" from="2004" to="1900" step="-1"&gt;&lt;br /&gt;	&lt;option value="#y#"&gt;#y#&lt;/option&gt;&lt;br /&gt;	&lt;/cfloop&gt;&lt;br /&gt;&lt;/select&gt;&lt;br /&gt;&lt;br /&gt;&lt;/cfoutput&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 07 Nov 2005 05:04:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/868</guid>
      <author>jamescullin (James Cullin)</author>
    </item>
    <item>
      <title>Alternate table cell background color</title>
      <link>http://snippets.dzone.com/posts/show/326</link>
      <description>&lt;code&gt;&lt;br /&gt;BGCOLOR="###IIF(currentrow MOD 2, DE ('FFFFCC'), DE ('FFFFFF'))#"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 26 May 2005 08:57:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/326</guid>
      <author>i8flan (Matt)</author>
    </item>
  </channel>
</rss>
