Month: March 2011

Speeding ruby tests up by putting gems on a ramdisk

It doesn’t work.

Time before ramdisk: 32.24 – 33.7 seconds
Time after ramdisk: 32.38 – 33.65 seconds

I am being unfair. The first run without the ramdisk was about 10 seconds slower, then the times were in the range above. With the ramdisk, it went straight into that range. Nevertheless, for the case in which I care most about test runtime, the change-stuff-and-run-again case, as long as the caches stay hot I’m not going to win anything by stuffing around with a ramdisk.

ajax toggle magic

Here’s an obvious-in-retrospect bit of code:


$.fn.liveAndRun = function(event_name, f) {
$(this).live(event_name, f);
f.apply(this);
}

It’s for when you have checkboxes or radio buttons that toggle the visibility of form inputs. If validation fails and you send the form back to the browser, using $(selector).liveAndRun instead of $(selector).live means that the functions that sort out visibility happen on page load, not just when the checkbox gets clicked. And happy unicorns ride ponies to a delicious breakfast.