Virtualizing to Save the Planet

I just got an interesting IM from Jeff, one of our other developers:

Rough calculations: By using virtual servers, we are saving about 43729 kilowatt hours per year, and reducing co2 emissions by 29.5 tons per year.
And that’s just ITS.
And that’s assuming a very liberal use of desktop class hardware for low priority tasks.

We’ve been using server virtualization for a year or so now to reduce the number of boxes that we have to keep running in the server room. It has brought us a bunch of management benefits, but I was pleasantly surprised to see the positive environmental impact the change has brought as well!

Clickable <label>s in Safari

Today while testing the latest release of our CMS system, I noticed that Safari doesn’t actually do anything interesting with its <label> tags. Firefox and other right-thinking browsers allow one to click on a label and to activate the corresponding form element.

Fortunately, with a little Javascript-Fu, we can add this behavior for Safari as well. Here’s the script we wrote to bring Safari up to snuff:

// Make label elements clickable in Safari
Event.observe( window, "load", function() {
	if ( Prototype.Browser.WebKit ) {
		$$('label').each( function( item ) {
			Event.observe(item, "click", function(){ 
					var target = $(this.getAttribute('for'));
					// Checkboxes or radio button labels
					if( target.type == 'checkbox' || target.type == 'radio' )
						target.checked = target.checked == false ? true : false;
					else // Textareas and input fields, Select elements

This does require Prototype to work, of course, so if you haven’t developed the abiding love for it that we have, you’ll need to rewrite some bits to get them to work without it. There’s also something similar out there for jQuery if you swing that way.

(Our version is based on this one, but is simplified a bit by taking advantage of some of prototype’s newer utility functions.)

A Whole Page in a URL

Over the weekend at the Lone Star Ruby Conf, I got to wondering if one could use the iPhone as an eBook reader. Since it has Safari built in, it seemed like a great device for dumping the HTML versions of books from Project Gutenberg or Cory Doctorow’s site into for easy reading on the road. Unfortunately, it doesn’t seem that there’s any way to access the local filesystem, directly or through Safari. Curses!

A little judicious googling, however, turned up another option: one can actually embed the data of a webpage directly into a URL by using the data protocol instead of the usual http. By using the URL to actually carry the content, instead of as a pointer to where the content actually lives, one no longer needs a connection to a web server or a file system. Cool! My dream lives!

But how to generate these cryptic data URLs? You can fool around with Perl or your favorite scripting language and generate them without too much fuss. However, the guys at Insanely Great Tees have knocked together a little utility that does the hard work for you: just drag and drop a file on it, and it will generate a URL with the data from that file embedded in it. You can then bookmark it, sync it to an iPhone (or presumably, an iPod Touch in a few weeks), and have offline content.

Now, I just need an iPhone to try it on…

Welcome Aboard!

Hi folks, and welcome to our new weblog! We’re establishing this as a place to jot down interesting technical notes for those of you out there on the intertubes who might be doing things similar to what we are. We’ll also be posting information about our open-source projects as we release code out there into the wild. So stick around — it should be fun!

Our first order of business — a properly clever name for the joint. If you’ve got any ideas, let us know! The winner gets a free Gato tattoo, so vote early and often!