dans.blog


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

License Free Photo Resource - everystockphoto

I think I've seen this link before, but there's a great site for license free images called everystockphoto. They currently have over 268,000 free images for download. Definitely worth checking out if you're doing a project on the cheap and need some images to use.

On a related note, iStockphoto is site were you can get very inexpensive photos (from $1 to $5 per image, based on the resolution you want.) The great thing about this site is if you're a photographer, you can sell your pictures on this site. A acquaintance of mine, Todd Smith of SaturatedPixels has been selling his works there for a couple of years. Check out his iStockphoto portfolio.


ICU4J's TimeZone Ids Mapped To Windows Timezones

Ok, I've been working on trying to optimize some code recently. One of the huge bottlenecks in the application is the conversion of date/times to local user times. All date/times are stored in GMT in the database and are converted to user local when displayed.

We've been using a database table to do lookups/conversions of the date/times to make sure they display correctly depending on the user's region and whether or not they are in a daylight savings time. We're using custom data tables—which we have to maintain—not to mention it runs pretty slow on large recordsets.

In order to speed things up, I've been looking at using IBM's ICU4J's TimeZone class. Paul Hastings has written some nice little ColdFusion wrapper CFCs for this class. So far in my testing, under load the Java class performs about 10x more efficient that the db lookup code.

more…


CFHTTP "Connection Failures" issues with Gzip

I've been playing around with Port80's Gzip compression filter, httpZip, on my development server and realized I was having a problems with CFHTTP calls. A quick search on Google pulled up a blog post by Steven Erat titled Workaround for CFHTTP and Compressed HTTP Response from IIS.

My problem differed slightly in that the very first request to a URL (via a CFHTTP request) works fine, but subsequent hits return a "Connection Failure" error. Unfortunately Steven's suggestion didn't work for me, but after some playing around with syntax I was able to come up with some solutions that do work:

  1. When configuring httpZip, set up all compressed mime types to exclude anything with the header "ColdFusion" and "CFSCHEDULE". This will fix the issue with any default CFHTTP calls (Schedule Tasks, CFCACHE, or CFHTTP calls where no "user agent" is specified) If you're manually setting the "user agent" in the CFHTTP call, see one of the following solutions.
  2. NOTE:
    After some more testing, it appears CFMX 7 reports the user agent string of "CFSCHEDULE" and not "ColdFusion". This means you should also add the "CFSCHEDULE" string along with the string "ColdFusion" to your MIME type exceptions list.
  3. Pass in a <cfhttpparam type="header" name="Accept-Encoding" value="*" />. For some reason Steve's suggestion did not work for my setup, but passing in the asterisks value did work. Including this header information prevented me from getting the "Connection Failure" message again.
  4. The last method is to add custom header to the page serving up content, which tells the httpZip ISAPI filter to ignore compressing the request: <cfheader name="httpZip" value="no-compression" />. You could use this technique and have all your CFML pages look for the custom header labelled "Gzip-Disabled". If the custom header exists and is set to "true", you then could execute the CFHEADER tag to tell the ISAPI filter not to compress the page. This would give you the ability to dynamic control the compression of httpZip from within your code.
  5. NOTE:
    You could pass in the httpZip to your initial call and just pass that value back to the CFHEADER output stream, but that opens your page up to be controlled from an outside source. I prefer to just allow the compression to be enabled or disabled on request.


The future is here: Web 2.1

There's a new Web in town—Web v2.1! A new article over at Something Awful gives a humorous, yet insightful, look at the buzz phrase "Web 2.0".

Web 2.1 is the new standard for web sites and applications in the blogosphere collective information age. It is scaleable and easy to use, as well as being user friendly and designed with the end user in mind. In order to be Web 2.1 compliant, you must follow these guidelines:

  • If it comes to a rest on the floor for less than five seconds, you can eat it
  • No means no
  • Don't expose it to bright lights, get it wet, or feed it after midnight
  • Data is the next Intel Inside
  • If the kick returner signals for a fair catch but drops the ball, the other team can attempt to recover it


Yahoo! releases new User Interface Library JavaScript APIs

Yahoo has released a pretty impressive collection of JavaScript libraries on their Developer Network. The new libraries are collection they're calling Yahoo! User Interface Library. The new UI library consists of about everything you need to build modern web applications—AJAX (Connection Manager), animation effects, drag-n-drop effects, event handlers and basic DOM umbrella for miscellaneous DHTML handling.

They've even released a few nifty UI controls (widgets) that seem pretty feature rich. These include a Calendar, Slider and a TreeView control. The slider control seems very solid and I like the "task" mode of the TreeView control (it allows you to place checkmarks next to the tree items—which would be useful in removing nodes from a tree.)

I'd also recommend checking out the new Yahoo! User Interface Blog, which is designed to talk about changes and additions to the UI Library. They've also published a Design Pattern Library which talks about common design problems and provides some solutions. They Design Pattern Library has an interesting entry on "Auto Complete", but they have not yet posted any actual code.

more…


SeeFusion Trace Tag

I was needing to do some debugging on a live server today. I had some code that was not performing the way it should have been, so I want to use SeeFusion's trace() method to dump out some information to the debug log so I could find out exactly what line was causing the problem.

Anyway, instead of invoking a reference to the SeeFusion Java object, and manually putting in trace() methods, I thought I'd write up a little CF tag that would manage the creation of the object in the Request scope and dump out the trace methods for me, as I felt this would speed up being able to quickly insert a SeeFusion trace.

There's nothing fancy going on here, but I thought I'd just share the tag in case it saves anyone some time. I'd recommend saving this file as "seefusion.cfm" in your default ColdFusion Custom Tag directory. That will make it available to any template without having to worry about any mappings.

more…


Process Explorer saves me from IBM DLA hell

I've been having a lot of weird performance issues lately. For some reason today my CPU was just getting maxed out within minutes of booting. My first thought was a virus or spyware, but after some digging around with the excellent application Process Explorer, I was able to find a thread in the system process that was eating all my CPU cycles. It was a DLL named "ssrtln.sys".

Troubleshooting this was a real pain. This DLL was eating so many CPU cycles, that it was actually preventing many applications from even loading (including Internet Explorer, the Control Panel and Windows Explorer.) Turns out this DLL belongs to the Sonic Solutions, which was part of the IBM DLA drivers which were loaded on my IBM ThinkPad R50p.

Since the driver is not loaded in Safe Mode, I tried booting to Safe Mode to remove the driver. Turns out, you can't uninstall this particular piece of software in Safe Mode.

more…


Disabling Windows' native Zip folder support

Tonight I finally got sick of Windows XP's native support for Zip files in Windows Explorer. It really slows down Explorer and I really have never even liked the fact that it treats Zip files as folders. I want compressed archives to be what they are—files. If I want to view the contents of compressed archives, I'll use an archive applications like WinRAR.

To prevent Windows XP from treating compressed Zip files as a folder, go to "Start > Run" and type the following:

regsvr32 /u zipfldr

If you wish to restore native Zip support in Windows, just go back to "Start > Run" and type the following:

regsvr32 zipfldr


Raymond Camden's "Variable Scopes in CFCs"

Raymond Camden has posted a really excellent article covering variables in CFCs. It does a very good job of simplifying how the different ColdFusion scopes work in a CFC. If you're new to CFCs or just not sure if you're using CFCs correctly, it's definitely worth a read.


Viewing active "sessions" in ColdFusion

Ever need a snippet to read in the active sessions running on your server? This code was recently posted to the CF-Talk list and I thought it was worth blogging for future reference. (Thanks to Raymond Camden and Dave Carabetta for the information.)

function getSessions(appName) {
    var tracker = createObject("java", "coldfusion.runtime.SessionTracker");
    return tracker.getSessionCollection(appName);
}

variables.numSessions = 0;
variables.sessions = getSessions(application.applicationName);
variables.numSessions = structCount(variables.sessions);

<cfoutput>Total Number of Sessions: #variables.numSessions#</cfoutput>
NOTE:
This code relies on using internal undocumented ColdFusion factories. This means the code could potentially stop working if Adobe ever changes the internal factories.

more…


Retrieving the wdith/height of a SWF file from ColdFusion

Doug Hughes has been kind enough to share the code he wrote to get the dimensions of a Flash (swf) file using ColdFusion. This could prove to be very handy to anyone running a CF-based CMS or if you're serving up random Flash files.


A "safe" way to compress your JavaScript code...

If you ever do any heavy JavaScript development, you know how large cross browser libraries. The file sizes of these libraries get very large, very quickly. Usually JavaScript files contain a lot of whitespacing and (hopefully) commenting, which can drastically increase the file size—which means for longer download times.

There are many solutions to this problem, but most involve the basic idea of stripping out commenting and taking out the unneccesary whitespacing. While these simple steps can reduce you files nicely, there are better ways.

Alex Russell, the project lead for the Dojo JavaScript Toolkit, has written an open source compression tool called SourceSafe. SourceSafe is based on Rhino, the JavaScript engine used in the Mozilla projects.

more…


Visual IP Locator based upon AJAX and the Google Maps JSAPI...

Matt Inman has released a little AJAX application that uses the Google Map Javascript API to visually display the location of an IP address.

Creating a visual IP address map isn't a perfect location, so don't expect to see your home address show up. Instead, they usually do a pretty good job of tracking the IP address back to your local ISP. Interesting product none the less.


FireBug - A great new Firefox Extension for Web Developers...

I find this nifty Firefox extension over on the Digital Media Minute blog. The FireBug extension is basically a combination of a DOM Inspector, JavaScript Console and XmlHttpRequest packet sniffer—all wrapped up into a Sidebar component.

I haven't played around with it very much yet, but for a "pre-pre-alpha" seems to work very well. I did notice that the keyboard shortcut to show the sidebar, does not hide it if it's already visible. That's the only thing I've found so far.


Quickly detecting if a Verity collection exists in CFMX

I ran into some problems with some code recently that had been written for pre-ColdFusion MX 7. The code in question was designed to create a Verity collection if it didn't already exist.

In past versions of ColdFusion, if you invoked the <cfcollection action="create" /> tag on a collection that already existed, you simply use a cftry/cfcatch to skip doing an error. So, the developer before me had been writing lines of code like this:

<cftry>
    <cfcollection action="create" collection="MyCatalog" path="#someDirectory#" />
    <cfcatch type="any"></cfcatch>
</cftry>

more…