Knock::on_wood

unclear thoughts on software development

Sunday, January 20, 2008

Rails 2.0 Cheatsheet

Rails 2.0 Cheatsheet

Download it here!

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.

Friday, June 15, 2007

Free Diff/Merge Tool

Back at Datastream we used Vault as a replacement for for Visual SourceSafe. It was a great tool. (Not living (completely) in Microsoft land anymore, I now use Subversion for all source control.) Bundled with Vault was a diff tool. It's apparently grown up into an nice little app.

SourceGear just released it's diff and merging tool, aptly named DiffMerge for free. It's available for windows, Mac, and Linux. In fact, depending on the API, I may try to integrate it with TextMate's Subversion bundle to finally get a good visual diff engine on the Mac.

DiffMerge

Download it now.

Saturday, June 02, 2007

Crontab problems with nano

I was trying to set up a cron job on my new (relatively) SliceHost VPS. On Ubuntu, each time I would run crontab -e, edit and save the file, I would get this:

"/tmp/crontab.nQMgF1/crontab"\:2: bad minute
errors in crontab file, can't install. 
Do you want to retry the same edit?

It didn't seem to matter that the syntax was correct. Ha. After googling around for a while, I found out that the problem was with nano, the default text editor on Ubuntu. It wraps long lines by default and crontab has a problem with this.To fix the problem you need to turn off long line wrapping which is on by default. Go to /etc/nanorc and uncomment the following line

set nowrap

Now, nano will correctly save your crontab. (I also uncommented

set rebinddelete

to find a problem with backspace/delete on the mac.)

Thursday, May 03, 2007

CFObjective

I’m heading to Minneapolis today to go to CFObjective.

Saturday, March 10, 2007

Back in the ColdFusion World

For the past 6 months, I’ve been spending a lot of time of time applying object oriented architecture principles to a rather large ColdFusion application. We are employing Transfer for our ORM, ColdSpring as our dependency injection engine, and Fusebox 5.1 as our web UI framework. This initial architecture was already in Fusebox 4, so we stayed it rather than moving to Model-Glue or Mach-II (the more innately OO CF frameworks).

Be on the lookout for a bunch a new posts around these topics.

Wednesday, November 15, 2006

Premature Extraction

The Rails Way is off with their first code review. It is really great to see into the coding process of top notch hackers. Their first review deals with “acts_as” code modules and “premature extraction”. Koz keeps it simple.

These both illustrate a common anti-pattern I see with rails programmers: premature extraction. Just because rails has a bunch of meta programming magic with names like acts_as_list, doesn’t mean you need it.

The process is all about keeping it simple and extracting only when you need to. I’ve been learning more and more about that in a Ruby application I’ve been working on lately. It is a challenge, especially coming from .NET, to not overly abstract early.

Thursday, November 09, 2006

Crunch or Krackel?

Being inundated with Halloween candy, I wondered which chocolate I like the best, Hershey or Nestle. Of course there are many other exotic options, but the question is really one of branding—a Coke or Pepsi kind of venture.

I happened to be eating a small Nestle Crunch bar when thoughts of my childhood crept up. Each summer morning, my Mom dropped me off at the pool for swim practice. I would inevitably stay through lunch charging it to my parents account. That is until my dad got the bill. Then, no more lunches. So my friends and I would do what every American sweet tooth would. We figured out the cheapest, tasty lunch possible. A cherry coke and a nestle crunch bar. mmmmmm.

When dad completely cut off the fund, we’d sneak into the clubhouse and find those little Andes mints for the dining room, and grab a handful. Not quite as good, but they got the job done. Nestle Crunch was just the best.

So I’m thinking? Does Nestle have better chocolate or is it just my fond (and dentally terrifying) memories of my youth that make it taste better than Hershey’s. I don’t know. What do you think? Do you prefer one over the other? Why? I’m really curious now.

Monday, November 06, 2006

Coda

Hopefully this won’t completely kill my new commitment to blogging. We’ll see. We add a new member to the family this weekend. Introducing “Coda”...

He’s a little black lab we adopted into the family this weekend. He’s about 7 (or so) weeks old. And I thought we were moving out of the baby stage.

Here are some other pics of the litte guy.

Monday, November 06, 2006

Fusebox 5.1 in the works

Sean Corfield, lead developer of Fusebox 5.0, announced that 5.1 is underway. It’s great to see continual thought and effort being poured into Fusebox in light of all the new frameworks out there.

Here’s a list of cases that comprise the 5.1 release.

Saturday, November 04, 2006

The Rails Way

Most who know me, know that I am a big fan of Ruby and Rails. I simply enjoy using the language far more than others I’ve used. The biggest reason is the community. I my previous post about the importance of choosing a community, I note the differences that I’ve experienced. Here’s another…

Jamis Buck and Michael Koziarski have introduced The Rails Way, a site where you can upload code and they will analyze it according to best practices (a.k.a. the rails way). This is not for-profit, it is for the community—a way to help others grow in their coding skills. I really do enjoy being a part of this community.

You can read the intro on Jamis’ blog.

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