dans.blog


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

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…


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…


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…


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…


Free Windows MD5 Checksum Application

I downloaded the ColdFusion v7.0.2 Updater this morning. Since I've had some problems recently with downloading CF updates from Adobe.com, I decided I'd verify the MD5 checksum. This made me realize I didn't have a good Windows application for verify the MD5 checksum. After searching Google for a few minutes, I came across a very small (97k) application called MD Checker v2.20.

Using the program is very straightforward—just unzip to a directory and run the md5.exe executable. No installation required. To compare a checksum against a file's checksum, select the "Verify an MD5 checksum" (which is the default option.) Next, copy the MD5 checksum into your clipboard and click the "Paste" button—this will put the MD5 checksum value to verify against in an uneditable control. To verify the checksum of a file, click the "Browse" button and find the file on your hard drive and click the "Open" button. The application will then report the checksum found in either a green (if the values match) or red (if the values differ) box.

This program is very straightforward and best of all, it's free.


New and Improved--now built with LylaCaptcha!

In order to try and prevent the spamming issues, I finally had to do something I didn't want to do—and that's implement a Captcha process to the comments.

When you wish to post a comment, you'll now be required to fill in the text you see in the image right below the comment box. This is to help ensure that it's a real person entering in the comment and not just a spam bot. If this doesn't help with the problem, the next step will be either to require a valid e-mail (in which you'll have to go through a verify process the first time you post) or I'll start approving all comments manually. I really hope I don't have to turn off commenting altogether, but I'm tired of deleting 20-30 spam messages a day.

For those of you wondering, I used LylaCaptcha for my captcha needs, which worked on really well. I was going to type up a "how-to", as the documents on the LylaCaptcha site aren't as straightforward as they could be. Once you figure out what you need to do, it's very straightforward, but I found I had to really do a lot through trial an error. Anyway, the reason I'm not doing a write-up is Brian Rinaldi already wrote what I ended up doing in a blog post titled Adding Open-Source LylaCaptcha to BlogCFC.

more…


A ColdFusion UDF For Dynamically Loading Java Classes

UPDATE:
2007-09-21
I just noticed today that the createClass() function below was an old version of the actual code I'm using, so I've updated the code with the latest version.

I've been working on modifying some ColdFusion based web services for XStandard originally written by Ben Nadel. One of the things the original code didn't support was the Spell Checker support feature built-in to XStandard.

After doing some searching, it appeared the Jazzy Spell Checker Java API would fill my needs nicely. It's based on the algorithms in aspell and it can use both dictionary and phonetic files to help with spelling suggestions and it returns all the information required by XStandard (position of word and suggested spellings.) The only "disadvantage" of Jazzy is that it does come "ready-to-use" with CFMX—you need to write a wrapper class for easy use w/ColdFusion. (More on that to come in a later post.)

more…


MSSQL 2k Stored Procedure for Pagination...

A while back I found a stored procedure that someone was using to create pagination resultsets in SQL Server 2000. While the stored procedure was nice, it didn't allow for the "DISTINCT" keyword—which is necessary for some of my queries. There were also a few other issues I didn't like about the stored procedure, so I re-wrote the stored procedure pretty much from scratch.

In order to support the "DISTINCT" keyword, I had to change the inner query to use a derived table. Since this provides a little more overhead, I added a bit parameter "@Distinct" which inserts the "DISTINCT" keyword into the query and uses the derived table.

Also, on the initial page of results, I simply use the TOP keyword. The previous stored proc used an inner query, which did a TOP 0—which means the code did nothing.

more…


Protecting your HTML pages from Spam Harvester Bots

Today I was reading a post on a message list and someone mentioned they were using a function to generate their mailto: links using HTML entities instead of the ASCII characters in order to prevent spam harvesters from snagging the e-mail address. The problem with this method, is it would be pretty easy for a harvester to re-encode the HTML entities back into the correct ASCII characters.

This got me think that the best method would involve using JavaScript to write out the link. In order for a spam harvester bot to parse out the e-mail address, they'd have to understand the context of the page. This means they'd either have to actually parse the page into a DOM object and parse the DOM, or they'd have to specifically knowledge of the function and reverse engineer the links to the function. Either method is probably more than what most harvesting bots are going to use (although this could always change.)

So, I spent a few minutes and whipped up the following code. The spamProtector() JS function takes in an array of ASCII character codes, which will be used to generate the mailto: links. I obfuscated the document.write() statement by breaking the string into chunks in order to throw off any parsers looking for certain strings.

more…