dans.blog


The miscellaneous ramblings and thoughts of Dan G. Switzer, II

CFMX UDF: Parsing a URI into a struct...

Ever needed to parse a qualified URI to examine a URL for specific information? I'm working on some code that needs to examine links in a document and extract information about the links.

To make sure I was doing things by the spec, I made sure to check out RFC2396. Fortunately, the RFC has a nice little regular expression for breaking a URI into it's core pieces: scheme, authority, path, query and fragment.

However, those core portions are still pretty broad. The authority can include user info, domain and port information. The path can include embedded parameters inside each segment. So, I took the core regular expression to break up a URI and then I do further parsing on the authority and path portions of the URI.

more…


Fiddler Issue: Slow running HTTP requests on local IPs (i.e. 192.168.1.*)

For those of you using Fiddler HTTP Debugger (which is a great tool I've blogged about many times in the past,) there appears to be an issue when using IP addresses. This is especially noticable when using private subnet IP addresses (such as 192.168.1.*.)

The problem I was seeing was that requests to my developer server came to a crawl when using Fiddler. Speed to external domains was working fine. If I turned off capturing, speed resumed. I finally was able to figure out that by setting up a DNS entry, speed would resume.

Since this was slowing me down, I sent Eric Law, the developer of Fiddler, an e-mail message reporting the problem. He was very quick in researching the problem.

more…


CF TIP: Determing if a UDF argument is "null"

Ok, so the title is misleading. CF doesn't really have a concept of null, but it does have the concept of "not exists."

If you need to differentiate between when an argument of a function has been supplied or not, set the required attribute to true and leave the default attribute off. If the argument is not supplied to the function, then a against structKeyExists(arguments, "argumentName") will return false. If a value has been supplied, the function will return true.

Here's an example:

more…


CFMX UDF: Creating a query from a zip file

The other day I had the need to unzip the contents of a zip file. However, I did not want to unzip the file to disk, I really wanted to grab the binary data in memory so I could write it to MS SQL as an image data type.

As I normally do, I first did a quick Google and CFLib.org search to see if I could find anything that did exactly what I wanted. The only examples I could find were of writing the zip contents to disk. While I could have written to disk and then read the file from disk, I know I could do what I wanted by just creating a ByteArrayOutputStream. So I took the unzipFile UDF I found (written by Samuel Neff) and basically re-wrote it.

I decided I actually wanted to return a complete query object of all the zip file information. I thought this would be useful for other projects (in case I ever need to "browse" a zip file.)

more…


Saw Jeff Scott Soto fronting Journey...

Well, Sunday night I went to see Journey and Def Leppard with Jenn and a group of friends (Todd, Monica, Eric, Krista and some neighbors of Todd & Monica.) Jeff Scott Soto was singing for Journey in replacement for Steve Augeri (the current lead singer), as Steve is suffering from a throat infection. If you've never heard Augeri sing, if you close your eyes, you would indeed think it was Steve Perry singing. Augeri was an excellent choice to take over the reigns.

Anyway, I was pretty excited to hear Soto sing for Journey. I've been a fan of Soto's since his early work with Yngwie Malmsteen (I love his vocals on I'll See The Light Tonight.) Overall Jeff did an excellent job, but they definitely seem to alter the set to match his vocals. My only disappointment was that he didn't even try to sing any of the songs Steve Perry sang in falsetto (Open Arms, Faithfully, Who's Crying Now.) Those were the songs that I thought might bring Jeff some trouble, but I wanted to hear him sing them, as I've never really heard Jeff attempt to sing anything in that style (not saying he hasn't done it, I've just never heard it if he has.)

To my surprise Deen Castronovo (the drummer) sang those three songs. While he doesn't have the impact of either Steve (but who really does,) I was really shocked out how well he sang those songs. I never had any idea Deen had those kind of pipes. I've always considered him a kick ass drummer, just never knew he could sing like that.

more…


CFTHREAD/CFJOIN POC released!

Damon Cooper has blog Rupesh Kumar's latest CFTHREAD Proof of Concept (POC).

Rupesh is an Adobe "scientist" (a cool word for CF Developer Engineer.) He was very active in listening to feedback from the original version of the code that was released. I, along with a few other developers, were in active discussions with him over issues with the first release. Thanks to Rupesh's hard work, he's addressed the issues that were discussed.

The biggest changes are the addition of being able to pass attributes to the CFTHREAD tag (which allows you to pass in variables who's values can't change,) threads having their own unique scope (so that variables outside the thread aren't negative affective,) and the addition of the thread.OUTPUT and thread.ERROR variables.

more…


September 11, 2006

Just wanted to give my condolences and well wishes to all those Americans who lost their lives on 9-11, to all the heroes that contributed to the rescue and safe evacuation of thousands of people from the World Trade Center, to those that were in the Pentagon and finally all the brave passengers of United flight 93—who after knowing the events that happened in New York and DC, made the decision to take down their own plane, instead of letting the terriorist cause more damage.


ColdFusion TechNote: Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server

Adobe has released a new TechNote regarding Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server. This is probably a good document to have handy whenever you set up a clean install of ColdFusion. Hopefully they'll continue to modify this document as patches/upgrades are released.


Calculating the visual length of a string

Sorry I haven't blogged in a while, but I've been very busy working on a project. Part of the project requires that I convert HTML to formatted plain text. On the very surface, this may seem simple (just use a RegEx to remove the HTML,) but the key word in that first sentence was "formatted."

One of the many issues I've run into, is that none of the built-in ColdFusion string manipulation functions account for the "visual" length of a string. Since one of the things I needed to do was wrap text after XX number of visual characters; I needed a function that, unlike the standard len() function, would return the length of a string as it would appear on the screen. This means I have to take into account how many "spaces" a tab would occupy on the screen.

My first attempt was simply to count every tab character (chr(9)) as 8 spaces. While this number assured I would never go past the right edge of the content, it wasn't very accurate (as a tab can very between 1 space to 8 spaces in Windows.) I quickly started running into problems when I realized that for some functionality (like centering text,) I'd really need an accurate account of the total number of visual spaces a string was occupying.

more…


Using CF to automatically pass form fields from page to page

I'm working on a project that requires state to be passed via form fields (i.e. a multi-step wizard.) This means that I end up needing to pass hidden form fields from page to page. This normally requires a funky series of if/elses to determine which values to include on each form. Also, as things change from one form to another, you'd need to update each page in the process to include the hidden form field required, otherwise the value gets lost.

Anyway, I started thinking it would be nice if I didn't have to write any if/else statements and just have the necessary fields required automatically passed. Well, if you're thinking "Why not just loop over the form scope?" Well, that's only part of the solution. You really need to exclude fields that are already on the page.

Fortunately, several years ago I had written some code that was part of a much bigger project, that could parse a string and find form fields and extra information about about the fields. Harvesting the code I had already written, I was able to whip out a tag that would parse the content between the start/end tags, look for any form fields in the content and exclude those fields from being copied as hidden form fields.

more…


My Golf Game is the Model of Consistency...

Well, I played golf at Chapel Hill Golf Course on Sunday. It's a couse up near Mount Vernon, OH. It was my first time playing the course, so I wasn't sure what to expect. The golf carts were very nice—complete with digital scorecards & GPS. The GPS was definitely handy for a new course—since you always new the yardage to the pin. Using a cart on this course is almost a must, as the course is on very hilly terrain.

Anyway, I played the front nine pretty poorly, or more so I should say I played 3 holes on the front poorly. I played 3 holes on the front, +10 over par. However, this was mainly due to hitting some balls out of bounds and losing a ball or two to the course. Those penalty strokes add up quickly. I ended up +15 over on the front nine.

My game's been all over the place this year. A month or so ago I was playing extremely well. Most of my game was in sync and I was playing the best golf I've played in years. Then all of the sudden everything went down the tubes. In just nine holes, every aspect of my game went in the toliet. I went from doing everything well, to pretty much doing nothing well. I've been struggling to find my swing again for the past 3 weeks or so.

more…


Chimpanzee Plays Ms. Pac-Man

I came across this video this morning and it's pretty interesting. The chimpanzee appears to have enough motorskills to get the basics down. His/her reaction seems a little slow, but it does appear that the chimp has the basic fundementals down. I found this fascinating at least.

Chimpanzee Plays Ms. Pac-Man


Implement Gmail-like Spell Checking w/GoogieSpell and ColdFusion

GoogieSpell is a cool little Gmail-like spell checker for use in your own web-based applications. They include several server-side scripts that you can use to connect to Google's Spell Checking Web Service. Unfortunately, ColdFusion isn't one scripts they provide.

However, Robert (over at RedBalloon Labs) has written an article on how to use the GoogieSpell API within your ColdFusion applications.


Fix Firefox "Unresponsive Script" warnings...

I've run into this problem from time-to-time. I think the main time I run into the problem is when uploading files to a server, where the form submit is triggered by JavaScript—although I haven't dug around enough to confirm if this is the case or not. Anyway, here's a way to increase the default timeout.

The dom.max_script_run_time is an integer that is the number of seconds to wait before prompting that a script is taking too long to respond. I found this information over at Itchy Hands.

Ever since I upgraded to Firefox 1.5, I’ve been getting some unresponsive script warnings on sites that employ heavy Javascript like Gmail or Bloglines. Curious about it, I dug around and managed to find out how to fix the problem.

Firefox unresponsive script dialog

To fix it, you’ll need to access the hidden configuration page in Firefox. Just type about:config in the address bar and you’ll get a page full of hidden configurations which you can tweak till your heart’s delight.

In the 'Filter' box, type dom.max_script_run_time. This will narrow the options till only the dom.max_script_run_time option remains. Right-click it and choose Modify. A box pops up. Change the number to something bigger like 20. This is the maximum time a script can run before Firefox considers it 'unresponsive'.

If you can’t find the string in the about:config page, create it by right-clicking anywhere and then choose New—> Integer and enter dom.max_script_run_time. When prompted for the value, use 20.

So far I’ve not had anymore unresponsive script warnings, so I guessed that fixed that problem! However some extensions may also cause similar problems. Hope this helps.


When Firefox is not behaving correctly, use safe mode...

At work, I had a client who was having problems with our website crashing Firefox. Suspecting a problem with an extension, the first step I had the person do was to disable all their plug-ins—thinking that would be enough to determine if an extension was causing the problem. While, I learned the hard way that just disabling an extension won't necessary make Firefox behave like the extension isn't installed.

After some basic troubleshooting, I discovered the browser would crash any time a window.close() method was called (self.close() caused the same behavior.) Once again, I really suspected this had to be an extension issue. This time I had the client start Firefox in "safe mode". Sure enough, everything began working as expected.

I knew the client was using an extension called "Tabbrowser Extensions 2.1.2006031301". My original gut instinct was it was this extension that was causing the crashing. However, like I stated, I assumed just disabling the extension would get rid of any side effects it might be introducing. This was wrong. I think the reason why disabling this extension didn't avoid the problem, was because the extension loads a preference file that overwrites normal Firefox configuration options and that simply disabling the extension doesn't prevent the preference file from being loaded. After uninstalling the extension, their browser started working correctly.

more…