Viewing By Category : ColdFusion / Main
May 29, 2007

Moving On

As you can see, there's not much activity here anymore.

You can find more of Nat's wisdom at webapper.

Erik is now blogging at psykel.

Happy Trails, grumps

May 25, 2006

Nested Query Loops - Worst code ever

I had no idea how bad nested query loops are. But oh man, they are BAD.

I came across this "technique" this week when a very busy site started resonding extremely slowly - like 30 seconds per request, sometimes more. I didn't write the code, but I "got" to fix it.

Check this out, if you have a strong stomach:

[More]


SeeFusion really saved our asses

This past Sunday, the 21st of May '06, DNS transferred over to our servers for a big client site we rebuilt. Monday was sketchy with uptime declining, our server monitors beeping pretty much all day and us pulling our hair out trying to figure out the problem. Since then, we've been locked in a fight-to-the-death for the last few days with our monster server.

[More]

May 22, 2006

Keep it scalable, kids

We had a lot of trouble today with some really bad code that looked to be written about 10 years ago.

It was simply horrible. Nested loops, tons of CFIFs, you name it. Opening and editing this one CF file felt kinda like fixing a leaky pipe in my crawlspace. Dusty air, spiders all over the place, dark, no room to move...yuck.

Anyway this one page suddenly became very popular, and was definately NOT scalable. I rewrote it so the server would stop crashing (!) and it is now seriously about 100 times faster than before.

If, by chance, you are a person looking for web development services, be sure to get someone who knows what they're doing.

If, by chance, you are a developer, make your code scalable. Most of you know this, but I'll say it anyway -- Just because your code runs well on your dev box, it doesn't mean it will perform the same way when it's hit by 50 concurrent users. And if you have to write nasty slow code, at least cache it.

Thanks, I'm going to bed now.

March 21, 2006

International Characters

Every now and then you get a little job that seems simple and straight forward, but is anything but. I just encountered one of those.

I recently inherited an old CF application, written in CF 4.5 or 5.0.

The cfml templates have Japanese characters simply pasted in the file, with a meta tag in the HEAD section of the HTML that sets the character set to x-sjis (shift japanese).

[More]

March 17, 2006

SES can cause trouble if you're not careful

So I recently deployed some SES URL code to a big site we did. One thing I forgot to do was adjust a layout file that is used by sort of sister site - same content, different layouts.

Anyway, I did not add the BASE HREF tag to this layout file. The layout file uses about 50 images or so, all called via a virtual directory.

<img src="myDir/whatever.gif">

Since I forgot to add a BASE HREF, each image call was preceded with the entire SES url:

So each image request actually called a page of the site! Worse yet, the code took MYDIR as a url parameter, which caused the code to throw an error (an unexpected value).

So each page request was throwing about 50 or so errors, each of which resulted in a robust error report sent to my inbox. I'm still getting email messages 30 minutes later. Ugh.


SES lives on

I've done a lot of work with SES, (Search Engine Safe) URLS in the past. I new project has recently required I use them again.

This client knows a lot about Google placement so it's quite interesting. We'll see how they work.

Changes will probably be made to the red viper systems and green viper systems websites based on the lessons learned here.

See here for our sesConverter stuff, or see it in action.


base href breaks javascript form submit

I placed a BASE HREF tag in my application the other day. To my dismay, it somehow screwed up all of my links that submit a form. For example:

<a href="#" onclick="document.theForm.submit();">

I still am not sure what the issue is. I worked around it fairly easily so I guess I'll put off investigation for when I have the time.

But it's a very irritating little problem that took a while to diagnose.

March 8, 2006

RegEx Backreferences

Backreferences are cool, but I've never needed to use them before.

I just ran into something where they were quite handy.

I had to manipulate a string like the following:

TNF S/S VENT POLY SHIRT W

The end goal was to see if the string had either a S/S or L/S in it, along with SHIRT. If both substrings were found, remove SHIRT and move the S/S or L/S to the end of the string.

It's not hard, but a one liner kind of is. Backreferences really helped out here.

[More]


CF Loop Bug

I've seen this numerous times throughout the years but I've never actually written it down.

When you do a CFLOOP within a query loop, odd things occasionally happen.

For example:

<cfoutput query="getWidgets">
<select name="whatever">
<cfloop query="getThings">
      <option value="#getThings.ID#" <cfif getThingsID EQ getWidgets.ThingID>selected </cfif>>#getThings.Name#</option>
</cfloop>
</select>
</cfoutput>

The value for getWidgets.ThingID will be lost!

So you have to patch it up like so:

<cfoutput query="getWidgets">
<select name="whatever">

<!--- This line will fix the problem --->
<cfset foo = getWidgets.thingID>

<cfloop query="getThings">
      <option value="#getThings.ID#" <cfif getThingsID EQ foo>selected </cfif>>#getThings.Name#</option>
</cfloop>
</select>
</cfoutput>

This happens in pretty much all versions of CF I've tested on, including v7.

I don't think this happens EVERY time, just in certain situations. Irritating? Hell yeah.

More Entries