March 18th, 2007 by Ryan Stille
I am currently working with a client that sends large amounts of mail using ColdFusion. They are having a few problems, and I am going to be doing some optimizations to improve their mail delivery. One of the things we are going to do involves monitoring the number of messages in the ColdFusion spooler directory that are waiting to be handed off to the SMTP server. This involves looking at the files in the ColdFusion spool directory. I did not want to hard code the path to the spool directory, because it may change between production and development machines, and the path may also change when ColdFusion is upgraded.
It is possible to find the spooler directory programatically. My first thought was to look in the adminapi. No luck there. But digging around in the ColdFusion ServiceFactory java class lead me to my answer:
<cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
<cfset MailSpoolService = sFactory.mailSpoolService>
<cfoutput>#MailSpoolService.getSettings().spooldir#</cfoutput>
Read the rest of this entry »
Posted in Web Development, ColdFusion | 3 Comments »
March 7th, 2007 by Ryan Stille
I recently wrote a routine to export a client’s newsletter subscribers as a CSV file. There are a little over 7000 records in the database now and that is expected to increase at a steady pace. I have been wanting a good reason to reach into Java and do some fancy string manipulation, as I’ve read it can be quite a bit faster than in native CFML. So this looked like a perfect chance to try it. Here’s my first take in plain old CF. I had some additional quote and comma checking in there but I’ve left it out for readability.
Read the rest of this entry »
Posted in Web Development, ColdFusion | 9 Comments »
March 4th, 2007 by Ryan Stille
This week I had a need to copy some data between SQL Server database tables. A client of ours has three tables containing users - subscribers, seminar users, and weekly report users. He wanted his subscribers and seminar users to be placed into the weekly report table, along with modifying the subscriber and seminar signups to also insert those users into the weekly report users table.
Copying data between tables in SQL is pretty straightforward:
INSERT INTO reportUsers (fname, lname, email)
SELECT fname, lname, email FROM seminarUsers
The problem with this is that some of the subscriber and seminar users already exist in the weekly report table. We can exclude them with a subquery:
INSERT INTO reportUsers (fname, lname, email)
SELECT fname, lname, email FROM seminarUsers
WHERE email NOT IN (select email FROM reportUsers)
But, the seminarUsers table contains signups for every seminar. That means a given user could have signed for several seminars, and would be imported into the reportUsers table more than once. To solve that we need to eliminate the duplicate records coming from the select statement. But for a given email address, which of the several record should we choose to import? On the second or third time the user signed up for a seminar, they may have given us an updated name or address. Only the name is relevant in this example, but in actuality I was copying more fields than just the first and last name. So lets grab the most recent signup. We can do that by just using the record with the highest userid, since it’s an identity field - the more recent records will have a higher user id number. Read the rest of this entry »
Posted in Web Development, SQL | 1 Comment »
February 24th, 2007 by Ryan Stille
Unless you’ve been living on a desert island for the last year, you’ve probably heard that you’ll need to upgrade ColdFusion’s JVM (java virtual machine) before March 11th 2007. Thats when daylight savings time takes effect this year. Since the dates have shifted in 2007, anything that is aware of daylight savings time will require an update. This includes your operating system (Windows, Linux, OSX, etc.), and Java since it has its own internal timezone tables.
And if you use NTP (network time protocol) to set the time on your servers from an internet time server, don’t think you’re immune. NTP simply syncs your internal UTC (universal time) clock with a UTC clock on the internet. Your timezone tables then determine your actual local time, based on your UTC offset, which changes during daylight savings time.
Updating ColdFusion’s JVM is very easy. The version of java that ColdFusion ships with is 1.4.2_09. You can see this if you login to your CF Administrator, then click on SYSTEM INFORMATION at the top of the page.

Read the rest of this entry »
Posted in Web Development, ColdFusion, System Administration, Linux | 27 Comments »
February 22nd, 2007 by Ryan Stille
I was working on converting an application from ColdFusion 5 to CFMX 7 last week, and ran into some problems converting cfgraph (CF5) to cfchart (CF7). The graphs that looked nice in 5 weren’t coming out so good in 7.
Original chart in CF5, using the CFGraph tag:

How the chart looks after converting to CFChart in CF7

Notice the problem with the y-axis labels.
Read the rest of this entry »
Posted in Web Development, ColdFusion | No Comments »
February 11th, 2007 by Ryan Stille
Usually to setup an SSL-enabled website (a website available via the secure, https protocol), you purchase a certificate from a trusted authority such as Verisign or Thawte. This costs anywhere from $150-400 per year. But this cost is not always necessary.
Read the rest of this entry »
Posted in Web Development, System Administration, Linux | 1 Comment »
February 8th, 2007 by Ryan Stille
Last weekend I wrote my first GreaseMonkey script. If you are unfamiliar with GreaseMonkey, its a FireFox extension that lets you run specific JavaScripts on specifc webpages. This is incredibly cool, you can basically bend websites to whatever you want. Everything from changing the look and feel to adding new functionality. GreaseMonkey puts you back in control of your browsing experience. A neat example is the GM script that, when you are browsing Amazon, will put a link to the book at your local library and indicate if its available there.
The GreaseMonkey script I wrote works with Craigslist.org. Craigslist is a popular free classifieds site. Craigslist’s posts are not moderated, so anyone can post an ad. That includes spammers. Craigslist spam is mostly controlled by craigslist users themselves. See an ad thats spam? Click the spam button. If enough people mark it as such, it automatically gets taken down. I really like CL, so I do my part by flagging any spam I see. To do this you must click on the item title from the list, then click the spam button on the detailed listing. But I can often identify spam just from the title. Posts like “FREE 4gb ipod nano!!” and “Take Your New Pair of Uggs!” are obvious spam.
Read the rest of this entry »
Posted in Web Development, AJAX / JavaScript | 25 Comments »
February 4th, 2007 by Ryan Stille
On pages that take more than a few seconds to complete, its a good idea to show some type of in-progress meter. Things like bulk email processing and large file uploads are good candidates. Often this doesn’t need to be as complicated as a real progress meter, where you show the actual percentage complete. Instead, an “in progress” meter just gives feedback to the user to let them know that something is going on.
Read the rest of this entry »
Posted in Web Development, AJAX / JavaScript | 10 Comments »
January 30th, 2007 by Ryan Stille
Here’s a small snippet to help prevent users from clicking the submit button more than once. When this happens you can end up with duplicate data, or even multiple charges on the user’s credit card. This trick uses JavaScript, and degrades nicely if JS is turned off.
<input type="submit" value="Place Order"
onclick="if (this.value == 'Place Order') { this.value = 'Please Wait...'; return true;} else return false;">
On some applications it is also a good idea to redirect the user to a success page, instead of just displaying a success message. That way they can’t accidentially refresh their browser and POST the form again. This is complicated if you’re displaying a receipt or similar, where you need the data from the form post to create the success message. You could stuff those values in the session in that case.
Posted in Web Development, AJAX / JavaScript | 1 Comment »
January 26th, 2007 by Ryan Stille
One thing I often notice about novice developer’s web forms is that they usually contain a RESET button. You know, <input type="reset">. I think this is because a lot of books that talk about creating forms always use them in their examples.
But who really uses a reset button? Have you ever filled out a form, then realized you made a typo in your phone number? Did you correct your typo or did you think “gee, I’ll just use this reset button to clear the whole form, then I’ll put in the right phone number!”
I’m sure somewhere there is a legitimate use of a reset button. Maybe to reset a form that was pre-filled back to its original values. But 99% of the time they are not needed. Take a look at the forms on any well designed site, you won’t find any reset buttons. Not on Google, Yahoo, Microsoft, A List Apart, etc.
And its not just that they’re not needed, they are actually detrimental. Having two buttons at the bottom of a form clutters the interface and makes it harder for the user to clearly see the path to the next step. Trust me, I’m not the only person who has filled out a lengthy signup form, only to be too quick on the mouse (or tab key) when clicking the ‘obvious’ submit button on the bottom of the form. Only its not the submit button, its the reset button. And unfortunately there is no undo for that action.
So please, no more reset buttons!
Posted in Web Development | 2 Comments »