Viewing By Category : Coldfusion / Main
March 1, 2008
AspectCrop added to imageUtils
I'm a little late posting this. Ben and Ray added AspectCrop to imageUtils yesterday. If you've ever needed to resize and crop images to specific dimensions then this one is for you. Go check out the example. Then download it and make that ultimate photo gallery app you're always talking about.



July 3, 2006
Hangovers and Persistance
I've been meaning to comment on my thoughts about CF United this year. Although I havent had time to put my kudos and critisisms in a coherent post I do need to say hey and give thanks to everyone who made my stay so damn fun.

In no particular order...
Cutter
Aaron West
Mark Drew
Ray Camden
Kola Oyedeji

Honorable mention goes out to Josh Adams for the entertainment at Houstons and almost taking us seriously about picking up the tab.

There was also Friday nights dinner at the hibatchi grill. I was almost as entertained by the 13 of us as I was watching the waiter deal with 13 seperate checks. Thanks for the invite Ray. I didnt think we were gonna get out of there alive. Other than Ray who I allready knew, I only caught Scott Stroz's name. If you were there, drop me a comment. I'd love to put some names to the faces.

Sorry if I forgot anyone but my recollection is a little blurry still.

June 6, 2005
Scrobble Scrobble
I had to take down the the Audio Scrobbler pod after discovering the site was on error all nite. Since I rarely miss a day of playing music I didnt take into account what would happen when the xml feed is empty. Woops. Code has been updated. Pod is back.

I've also noticed audioscrobbler can be pretty damn slow sometimes. If you dont want your site affected by the response of their site, you might want to just schedule it to run every 5 minutes.

June 4, 2005
CF_AudioScrobbler
I added caching to the Audio Scrobbler RSS parser thingy. I posted it for download on the right. It's now officially called CF_AudioScrobbler.

Let me know if you have any suggestions or improvements.

June 3, 2005
XMLParse is not Da BOM!
The other day I mentioned our hiring dilemma and gave an example of a simple solution to a simple problem. It was easy, but I guarantee a few of you wouldn't have come up with it on the first try. When it comes to coding, sometimes our brains try to take the path of most resistance. At least mine does. A perfect example is a problem I had today with parsing an XML document.

I like to play Halo2. Nothing caps off a stressful day like senseless violence. Usually after a night of killing I go to Bungie's site and check out my stats. The first time I went there I immediately noticed the RSS link. Sure enough, my stats were there for the taking. The idea of writing a statistics app was born. Today I finally got a chance to start writing the app. As I typed the first line of code I was already thinking ahead. I could finally back up all my shit talking with colorful graphs and pie charts. I quickly grabbed the feed with cfhhtp and sent it through coldfusions xmlparse function and...

Error Occurred While Processing Request
Document root element is missing.

I looked at the XML for any indication of why it wouldn't parse. I ran it through some XML validators and compared it to other documents I had parsed in the past. Everything looked fine. I was stumped. Then it came to me. Instead of looking for something I could see, I started looking for something I couldn't. It was time to break out the HEX editor. Sure enough, a byte order mark (BOM) was sitting in front of the XML declaration. In UTF-8 it would be EF BB BF. Technically, a BOM can exist in any UTF-8 document so I found it surprising the CF's built in parser would choke on it. I spent the next several minutes trying to figure out how to strip the BOM out with CF. If I could just convert it to HEX i could do a find replace on the BOM then convert it back to a string. The entire time I'm thinking of how to do this I'm talking to my programmer friend ritchie. Suddenly he suggests I just find a starting point and strip everything away before that. DOH! I just failed my own test from a few days previous. I ended up stripping away everything before the root element including the XML declaration and voila!... there was my array.

So the final code looked something like this. So simple I couldnt see it.

<cfhttp url="http://www.bungie.net/stats/halo2rss.ashx?i=697888&k=30743151" method="get" resolveurl="No"></cfhttp>
<cfset begin = Find("<rss version=""2.0"">",CFHTTP.FileContent)>
<cfscript>
begin = begin -1;
xml = RemoveChars(CFHTTP.FileContent,1,begin);
xml = XMLParse(xml);
</cfscript>
<cfdump var="#xml#">

You and I are just the same. Unless you listen to MTV that is.
Miles Rast over at the Rasteroids turned me on to Audio Scrobbler last night. Apparently everyone and their grandmother has known about this site for a while. Drats! I hate not being the first on the scene.

The playlist tracking is cool but the part that interested me the most was what other people that shared the same taste in music listen to. They pretty much define your musical tastes within 20 individual tracks or so. In the blink of an eye my individuality was thrown in the pen with the rest of cattle. MOOOO!

Like all good geeks I quickly noticed the RSS feed at the bottom. A quick click of the keys and I had myself a playlist pod. Bottom right if your curious.

Here's the code. Come join the herd.

<cfhttp url="http://ws.audioscrobbler.com/rdf/history/renhack" method="get"></cfhttp>
<CFSet xml=CFHTTP.FileContent>
<CFSet xmlDoc = XMLParse(xml)>
<cfset song=xmlDoc.rdf.item>
<cfloop from="1" to="#ArrayLen(song)#" index="i">
<cfoutput>
<strong>#ListFirst(song[i].description.XmlText, "-")#</strong> - #ListLast(song[i].description.XmlText, "-")#<br>
</cfoutput>
</cfloop>

May 31, 2005
Were Hiring! if only we could...
The company I work for is currently hiring an inhouse developer. We've been under a heavy load for quite a while now and there appears to be no end in site. In most areas of the country you'd have pleny of talent out there to choose from. Unfortunately we're located in a tourist town and most of the population is transient seasonal workers looking to earn some tips and get drunked up.

My initial hope was to find an intermediate CF'er with a working knowledge of photoshop. No takers. Next I decided to settle for a beginner cf'er whos heard of photoshop. No takers. Now I'm stuck looking for the first person who can write a table in notepad without using FrontPage. Guess what? NO TAKERS!

While still in the hopes of finding an entry level CF'er I did settle on a simple test of logic. Maybe someday we'll find someone who can answer it.

The question was this...

Display the alphabet with each letter linking to an anchor of the same letter in three lines of code or less.

The answer...

<cfloop index = "i" from = "97" to = "122" step = "1">
<cfoutput><a href="###chr(i)#">#chr(i)#</a></cfoutput>
</cfloop>