Rajan Agaskar's blog
Helps
- Fast/Simple share widget plugins? A project was in need of a turn-key plugin to provide Digg/Twitter/Facebook links. The two suggestions were the ever-popular "roll-your-own", and pivotal's own bookmark_fu. The latter of which, if you glance downwards and towards the right, you'll see in use on this very blog! (Unless, of course, you're using Google Reader and robbing us of our ad revenue riches).
Interesting
- SpecRails Superclass Shenanigans
A Pivot found that when spec_rails is loaded, the superclass of spec suites changes to ActiveSupport::TestCase, instead of ExampleGroup (which, in this case, had a number of useful and necessary methods added to it). [1]
This carefully named plugin provides really nice sql-console-style formatting for ActiveRecord queries made from the irb console. I'm going to install it right away so I can pretend I still remember how to write MySQL queries by hand!
[1] I was working on a brilliant analogy that referenced Dick Dastardly and Muttley here, but I totally failed. Still, Wacky Races was totally rad, right? Radder than sneakily replacing superclasses, anyhow.
Interesting Things
Fixjour blows up on validations for associated models
Two Pivots experienced this problem on separate projects. The general consensus was that generating objects with correct associations can be difficult. FactoryGirl was recommended as a fixture plugin that handles this problem particularly well. It was also suggested that rolling your own object mothers was trivial (fisticuffs ensued).
timeout.rb
Timeout.rb raises an exception to kill child threads; it so happens that this exception can be caught, and possibly swallowed. This is truly a Noid to be avoided at all costs.
- UPDATE: Tests using Paperclip fail to run
When Paperclip cannot find identify in the path, it will raise an error that suggests it has been called with incorrect arguments. This is a bold-faced lie.
One Pivot remarked that these tests should really be mocking Paperclip in the first place, which seems an appropriate response to dishonesty.
Interesting Things
- fleegix.date.Date - Javascript, DST, and You
In 1895, George Vernon Hudson somehow managed to convince the world (of the Wellington Philosophical Society) that Daylight Savings Time was a good idea.[1] Hudson, an amateur entomologist, was motivated by his desire to look for bugs after work.[2] Sadly he did not forsee that determining DST for multiple regions using JavaScript would be a non-trivial task.
Javascript provides some rudimentary timezone support with Date.parse, but does not automatically apply daylight savings time, in other words:
Date.parse('Sep 9 2009 11:00:00 PST');
and
Date.parse('Sep 9 2009 11:00:00 PDT');
return different timestamps. fleegix.date.Date (a plugin for the fleegix.js library) lets you express the timezone as a region string, automatically taking into account whether or not that region observes Daylight Savings Time (by using Olson files), and providing the same interface as the native Javascript date. This means you can get an proper timestamp with the following:
new fleegix.date.Date('9/9/2009 11:00:00', 'America/Los_Angeles');
This is arguably more useful than Daylight Savings Time itself.
- RightScale errors
Two Pivots experienced an issue where RightScale was caching their connection to Amazon upon creation. This led to the connection start time parameter getting further and further out of date until Amazon failed to accept the upload with a 'Request Time Too Skewed' error. No workaround was discussed, but it was roundly decided that any error with the word "Skewed" in it is pretty awesome. [3]
[1] Well, according to Wikipedia, so it might as well have been Ron Paul for all we know.
[2] aaaaaand rimshot.
[3] Not really.
Interesting Things
- Pivotal Core Bundle - Deprecations deprecated!
Two Pivots heroically removed some deprecated extensions and rake tasks from the Pivotal Core Bundle. Do not be surprised if your favorite code jams (like cancel_default_validates_associated class method) disappear next time you pull.
- Move files fast!
Some lucky pivot discovered that
mv file.tgz *will move all files in the current path into the last file or directory it can find.
If for some reason you do not want this to happen, it is recommended that you always specify a destination when moving files.
To help you remember this protip, here's a totally worthless analogy that involves automobiles: would you get into a cab without telling the driver where you wanted to go?
No, you would not, because he would take you to IHOP, and you hate pancakes. You wanted to go to Waffle House, which is unfortunate, because the nearest Waffle House is in Nevada.
