Next: World Domination

December 27, 2005 Link to post  Permalink

For christmas, Lisa got me Electronic Gadgets for the Evil Genius This thing has plans (sadly, not detailed) for an EMP, just like in the movies!

My plans for World Domination are set in motion, bwah-ha-ha-ha.

Next on my list: Fluffy White Cat.

Rails action cache upgrade

December 26, 2005 Link to post  Permalink

Due to issues with page caching, I just started looking at the Rails action cache. There are a few things that could be done better by the built in code, but since this is written in Ruby, I can make those changes in my code and override the pieces I want.

The core of Rails Action Caching is the around filter applied to all actions that are to be cached. I re-implemented the before and after methods to make the changes I needed.

Here are the things I changed:

The code can be downloaded here. Place action-cache.rb in your lib directory and require ‘action-cache’ in your environment.rb to hook this in. Since this extends Rails Action Caching, all the documentation for that code still applies, e.g.

Rails OutputCompressionFilter

December 17, 2005 Link to post  Permalink

The Rails documentation has passing references to a filter class called OutputCompressionFilter. However, this code is nowhere to be found.

Since I have some code to do output compression (see my earlier post), I decided to repackage it as this class:

Here is the source file – put it in your lib directory.

Here is how you use this code:

Rails RJS Templates need better replace semantics

December 15, 2005 Link to post  Permalink


If I have a collection of things that are output like this:


I can use AJAX to insert a new ‘thing’ by implementing an RJS template that does this, reusing the same partial layout:

Rails output compression

December 7, 2005 Link to post  Permalink

I want to be able to compress my output text that I send to the browser from my Rails app. This will include HTML, javascript, Ajax responses, plain text etc. Lighttpd will perform this function for the static files it serves, but not for the dynamic files, so I went looking for a solution.

There is a README for ActionPack that has this snippet of code:

after_filter { |c| c.response.body = GZip::compress(c.response.body) }

I added this to my ApplicationController, and it doesn’t work.

Make your DIVs Resizeable

December 1, 2005 Link to post  Permalink


I love using Scriptaculous for its effects and drag/drop. However, I need to have my DIVs be resizable too. To make this happen, I’ve written a class called Resizeable that can be added to a DIV in the same way that Draggable can be.

This code is standalone (it needs Prototype, but not Scriptaculous), and it can be used with Draggable with one note: The Draggable handle cannot be the element that is Resizeable, you must specify a handle element when you create a Draggable to avoid confusion between Draggable and Resizeable.

This doesn’t work very well

new Draggable(‘foo’); new Resizeable(‘foo’);

This works nicely:

new Draggable(‘foo’, {handle: ’bar’}); new Resizeable(‘foo’);

There aren’t many options for this object, but here they are:

The grab areas can be defined with top, left, bottom, right. Each defaults to 6 pixels. If you set this to 0 (zero), then resize in that direction will be disabled.

new Resizeable(‘foo’, {top: 0, left:50} );

A callback function can be defined that will be called when the resize is over.

new Resizeable(‘foo’, {resize: function(el) { alert(‘Done!’); } } );

The minimum height and width of the DIV can be specified as minHeight and minWidth options.

The resizable code in action – view source to see how it works.

The Javascript source file can be downloaded here

Currently, this code doesn’t quite work in IE (the DIV can jiggle around a little), but Firefox 1.0 is working Ok.

Weirdness in Napa

November 26, 2005 Link to post  Permalink

Last Saturday, we spent about 5 hours in Napa on a trip organized by the Seahawks. We visited two wineries – Opus One and Neibaum Coppola. We had a great time at both. Opus One took us on a tour of the facility and we had a tasting in a dining room that opens onto their impressive barrel room.

At Neibaum Coppola, they took us to a private area and we tasted wine and ate some great cheese.

Here’s where the weirdness begins. After our cheese and wine, a bunch of helicopters started buzzing around. It was quite annoying. It turns out that Christina Aguilera was getting married on a neighboring property.

The other weird thing. Whilst driving there and back, we noticed a house just off the road on a hill. It turns out it was the Napa house from this CNN article

Seahawks sunburnt in San Francisco?

November 21, 2005 Link to post  Permalink

The Seahawks took us to our annual away game, this year in San Francisco. This year was the best we’ve been to so far. Once again, the Seahawks manage to get me sunburnt in November. The temperature in SF was over 70 on Sunday, and we had seats in the sun. We did manage to find a tube of SPF 8 sunscreen, and that did a good enough job to stop a full burn.

The heat may have got to the Seahawks too, as they wilted a bit in the second half.

The SF crowd were completely out of it in the first half. The player introductions were the quietest I’ve ever heard.

The 49ers had an ace up their sleeve though – at half time, bring out Steve Young and present him with his Hall of Fame ring. Now the crowd comes alive.

Fun with Rails on the edge and RJS

November 18, 2005 Link to post  Permalink

There’s a new template system being built into Rails right now that helps generate Javascript responses to browser Ajax calls. The template extension is RJS.

Since I wrote a bunch of code to do something like this only yesterday, today, I sync’d up to the latest Rails to give it a go.

Well, it works! Reading the RDoc comments in the source code, and with a little experimentation, I got the thing to work, converting my rhtml file into the rjs equivalent.


Didn't see Harry Potter today

November 18, 2005 Link to post  Permalink

Lisa spent 2 hours at Les Schwab getting the snow tires put on the car yesterday. It seems that low profile tires shouldn’t be swapped off the wheels very often, as our snow tires were damaged the first time they were taken off the car.

On the way to see Harry Potter this afternoon, a strange noise started, on inspection on the side of the road, the driver’s side rear tire was flat (and hot)

We drove the mile to Les Schwab to switch back to the summer tires. Two new rear snow tires, and a set of wheels to match, have been ordered and will be available on Tuesday.

I learnt to not try to be cheap and use only one set of wheels for two sets of tires.