ColdFusion Singletons
Singletons are perhaps one of the most simple Design Patterns. For those who don't know sigletons are a class that can only have one instance. They can be thought of as a glorified global variable - but are a lot more useful.
Most ColdFusion classes, or rather instances of CF components, can be turned in a singleton by placing the following code in your Application.cfm:
2 <cfset application.<instance name> = createobject("component",<path to component>)>
3 </cfif>
or OnApplicationStart method of your Application.cfc:
ColdFusion hCard Microformats Custom Tag
I a huge fan of of microformats (or µF), if you're not familiar with them take a look at www.microformats.org and the entry at Wikipedia.
Basically it's a way of marking up HTML to give it more more meaning, think of it as the semantic web (with a small s) that is available now.
hCard is a HTML representation of vCard and while no browers currently support it natively, the next versions of Firefox and IE will support it. There are also plugins currently available for Firefox (Operator and Tails ) and Safari (various bookmarklets) and IE (various favlets).
ColdFusion Securely Storing Passwords
Consider the following code that implements a simple login.
2select * from users
3where name = '#form.login#' and password = '#form.password#'
4</cfquery>
5
6// if login failed go back to login page
7<cfif user.recordcount is 0>
8 <cflocation url="login.cfm">
9</cfif>
One of the issues with this is that the password is stored in the database as plain text. Anything with access to the database (including your ColdFusion application) could possibly be used to get a list of all users and their passwords.
ColdFusion Simple Friendly URLs
There quite a few methods out there for making search engine and user friendly URLs in ColdFusion eg Spike's Friendly URL servlet or one of the many Apache and IIS URL rewiters.
These are great if your hosting provider has installed them or if you have your own dedicated server. So what do you do if this is not the case or you want to support friendly URLs in a web server agnostic way?