Automate Compressing JS and CSS with ANT

December 31, 2009

I’m still a bit of a n00b with ANT still, but I took the time today to improve my skills with it a tad to help automate a task which has become quite repetitive. Once we are ready to roll changes to our application we first have to minify our JavaScript and CSS files. We use the YUI Compressor which is a very nice compression engine for both JS and CSS. It also just so happens that they have a Java executable JAR to run compression against your files with.

As such I set out to make an ANT script. For an entry talking about the basics of building ANT scripts see my blog entry on Using ANT to Automate a Build. In this post I’m simply going to cover how to call the JAR file to perform minification.

(more…)

3

Basic Query Loop and Group in ColdFusion

December 30, 2009

While going over the DreamInCode.net forums I came across this question.

Good day everyone. I’m hoping someone can point me in the right direction. I’ve been using Coldfusion for awhile, although I admit, I’m not a master at it. I’m pulling my hair out on a project I’m hoping someone can shed some light on. I have a table in my database that I want to group and output a report on. It’s a table tracking purchases and types of purchases. Here’s the data I’m collecting: from_name, from_company, transaction_type, and amount. I have a few other fields, but they aren’t needed for this report. There are multiple transactions per person and a varying number of persons. What I need to do is to create queries that will group by name or company, which doesn’t matter, give me a count of transaction types (3 of A, 6 of B, etc.) as well as a total amount of each type, then show the total transactions count by name or company and the total amount. I’m trying to output in a table having each row be the data from each company. Can someone point me in the right direction to group such output, do counts on the number of records as well as show totals dollars? Thank you so much for any advice you might have.

(more…)

2

Webservice WSDL Document Consumption in ColdFusion

December 30, 2009

This question was posted on the Adobe ColdFusion forums (found here at http://forums.adobe.com/thread/546708?tstart=0).

Does anyone know of a service for this compatible with CF? I need to display an amount for Korean Won and USD on a checkout form and the service at http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl doesn’t exist anymore. I searched Google for a while but didn’t find much. Thanks!

The issue was in understanding how to read a raw WSDL (Web Service Description Language) document. I’ll be the first to admit that these can be a bit daunting, but after you know a little about how they are typically structured, you can surmise what methods and their arguments are available to you.

(more…)

1

Example of jQuery Autocomplete with ColdFusion

December 22, 2009

A useful feature, and high “value add” to many sites today is a text box with autocomplete and suggestion as you type. The powerful jQuery JavaScript library makes this really easy to do, especially with the help of the excellent autocomplete plugin from bassistance.de. In this example we will setup a page to search for people, with a text box, a hidden field to hold the ID of our selected person, and a submit button. The setup is pretty simple. Let’s take a look at that code.

From here we need a little JavaScript magic to wire up our autocomplete. There are three items of concern. The first is just setting up the autocomplete on the text box. The next item is to make sure that when a selection is made our hidden field (which contains the person’s ID) is populated. The final area of concern is if the user blanks out the text box value, we want to reset our hidden field. Let’s look at the first part where we setup the autocomplete.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * Initialize the autocomplete. Will call ajax_searchPersons.cfm
 * and pass the variable "q" as the query.
 */
$("#searchPersonText").autocomplete("ajax_searchPersons.cfm", {
	width: 300,
	multiple: false,
	formatItem: function(row) {
		return row[1];
	},
	formatResult: function(row) {
		return row[1];
	}
});

In that snippet we are telling the autocomplete control that it will retrieve its data from a ColdFusion page called “ajax_searchPersons.cfm”. Aside from a couple of basic configuration options, there are two options worth noting in detail. The first is the formatItem value. This configuration parameter takes a function, and is passed an array containing the key, and the value returned from the AJAX call. This is called to display the suggestion box. The next is the formatResult value. This function takes the same parameter, and dictates what displays in the text box when an item is selected.

Now we need to populate our hidden field once a selection is made. This is done by calling the result method against our text box. It takes a function as an argument, with three parameters: event, data, and formatted text. The data argument is what we are interested in. Again this argument is an array with two values, the key, and the value. Let’s look at that.

1
2
3
4
5
6
7
/*
 * When an item is selected from the autocomplete
 * dropdown, set the selected ID into the hidden field.
 */
$("#searchPersonText").result(function(e, data, formatted) {
	$("#personId").val(data[0]);
});

And finally we want to make sure that if the user blanks out the text box we reset the hidden field’s value to zero. To do this we will handle the onblur event. In this handler we’ll check the text box for a blank value. If it is blank, we will zero out the hidden field. Here is that code.

1
2
3
4
5
6
7
8
9
10
11
/*
 * When we blur off the text box we want to make sure
 * something is selected. If we've cleared it out zero
 * out the hidden field.
 */
$("#searchPersonText").blur(function(e) {
	if ($("#searchPersonText").val() === "") 
	{
		$("#personId").val("0");
	}
});

Now let’s talk about the server side. The bassistance.de autocomplete plugin will pass a URL variable called “q” to a server side page, and expects a set of records delimited by a carriage return. Each record must have a key and value, delimited by a pipe. So, for example, if my ID is 1, and my name is “Adam Presley”, I will send back a record like this (without quotes): “1|Adam Presley”. This will be followed by a new line.

I have a sample database with a table called “persons”, and I’ve populated it with sample data (provided below). This page will query that table for any records where the first name plus last name is like the search string passed in by the autocomplete JavaScript. We will then craft the pipe delimited records and spit it out onto the page. Here’s that code now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<cfsetting enablecfoutputonly="true" showdebugoutput="false" /><cfsilent>
 
<cfset local = structNew() />
 
<cfquery name="qryPersons" datasource="dsn">
	SELECT
		p.id
		, p.firstName
		, p.lastName
 
	FROM persons AS p
	WHERE
		(CONCAT(p.firstName, ' ', p.lastName) LIKE <cfqueryparam value="%#url.q#%" cfsqltype="cf_sql_varchar" />)
</cfquery>
 
<cfset local.output = "" />
<cfset local.crlf = "#chr(13)##chr(10)#" />
 
<!---
	This jQuery plugin requires the data to come back formatted like:
		key|value\n
--->
<cfloop query="qryPersons">
	<cfset local.output = local.output & "#qryPersons.id#|#qryPersons.firstName# #qryPersons.lastName##local.crlf#" />
</cfloop>
 
</cfsilent><cfoutput>#local.output#</cfoutput>

Take a look at the demo page to see this code in action. As you can see this plugin is pretty easy to use, and powerful too. The code for all of this is below. Happy coding!

index.cfm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>jQuery Autocomplete Example</title>
 
	<link type="text/css" rel="stylesheet" href="jquery-autocomplete/jquery.autocomplete.css" />
 
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
	<script type="text/javascript" src="jquery-autocomplete/jquery.autocomplete.min.js"></script>
</head>
 
<body>
 
	<cfif structKeyExists(form, "btnSubmit")>
		<p><cfoutput>You searched for #form.searchPersonText# and found ID #form.personId#</cfoutput></p>
	</cfif>
 
	<p>
		Please type in the name of the person you are searching for.
		For example, try typing "sel", or "ja".
	</p>
 
	<form name="frmSearch" id="frmSearch" method="post">
		<input type="text" id="searchPersonText" name="searchPersonText" value="" />
		<input type="hidden" id="personId" name="personId" value="0" />
 
		<br />
		<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
	</form>
 
	<script type="text/javascript">
 
		$(function() {
 
			var ExamplePage = function()
			{
				this.initialize = function()
				{
					/*
					 * Initialize the autocomplete. Will call ajax_searchPersons.cfm
					 * and pass the variable "q" as the query.
					 */
					$("#searchPersonText").autocomplete("ajax_searchPersons.cfm", {
						width: 300,
						multiple: false,
						formatItem: function(row) {
							return row[1];
						},
						formatResult: function(row) {
							return row[1];
						}
					});
 
					/*
					 * When an item is selected from the autocomplete
					 * dropdown, set the selected ID into the hidden field.
					 */
					$("#searchPersonText").result(function(e, data, formatted) {
						$("#personId").val(data[0]);
					});
 
					/*
					 * When we blur off the text box we want to make sure
					 * something is selected. If we've cleared it out zero
					 * out the hidden field.
					 */
					$("#searchPersonText").blur(function(e) {
						if ($("#searchPersonText").val() === "") 
						{
							$("#personId").val("0");
						}
					});
 
					$("#searchPersonText").focus();
				};
 
				this.initialize();
			}();
 
		});
 
	</script>
</body>
</html>

ajax_searchPersons.cfm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<cfsetting enablecfoutputonly="true" showdebugoutput="false" /><cfsilent>
 
<cfset local = structNew() />
 
<cfquery name="qryPersons" datasource="mysqlcf_cfexamples">
	SELECT
		p.id
		, p.firstName
		, p.lastName
 
	FROM persons AS p
	WHERE
		(CONCAT(p.firstName, ' ', p.lastName) LIKE <cfqueryparam value="%#url.q#%" cfsqltype="cf_sql_varchar" />)
</cfquery>
 
<cfset local.output = "" />
<cfset local.crlf = "#chr(13)##chr(10)#" />
 
<!---
	This jQuery plugin requires the data to come back formatted like:
		key|value\n
--->
<cfloop query="qryPersons">
	<cfset local.output = local.output & "#qryPersons.id#|#qryPersons.firstName# #qryPersons.lastName##local.crlf#" />
</cfloop>
 
</cfsilent><cfoutput>#local.output#</cfoutput>

SQL Data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
CREATE TABLE persons (
  `id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `personId` MEDIUMINT DEFAULT NULL,
  `firstName` varchar(255) DEFAULT NULL,
  `lastName` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1; 
 
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('1','Imogene','Coffey','nec.tempus.scelerisque@montesnascetur.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('2','Marsden','Mcbride','malesuada.malesuada.Integer@vitae.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('3','Jescie','Vang','neque.venenatis@ipsum.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('4','August','Hewitt','Nullam@MorbimetusVivamus.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('5','Raven','Gilmore','Sed@mollisInteger.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('6','Susan','Reyes','Proin.vel@Duiscursus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('7','Maya','Soto','massa@bibendumDonecfelis.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('8','Wyatt','Nixon','Fusce.dolor.quam@Cum.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('9','Alfonso','Ochoa','nunc.In@nec.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('10','Kim','Price','massa.Mauris.vestibulum@Morbimetus.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('11','Selma','Wilder','nec@SeddictumProin.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('12','Luke','Maddox','Donec.porttitor@a.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('13','Fatima','Ramos','dui.semper@etrisus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('14','Ivory','Lynch','dui@amet.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('15','Rebekah','Duke','id.libero@magna.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('16','Anjolie','Lester','placerat.orci.lacus@sem.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('17','Farrah','Mcmillan','venenatis.vel.faucibus@lobortisClass.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('18','Randall','Carrillo','posuere@egetvolutpatornare.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('19','Zane','Curtis','placerat.eget@elementumat.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('20','Nelle','Hunt','erat.eget@ornarelectusjusto.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('21','Aurora','Joyner','est.Mauris@id.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('22','Ivana','Rivera','luctus.et.ultrices@Donecfeugiatmetus.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('23','Macy','Hopkins','Donec.non.justo@acrisus.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('24','Brooke','Hart','a.feugiat.tellus@euodiotristique.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('25','Shaeleigh','Montgomery','ac@amet.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('26','Coby','Coffey','fermentum.metus@velarcueu.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('27','Sybill','Hunt','Fusce.mi@sapienNuncpulvinar.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('28','Kuame','Hawkins','nisl.Nulla@ornarelectusjusto.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('29','Martena','Monroe','est@odio.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('30','Harper','Rodriguez','dictum.magna.Ut@Fuscealiquetmagna.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('31','Valentine','Hebert','risus@temporestac.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('32','Quamar','Lindsay','nunc.sed@Aliquamtinciduntnunc.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('33','Olivia','Daniels','nulla.Integer@euduiCum.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('34','Brenden','Reeves','vehicula@etarcu.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('35','Kareem','Booker','vel.est@sagittisfelis.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('36','Giacomo','Wise','magna.Sed@feugiatLorem.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('37','Ivy','Tucker','at.augue@Aliquam.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('38','Yuri','Montgomery','erat.Sed@massalobortis.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('39','Vernon','Parsons','luctus.sit.amet@aliquameuaccumsan.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('40','Drew','Love','id@lobortisnisi.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('41','Amal','Oneal','est@duiCum.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('42','Oliver','Montgomery','pretium@Donec.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('43','Mechelle','Garcia','dictum.magna@sit.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('44','Ruby','Cline','non.arcu.Vivamus@famesacturpis.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('45','Dean','Riddle','libero.at@anteblandit.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('46','Andrew','Fox','eu.placerat@lacusvestibulumlorem.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('47','Clayton','Forbes','in@turpisIn.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('48','May','Sims','sodales.purus@quis.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('49','Phyllis','Kerr','sed@Phasellus.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('50','Odysseus','Holden','ligula@Sedeunibh.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('51','Minerva','Cooley','risus@rhoncusNullam.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('52','Brianna','Bentley','a@inaliquetlobortis.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('53','Virginia','Byrd','rhoncus.Donec.est@consequatdolor.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('54','Tana','Sykes','bibendum@arcu.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('55','Anthony','Mejia','cubilia.Curae;.Donec@euismodindolor.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('56','Fallon','Gamble','vel.arcu@idmagna.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('57','Emily','Dyer','dolor.egestas@ametornare.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('58','Ahmed','Hewitt','sem.semper@Praesent.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('59','Maisie','Peterson','commodo.auctor.velit@senectuset.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('60','Cally','Sexton','convallis@Mauris.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('61','Kevyn','Webster','neque@magna.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('62','Logan','Sykes','urna@pede.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('63','Macaulay','Ford','Cras@ac.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('64','Grady','Rose','enim.gravida@Mauriseu.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('65','Rashad','Rogers','et.magnis.dis@elementumpurusaccumsan.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('66','Wing','Mcdonald','Mauris@vehiculaPellentesque.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('67','Rebekah','Wallace','sollicitudin.orci.sem@elit.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('68','Derek','Owen','erat.eget@Fuscediam.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('69','Brenda','Goff','luctus@in.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('70','Stuart','Wise','Donec.elementum@metusAenean.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('71','Andrew','Walker','neque.non@pharetranibhAliquam.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('72','Blaine','Barker','lorem.auctor.quis@miloremvehicula.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('73','Cooper','Hughes','nec@arcuVestibulumante.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('74','Victoria','Craft','In.at@Nulla.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('75','Portia','Levine','mauris@idlibero.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('76','Gage','Vargas','vel.est.tempor@vulputateveliteu.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('77','Myra','Gaines','ipsum.nunc.id@etnuncQuisque.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('78','Lavinia','Cannon','sociis.natoque@elitpharetra.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('79','Kelsey','Sharpe','nisl.arcu.iaculis@tinciduntpede.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('80','Savannah','Nash','Maecenas.libero.est@loremsit.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('81','Kelsey','Justice','Fusce.fermentum@NullafacilisiSed.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('82','Leigh','Byrd','sem.molestie@ultrices.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('83','Lynn','Sears','ipsum@laoreetposuere.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('84','Alice','Atkinson','in.cursus@feugiatnecdiam.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('85','Desiree','Wise','a.mi@tristiquesenectus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('86','Dorothy','Farrell','blandit@arcuSed.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('87','Mira','Hawkins','nibh.Aliquam.ornare@In.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('88','Tana','Pearson','dapibus.gravida.Aliquam@risusvariusorci.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('89','Idola','Quinn','parturient.montes.nascetur@magnaseddui.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('90','Chester','Levine','dui.Fusce@egetmagnaSuspendisse.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('91','Conan','Cochran','et.commodo@orciPhasellus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('92','Roary','Roberson','velit.in@ultricessit.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('93','Cynthia','Walton','et.magnis@orciluctuset.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('94','Howard','Pacheco','lobortis.tellus.justo@Nunc.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('95','Amanda','Wells','Class.aptent@eget.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('96','Oleg','Sanford','nibh.vulputate@pharetrased.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('97','Axel','Jacobson','non.feugiat.nec@tacitisociosqu.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('98','Belle','Keller','Donec@metus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('99','Ian','Harvey','elementum@enimEtiam.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('100','Joshua','Goff','urna.suscipit.nonummy@elit.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('101','Phillip','Clarke','lorem.ut.aliquam@sagittisaugue.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('102','Ann','Briggs','eros@scelerisqueneque.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('103','Ramona','Johnson','lorem.semper.auctor@Sedetlibero.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('104','Dai','Maldonado','primis.in@egetdictumplacerat.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('105','Aristotle','Ingram','eu.sem.Pellentesque@Aliquamnisl.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('106','Elaine','Leonard','dui.semper.et@idenim.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('107','Cruz','Flynn','Curabitur@vulputateposuerevulputate.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('108','Maryam','Townsend','risus.a.ultricies@eudolor.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('109','Gregory','Kelley','vestibulum.neque@aptenttacitisociosqu.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('110','Lila','Weaver','tempor.lorem.eget@acorci.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('111','Brady','Mendez','ac.libero.nec@egetmollislectus.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('112','Naomi','Schneider','rhoncus.Nullam@semegetmassa.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('113','Charlotte','Moses','turpis.nec.mauris@malesuada.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('114','Benedict','Mueller','rhoncus@tempordiam.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('115','Azalia','Sheppard','semper.auctor.Mauris@Nullamenim.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('116','Hadassah','Hobbs','dapibus.quam.quis@sed.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('117','Yasir','Sheppard','at.sem@purusDuis.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('118','Maite','Singleton','in.faucibus.orci@miac.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('119','Blaine','Bennett','Nulla@eusemPellentesque.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('120','Grace','Graham','luctus.et.ultrices@risusatfringilla.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('121','Alice','Dillon','Integer@velit.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('122','Lane','Everett','lobortis.risus.In@hendrerit.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('123','Maggie','Lamb','Curae;.Donec@aliquetdiam.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('124','Jermaine','Cline','ut@semconsequat.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('125','Fiona','Bean','lorem.ac@sed.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('126','Hamilton','Grimes','non.lobortis@Integerin.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('127','Quentin','Acosta','est@utodio.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('128','Basia','Russell','Vestibulum@Seddiamlorem.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('129','Kato','Mcmillan','non.quam.Pellentesque@disparturient.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('130','William','Stone','mus.Proin@non.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('131','Tad','Klein','eget.magna@Cumsociis.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('132','Alec','Welch','odio@necurnasuscipit.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('133','Patrick','Mccormick','ut@Phasellus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('134','Shoshana','Harmon','a@ultrices.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('135','Kameko','Weeks','velit.Sed@semegestas.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('136','Xavier','Haley','eget@perconubia.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('137','Beau','Juarez','iaculis.lacus.pede@Phasellus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('138','Diana','Walls','dolor@sagittis.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('139','Lester','Hays','nunc@etrutrum.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('140','Ruby','Griffin','Etiam.laoreet@etmagnisdis.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('141','Aubrey','Tyson','consequat.purus.Maecenas@penatibuset.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('142','Jasper','Maddox','Donec@ligulaconsectetuer.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('143','Russell','Stevens','leo.Cras.vehicula@volutpat.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('144','Mannix','Guzman','porttitor@nonmagnaNam.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('145','Jerry','Daniels','blandit@id.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('146','Keiko','Mccoy','Lorem.ipsum.dolor@habitant.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('147','Marah','Cole','purus.Duis@egestas.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('148','Galvin','Downs','odio.auctor@Crasvehicula.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('149','Graiden','Workman','augue.eu.tempor@velit.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('150','Gemma','Mcintosh','tincidunt@morbi.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('151','Forrest','Osborn','a.arcu@risusInmi.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('152','Violet','Mccormick','risus@tortorNunccommodo.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('153','James','Briggs','eleifend.egestas.Sed@sodales.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('154','Erich','Barber','ridiculus@ataugue.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('155','Roth','Austin','cursus.a@lacusQuisquepurus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('156','Lev','Dalton','mauris.sagittis@felisegetvarius.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('157','Maris','Kramer','Nunc@scelerisquedui.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('158','Nina','Bowers','nec.urna@Aenean.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('159','Phyllis','Scott','Donec@interdumligulaeu.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('160','Lacy','Mcleod','Duis.gravida.Praesent@Vivamuseuismodurna.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('161','Maite','Cline','In.faucibus@uterosnon.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('162','Eve','Frazier','lacus@variuset.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('163','Kasper','Lott','vehicula.Pellentesque.tincidunt@Aliquamerat.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('164','Cora','Hutchinson','et.tristique@neque.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('165','Tara','Pugh','Quisque.fringilla@elementumsemvitae.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('166','Macy','Peters','velit@tortor.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('167','Imani','Guerrero','ac.feugiat.non@bibendumfermentummetus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('168','Echo','Leonard','eu@sapienCrasdolor.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('169','Aretha','Austin','mauris@pedeetrisus.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('170','Nathaniel','Barnett','condimentum@purusDuiselementum.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('171','Rebekah','Wallace','Mauris@Duis.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('172','Colorado','Santos','tellus.Suspendisse@quisaccumsan.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('173','Garrison','Brady','egestas@rutrum.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('174','Tallulah','Holland','id.ante.Nunc@nonlorem.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('175','Dalton','Mccray','vestibulum@montesnascetur.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('176','Sage','Keller','a.scelerisque@a.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('177','Maya','Dunlap','accumsan.interdum@netuset.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('178','Jemima','Hart','quam.a.felis@Donecnonjusto.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('179','Erasmus','Pratt','mauris.sagittis.placerat@neque.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('180','Shannon','Franklin','Curabitur.vel.lectus@utmolestiein.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('181','Blake','Adkins','interdum@risus.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('182','Lysandra','Myers','nisi@ac.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('183','Sybill','Little','elit.dictum@Vestibulum.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('184','Linda','Cortez','nulla@nequeNullam.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('185','Faith','Ferguson','dolor.elit.pellentesque@ut.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('186','Kieran','Underwood','nulla.at.sem@pellentesqueSed.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('187','Madonna','Barnett','et.rutrum.eu@interdumenim.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('188','Shelley','Frederick','Sed.auctor@etmagnis.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('189','Alexis','Ratliff','consectetuer@volutpat.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('190','Ferris','Williamson','eros.Proin.ultrices@euismodetcommodo.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('191','Jameson','Aguilar','interdum@non.org');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('192','Madeson','Berger','tortor@musDonec.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('193','Tanner','Greer','dolor.dapibus.gravida@nunc.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('194','Callie','Puckett','dui@Aliquamgravidamauris.com');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('195','Lucius','Spears','Fusce.aliquet@montesnasceturridiculus.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('196','Troy','Miranda','dictum.ultricies.ligula@convallisdolorQuisque.edu');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('197','Athena','Patton','et.libero.Proin@consectetuer.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('198','Chase','Mullins','Quisque@aaliquet.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('199','Brenda','Cantu','faucibus@amet.ca');
INSERT INTO `persons` (`personId`,`firstName`,`lastName`,`email`) VALUES ('200','Steven','Castaneda','Etiam.laoreet.libero@orciconsectetuereuismod.com');
1

Dumbass Code of the Week 12-20-2009

December 21, 2009

Please, someone explain to me why this was necessary. The first line of code is just a sample setup. The real code has a loop over some orders, assembles this string, and adds the word “NewOrder” at the end of it. It then executes line #2 with the revers, replace, and reverse. This is the part I’m not sure I get. I run it, and see that the word NewOrder is just removed. So why all the crazy reverses and such?? No idea.

1
2
3
4
<cfset OrderDetailStringM = "1,5,SplitHere,10,600,NewOrder5,85,684" />
<cfset OrderDetailStringM = reverse(replace(reverse(OrderDetailStringM),"redrOweN",""))>
 
<cfdump var="#OrderDetailStringM#" />

Uh…

2

SES URLs with OpenBD and Google App Engine

December 17, 2009

A little tidbit that I though I’d share. While playing with the Google App Engine (GAE) version of the OpenBD CFML engine I noticed that SES friendly URL’s weren’t working for me. After a small search I came across a bug entry on the OpenBD site that suggested that the SES filter is not setup in the GAE version by default, and that the following XML needed to be added to the WEB-INF/web.xml configuration file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
	<filter>
		<filter-name>SearchEngineFriendlyURLFilter</filter-name>
		<display-name>SearchEngineFriendlyURLFilter</display-name>
		<description>SearchEngineFriendlyURLFilter</description>
		<filter-class>com.newatlanta.filters.SearchEngineFriendlyURLFilter</filter-class>
		<init-param>
		<param-name>extensions</param-name>
		<param-value>cfm,cfml</param-value>
		</init-param>
	</filter>
	<filter-mapping>
    	<filter-name>SearchEngineFriendlyURLFilter</filter-name>
    	<url-pattern>/index.cfm/*</url-pattern>
	</filter-mapping>

This is to be inserted just before the closing tag. After a quick restart of the OpenBD context, I was good to go.

Happy coding!

0

Setting Cookies then Relocating in ColdFusion

December 15, 2009

This question came across the ColdFusion User Group just recently. The developer has some type of login form, followed by a query that validates the user’s information. It then attempts to set a cookie then redirect to another page. The subsequent page checks for the existence of the cookie, and if it is not set will relocate back to the login page. The developer kept getting kicked back to the login page, as if the cookie was never set.

In this case it wasn’t. The reason is because when you do a CFLOCATION existing headers will be cleared out, and the Location header will be sent instead, cause the browser to redirect the user to a new page. The cookie header will be completely ignored!

Here is a sample on how to set the cookie, make sure the client browser gets the cookie, THEN redirect.

1
2
3
4
5
<cfset getPageContext().getOut().clearBuffer() />
<cfcookie name="testingCookies" value="#form.userName#" />
<cfflush />
 
<cflocation url="postLogin.cfm" />

Happy coding!

11

From Gregorian to Julian Dates in JavaScript

December 10, 2009

I am working on a contract right now where I am having to do some manipulation of dates in a calendar. This particular calendar stores dates in Julian Day Number (JDN) format. This by itself is not a serious issue as PHP has simple functions to handle these conversions. However I have a situation where I have a Gregorian date in the DOM, and I need to pass the Julian date to a JavaScript function.

After a bit of research, and a few algorithms online that didn’t do the trick, I used a formula from a site called Astronomy Answers that seems to have done the trick.

Below is a piece of code I have written to convert a Gregorian date to a Julian Day Number, as well as a sample of using it.

1
2
3
4
5
6
7
8
9
10
11
12
13
Date.prototype.ToJulian = function() {
	var d = this.getDate();
	var y = this.getFullYear();
	var m = this.getMonth() + 1;
 
	return Math.floor((1461 * (y + 4800 + (m - 14) / 12)) / 4 + (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + d - 32075);
};
 
var testDate = "12/9/2009";
var parsedDate = new Date(Date.parse(testDate));
var julianDate = parsedDate.ToJulian();
 
alert(julianDate);

Let me know if you run into any issues with this calculation, or find a better way to do it. Also let me know if you can get the reverse to work (going from Julian to Gregorian), as this is giving me some issues!

0