Roll Your Own Remember Me

October 11, 2009

I’ve been setting up Fluid Applications for a lot of the web applications I use frequently. This lets you run a web application in a lightweight browser, like it’s a native OS X application. Instead of having Gmail, Google Reader, Pivotal Tracker, and New Relic running in tabs in a browser I have them running as separate applications that I can switch between using the normal Cmd-Tab.

This has been working really well for me, until I hit one annoyance with New Relic. This web app doesn’t have a remember me feature. Its login cookies expire every time you close your browser session (as is the default in ruby on rails). This meant that every time I would pop it open I would have to re-enter my login credentials. Turns out I like to quit and reopen this application a lot, and was starting to get really irritated by having to retype my email and password to do a quick check of the production servers.

Resizing Textareas as You Type with Prototype

May 27, 2009

In my last post I described how you can use jQuery to easily add dynamically scaling textareas to your site. Now here’s one for everyone using Rail’s standard javascript framework Prototype:

Resizing Textareas as You Type with jQuery

May 26, 2009

Here’s some code I’m going to use on every project from now on. It makes all the textarea fields in your forms resize dynamically as the user types. Drop it unobtrusively into any page (running jQuery) and all your textareas expand to fit the text the user has entered.



Smart Pluralize for Rails

May 19, 2009

Sometimes you want to decide whether or not to pluralize a string based on a quantity. For example, at the bottom of this article should it say 1 comment or 2 comments? It depends on how many comments we have. I was running into this in a lot while pair programming on one project, so Ian Smith-Heisters and I whipped up this simple helper which makes it easy.

class String
  def smart_pluralize(num=self)
    num.to_i.abs == 1 ? self : pluralize
  end
end