Knock::on_wood

unclear thoughts on software development

Articles written in December 2007

Saturday, December 15, 2007

New Design

I wanted to play with Liquid, Mephisto’s templating engine. So in the process, I thought I’d create a custom theme for this sporadically updated blog.

I’ve added a few plugins and some code highlighting as well. Fun fun.

Monday, December 10, 2007

Boolean Columns

Just found this little tidbit about returning a boolean from a tinyint column tonight on the rails wiki...

Columns which are either boolean or tinyint(1) are recognised as booleans by ActiveRecord. So, if you have a table “people” and a column “rocks tinyint(1)”, you can say:

person = People.find(1)
person.rocks = true

However, person.rocks will return an integer, and Ruby thinks that 0 is true. If you want to test for truth, use person.rocks?, like this view example:

<% if person.rocks? %>
  You rock, dude!
<% end %>

I did not know that. Pretty dang cool.

Monday, December 10, 2007

Go ahead, cheat (It's ok!)

Though I'm fairly weened from intellisense from my .NET days, I still find myself always needing some type of reference when writing Ruby or Rails projects. There's always a browser tab with the Rails API, noobkit, or some other cheatsheet . While cheatsheets are pretty and all, they are sometimes just a hassle to find and go it when you just need that little syntax helper. So what do I do, I cheat.

This little command line tool provides a wealth of help at the tip of your fingertips.

gem install cheat

Then see what cheats are available.

cheat sheets

Or just run one (I use this one a lot)

cheat strftime

There are just hundreds out there. And you can edit (fix) one or add your own. The app is just a command line front end to a wiki. Pretty sweet.

Sunday, December 09, 2007

Ruby Debug

So one of the hardest things to do in a highly dynamic language is to debug code. If you feel the same way, check out the ruby-debug gem. Rails 2.0 now has full support for it and it’s a real “step forward, into, and out” debugger.

Here’s a great screencast to get you started. If you use cheat (which I highly recommend), simply type cheat rubydebug in the console to see all the options.

Saturday, December 08, 2007

Subversion Icons for TextMate

Here’s a great plugin for TextMate by Ciarán Walsh to overlay the status icon on each file/folder under subversion.

Grab the most recent release (as of today) here.

Powered by Mephisto. Theme modified and ported by Ryan Wood, based on the WordPress theme minima.