programming

SQL: Totaling A Column Containing Varying Values

I have been doing quite a few surveys recently and one of the tasks involved is mining the responses for data. Here's a neat trick I learned for totalling and counting responses using sql rather than programmatically on the front end.

Let's say you have a table of customers (tblCustomers) that houses the name of each person and the flavor of ice cream each customer prefers:

Detecting A Secure Server Using ColdFusion

I needed a quick tag to detect if the page the tag resided in was called using a secure URL. Unfortunately, the CGI function was not easily found, so here it is.

<cfif CGI.HTTPS EQ "off">

<cfset NewLink = "https://" & #CGI.HTTP_HOST# & #CGI.PATH_INFO#>

<cfif #CGI.QUERY_STRING# NEQ "">
<cfset NewLink = NewLink & "?" & #CGI.QUERY_STRING#>
</cfif>

</cfif>

Spell Check In SQL

I was tasked yesterday with writing a spell checker for an up-and-coming application. I completed the meat of the functionality today, done in sql. It's actually very acurate, pulling most words within the first 15 suggestions, but many within the first 5. It uses a table comprised of 62,070 words (a dictionary I imported from a flat file word list), which speaks to the procedure's accuracy as there are many names, cities, acronyms, etc., with the corresponding soundex values.

Some IP Parsing Fun Using ColdFusion

I know some of you have been dying for code (yeah, right) so here's a small function I made for parsing an IP address. I needed the last byte to determine if the machine calling the page was a developer's machine or not.

<cfoutput>
<cfset BegPos = 1>
<cfset EndPos = 1>
<cfset ip = #CGI.REMOTE_ADDR#>
<cfset ByteArray = ArrayNew(1)>

<cfloop index="i" from="1" to="4">
<cfset EndPos = #FIND(".", ip, BegPos)#>
<cfif EndPos GT 0>
<cfset ByteArray[i] =