Knock::on_wood

unclear thoughts on software development

Articles tagged with tips

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.

Tuesday, May 16, 2006

Saving CSS Background Images

The good ‘ole `Save Page As` drops the ball when trying to grab well-formed, standards based websites where most, if not all, of the images are specified in CSS. I spent an hour or so yesterday scouring the web for some tool that would download these CSS images. I found nothing.

I went back to the tried and true Web Developer toolbar extension for FireFox and found the View Image Information option (under the Images button).

It interrogates the CSS file creates a very nice list of all inline and CSS images. You still have to right click and save them individually, but it definitely helps.

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