February 2008
8 posts
2 tags
Pesto Caesar Salad
I’ve been experimenting with salad dressings for a head of Romaine I got recently, and finally came up with the following. For one large salad: Ingredients: 5 leaves Romaine (I leave the rib in; if you don’t like it, use 7 rib-less leaves) 1½-2 tsp lemon juice 2-3 tsp olive oil 8-10 drops Worcestershire sauce (instead of anchovies!) a few (OK, several for me) turns of...
Feb 26th
3 tags
with_modules_unavailable and Some Module helpers
I’ve been trying to test a new Rails plugin (stay tuned!), and I’ve found that I need to have certain Modules unavailable. This is useful when you need to test that missing Modules will raise errors or if you have behavior conditional on what gems are installed. I wanted something like: ... with_modules_unavailable(Foo, Bar::Baz::Goo) do test stuff end To get this working, just...
Feb 19th
3 tags
Updates to active_support_hacks
I’ve made a couple of updates to my active_support_hacks First: DateRange#include?(other) This accepts a Date, Time or another TimeRange. It assumes inclusive range ends 4.days.ago.until(1.day.ago).include?(2.days.ago) # => true 4.days.ago.until(1.day.ago).include?(3.days.ago.until(2.days.ago) # =>...
Feb 17th
2 tags
Frustrated With Media
I’m really just tired of it all. I’ve been trying all evening to watch some old TV shows on my nice Netflix unlimited subscription. Problem: I’ve got a Mac. I’ve got Parallels, and occasionally it’ll run Windows, but mostly it just crashes. I’m sick and tired of Microsoft writing code that crashes constantly. I’m sick and tired of Apple being greedy...
Feb 16th
3 tags
ActiveSupport Additions: TimeRange and Distance
I’ve created some utility classes that I use in many of my projects. I’ve broken them out into a Rails plugin, but they should really be part of ActiveSupport. First: TimeRange t = 5.minutes.ago.until(1.second.ago) s = 10.minutes.ago.until(3.minutes.ago) overlap = t & s overlap.start_time # => 5.minutes.ago overlap.end_time # => 3.minutes.ago Second: Distance 4.miles...
Feb 14th
8 tags
Reliable Software in Three Simple Steps
(or: How I Realized Intro Economics Applies to Software Engineering) The Rules: Hire a small number of really good programmers Hire one Information Assurance (IA) superstar Hire as many testers as you can without regard to past performance The Rationale: Software development is largely a weakest-link game. If you hire one crappy programmer, he’ll write crappy code that the stars...
Feb 10th
6 tags
The Problem with Rails' Resource Routes
Today I show how to easily solve an incredibly annoying (but small) problem in Rails Routing for Resources. For my past few Rails projects, I’ve created a module called ModelLoader that I include in my Controllers to load requested Models from the database. For each of my models, I have a #load_xxx and a require_xxx!. For an app that contains People and Tickets, the model loader would look...
Feb 9th
4 tags
Hacking Rubygems' #require, #require_gem, and #gem
I have some old gems in my latest Rails app, and Rubygems has changed its syntax since those gems were built. The gems have require_gem in them, but the newest version of Rubygems doesn’t add that command to Kernel, so you get NoMethodErrors when the gem loads. This simple hack in config/environment.rb will fix it: # hack rubygem's change to #require: Kernel.class_eval do def...
Feb 9th