Dr Nic

Magic Wiggly Lines => GuessMethod, by Chris Shea

If you ever make time to code just for pleasure, then method_missing and const_missing are just begging for abuse.

Chris Shea has come up with GuessMethod – a very cool hack that now deprecates my concept of Magic Wiggly Linesa spell-checker for runtime code.

What’s it do? Cop a squiz at this genius…

$ gem install guessmethod -y
$ irb
> require 'rubygems'
> require 'guessmethod'
> class Object; include GuessMethod; end  # though this could go in the guessmethod.rb file in the gem
> class Product; def name; "Some product"; end; end
> Prodct.nw.nae
attention: replacing non-existant constant Prodct with Product for Object
attention: sending new instead of nw to Product:Class
attention: sending name instead of nae to #<Product:0x144ff10>:Product
=> "Some product"

That’s going straight into my .irbrc file. My bad spelling, coupled with my British/Australian English, will never slow me down again!

UPDATE: actually, it doesn’t like being in the .irbrc file for Rails console; so in the config/environments/development.rb files will have to do for the moment.

OpenID for WordPress

This blog – nay, this InterTubes HomePage – runs on WordPress.

This website allows you to comment. Like a blog. Let’s call it a blog. That’s shorter than “website”.

To comment you’ve got to fill in your name and email and website every… single… time…

Well, I don’t have to, because I have an account.

So I completely forgot about everyone else’s plight. That is, until one young soldier Rodney Ramdas, ask a good question:

hey is there an openid enabled commenting thingy [for your blog]?

OpenId logo

So I found OpenId plugin for WordPress.

Now you can create an account on my site using OpenID and never have to fill all that crap in again.

UPDATE: See comments below for how to use your blog domain name/url as your OpenID url. As it is this url that is appearing below people’s names, and that’s not what you want. That is, I can use drnicwilliams.com as my OpenID, even though it is actually http://drnicwilliams.myopenid.com/.

You can check that you’ve setup up your blog as your OpenID with this helper site.

Functional Testing using a Matrix to cover all edge cases [video]

I’ve been a fan of Ryan Davis‘ (zenspider) and Eric Hodel‘ ZenTest library (including its autotest CI tool for rails and gems), and their Hoe gem, the Rubyforge gem, etc ever since I figured out what they did. (Side note: how to setup rubyforge gem)

Over the last month, Ryan mentioned “functional testing by a matrix” in four great blog articles.

Ryan shows this off at RejectConf; its 16 minutes but definitely worth your time to investigate, as I think this will be awesome for ensuring basic edge cases are thoroughly tested. Can a guest create something? Can a member delete something?

It is hard to see the code on the screen, but look at the blog posts linked above to get the gist of what is being shown.

People were really interested this as you can tell by the huge number of questions, despite this being the last of many many presentations.

This stuff looks primed for a sweet generator to create the test file.

“Reads -> slaves, writes -> master” plugin

Another solution to multiple connections in Rails has been put together by the Revolution Health team.

Look at this sweet database.yml syntax:


  database: master_db
  host: master-host

    database: slave_db
    host: slave-host

ActsAsReadonlyable adds support of multiple read-only slave databases to ActiveRecord models. When a model is marked with acts_as_readonlyable, some of AR finders are overridden to run against a slave DB. The supported finders are find, find_by_sql, count_by_sql, find_[all_]by_*, and reload.

README all about it.