tiniest of tips

Every time you find yourself typing something long and repetitive, automate it. Every time.

I often hop into script/console, so aliasing that is a no-brainer. That is not the point of this post, though; I also often look up my current user when I’m in script/console, and I get tired of typing my email address every time. Add a method into your ~/.irbrc to make that painless, too.

[~/dev/railsapp] alias sc

[~/dev/railsapp] tail -n 3 ~/.irbrc
def me
  User.find_by_email 'jmorrison@thoughtbot.com'

[~/dev/railsapp] sc
Loading development environment (Rails 2.3.3)

>> me
  SQL (0.2ms)   SET NAMES 'utf8'
  SQL (0.1ms)   SET SQL_AUTO_IS_NULL=0
  User Columns (2.7ms)   SHOW FIELDS FROM `users`
  User Load (60.1ms)   SELECT * FROM `users` WHERE (`users`.`email` = 'jmorrison@thoughtbot.com') LIMIT 1
=> #<User id: 1, name: "Jason Morrison", email: "jmorrison@thoughtbot.com">

Hound automatically reviews Ruby, JavaScript, and CoffeeScript code in your GitHub pull requests and comments on style violations. It is free for open source repos and $12/month per private repo.