Set initial input focus the easy (JavaScript) way

I wanted a simple way to set the input focus on a web page. The use case I wanted was this:

<input ... class="focus" />

All I want to do is add the focus class to a form field. To get this to work, I whipped up a little JavaScript (using Prototype):

function setDefaultFocus()
	var focus = $$(".focus");
	if ( focus.length > 0 )
Event.observe(window, 'load', setDefaultFocus);

The result: After your page finishes loading, the first element found with the focus class will be given the focus. Done!

Castle Project has gone RC3

So much has changed since RC2, it makes RC2 look like a beta. 🙂

I’m happy to say that I’m not just a user of Castle projects, but also a contributor (having sent in a few patches related to the Castle Validator).

With RC3’s features and stability, and a nice easy Windows installer available on SourceForge, there’s no excuse for you not to start exploring the power that the Castle Project libraries can bring you.

TypeQuick: How fast do you type?

It seems many people are measuring their typing speed using the TYPEQUICK online typing test. Not to be left out, I gave it a run:

Number of words typed: 282
Test duration: 3 min
Speed: 94.1 words/min. (470 keystrokes/min.)
Error penalty: 14
Accuracy: 95.0%

Not bad. I’d probably have done better if I didn’t habitually use the backspace key to correct errors — a trait that not only reduces error rate, but also slows me down. About ten years ago I took a typing test that would not let you backspace and would beep every time you typed an error. There were beeps every few seconds. The bad part is, I make lots of mistakes. The good part is, my fingers know about them, even when I’m not looking at the words I’m typing. You’d think my fingers would have gotten better over the years…

Forgot your Windows product key? It is recoverable…

I frequently rebuild my computer once Windows starts to reach its half-life, formatting the ‘ol hard drive and starting from scratch. Unfortunately, this typically involves a hunt for the Windows XP product key, which typically was written down on a piece of paper and subsequently misplaced. This time, however, I decided not to hunt for that sticky note. Surely, Windows XP knows the product key that was used when it was installed… right?

KeyFinder by Magical Jelly Bean SoftwareApparently, it does, and there’s a little piece of free software that can find it for you. KeyFinder by Magical Jelly Bean Software can identify the product key for Windows 95, 98, ME, NT4, 2000, XP, Server 2003, Windows Vista, Office 97, Office XP, and Office 2003 — on the local computer or on a remote computer (provided you have appropriate security permissions). Very impressive.

Wilson’s O/R Mapper going open source

I’ve been a fan (and user) of Paul Wilson‘s O/R mapper for some time now, having contributed to code generation templates, a service library, and a private Subversion repository for registered owners. I’m happy to say that, as of today, Paul has decided to release his O/R mapper as open source, and I’ve been given the honor of being its caretaker in the process.

The open source release of WilsonORMapper will be hosted on Google Code at I expect to check-in the first official open source release over the next few days, once I clean up a few things and make the necessary license changes to the source. The code will be released under the New BSD License, which is one of the most permissive open source licenses out there.

Thanks to Paul for all his work over the years and for releasing this wonderful product to the community, and for giving me the go-ahead to make it happen.

And for those keeping score… this is the second product I’ve coerced into full public open source in 2007 (the ASP.Net CSS Adapters, back in March, and now WilsonORMapper). Not bad for a hack like me. 🙂