Interesting Links #4
I’ve been scrambling this past week trying to close out a few projects before I start on some new ones. Here are a few links that came across my wanderings:
- Generating the code for an older version of Rails - A customer asked me how to generate a stock Rails application from an older release. Turns out RubyGems allow you to specify the version using underscores as an argument.
- Jeff Mackey’s notes on the SEED 2008 conference - Jeff took some notes from the 2008 SEED conference put on by 37signals, Segura Inc, and Coudal Partners.
- Practical Reporting with Ruby and Rails - New book by Apress. Sounds pretty interesting, especially with all the reporting plugins I’ve been building for Redmine.
- Real Programmers - Now if I can only get Emacs to buy my wife a Valentines Day gift, C-x M-c M-gift only works in emacs CVS.
Fail Loudly with osd_cat and autotest
A key to Test Driven Development is frequently run tests. These tests are used to judge the health of a project. Like in a hospital, when things deteriorate we have to be alerted right away.
Ruby developers use autotest to monitor and run their test suite in the background. One problem with autotest is that the results are printed to the console. No alert, no notification, no loud failure. OSX users are able to hook autotest up to growl, allowing growl to flash test results above all the windows.
Unfortunately, growl is only available for OSX, I need a Linux solution. I found someone using Knotify with autotest but the result window was tiny and easy to miss. I needed something bigger and more noticeable.
I remembered a friend used a program called osd_cat to build a volume control UI for his Linux DVR. osd_cat (On Screen Display cat) is a command line program that will print text above all your windows, similar to growl. Unlike Knotify, osd_cat can print text large and bright red.
In order to use osd_cat we need to install the program, called xosd-bin in Debian, and then hook it up to Autotest. When autotest starts it will read a Ruby file called .autotest. Using that file, I was able to hook up autotest to osd_cat. My current autotest file is adapted from several sources online and works with both RSpecs and Test::Unit.
Now I got a loud and alarming message whenever my tests fails. Not a puny little alert window but a big honking in your face “Something broke!” message:


#!/usr/bin/ruby
# NOTE Copy this to your home folder as .autotest
#
# Originally from http://wincent.com/knowledge-base/Setting_up_autotest_to_use_Growl
#
# Modifications:
# * Changed from Growl to osd_cat on Linux
# [Eric Davis http://theadmin.org]
# * Minor refactoring to use .autotest_images directory
# [Geoffrey Grosenbach http://peepcode.com]
# * Test::Unit compatibility [Pat Nakajima]
#
require 'autotest/timestamp' # time plugin
module Autotest::OsdCat
# Use xlsfonts to find the different fonts
FONT="-bitstream-charter-bold-r-normal--33-240-100-100-p-206-iso8859-1"
# Will display the message on the top of the screen centered, adjust these numbers to suit.
POSITION="top" # top|middle|bottom
POSITION_OFFSET="0" # Pixels from position to display (think CSS margin)
ALIGN="center" # left|right|center
def self.osd_cat msg, color='green'
osd_command = "echo #{msg.inspect} | osd_cat --font=#{FONT} --shadow=0 --pos=#{POSITION} -o #{POSITION_OFFSET} --delay=2 --outline=4 --align=#{ALIGN} -c #{color}"
# osd_cat blocks so start a new thread, otherwise Autotest will wait
t1 = Thread.new do
`#{osd_command}`
end
end
def self.osd_cat_fail(output)
osd_cat "#{output}", 'red'
end
def self.osd_cat_pass(output)
osd_cat "#{output}"
end
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\n")
if results.include? 'tests'
output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?(,\s*(\d+)\s+errors)?/)
if output
$~[3].to_i + $~[5].to_i > 0 ? osd_cat_fail(output) : osd_cat_pass(output)
end
else
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/)
if output
$~[2].to_i > 0 ? osd_cat_fail(output) : osd_cat_pass(output)
end
end
end
end
# From: http://www.ridaalbarazi.com/blog/2007/04/05/autotest-growling-in-red-green/
class Autotest
# All code borrowed from:
# http://www.robsanheim.com/2006/08/07/hacking-green-bar-color-output-into-autotest/
BAR = "=" * 80
# filter output for colorized green/red bar
def filter_output(results)
filtered = ""
results.each do |line|
if line =~ /\d+ tests, \d+ assertions, 0 failures, 0 errors/
line = "\e[32m#{BAR}\n#{$&}\e[0m\n\n"
elsif line =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
if $1 != 0 || $2 != 0
line = "\e[31m#{BAR}\n#{$&}\e[0m\n\n"
end
end
filtered << line
end
filtered
end
def run_tests
find_files_to_test # failed + changed/affected
cmd = make_test_cmd @files_to_test
puts cmd
@results = `#{cmd}`
hook :ran_command
puts filter_output(@results)
handle_results(@results)
end
end
Eric
Interesting Links #3
I upgraded a few Rails applications to 2.0 and found the following links helpful. In under an hour I was able to upgrade 2 applications from Rails 1.2 to 2.0.
Progress Review - January 2008
January has gone, marking my 7th month of running my freelance software business. It’s now time to take some time to review how I did with my goals and to set some new ones for February.
January Goals and Actions
After several months of “head-down” work, I took January off to scale up my marketing and get back into Ruby on Rails. I committed to 6 goals in January, but I didn’t reach all of them. Part of setting goals is failing and being happy with the growth you make.
Find an accountant - After procrastinating for months I got out and found a good accountant. She works from home and has a great sense of humor, just the type of person I need to help me run my business.
Complete 10 “Back to Ruby on Rails” tasks - I pressed hard but I just didn’t have enough time to complete 10 of the tasks on my list. I ended up finishing 9 of the 10, including reading two Ruby on Rails books (AWDWRv2 and Ajax on Rails). It’s amazing how much an active community can change in a few months and Rails is no exception.
40 new RSS Subscribers - In January, I wanted to increase my readership by 40 subscribers and as of January 31st I had 46 new subscribers. I have to say that counting subscribers is really hard, it changes from day to day. I ranged from -4 subscribers all the way up to 57. Thank you to everyone who has subscribed, your support means a lot to me.
Meet 10 new people - In my best months I was meeting 10 people, so I figured it would be easy to meet 10 in January. Turns out I was right. Between my blog, my network, and Open Sourcing some new programs I was able to meet 16 new people in January.
Open Source 2 projects - I was able to release two plugins for Redmine. I think I might have some time to even put out a second update of them in February.
Write a guest blog post - Sadly, I didn’t have any time to complete this goal in January. I have a few offers I am going to follow up on, but I had a hard time do extra writing this past month.
February Goals
Now my favorite part of the reviews, deciding what I will reach for this upcoming month.
February is going to be an adventure for me. I have a few new exciting projects coming up but I want to keep my goals focused on marketing and bringing in new business.
Logo Designed - Part of my 2008 website redesign includes a new logo for my business. Adding a logo will help me create a business brand, instead of just some text.
100 new RSS subscriptions - I reached January’s subscription goal easily so I am taking on a larger challenge. To get 100 new RSS subscribers I’ll have to really step up my online marketing, but it will bring me that much closer to my 2008 goal.
Meet 15 new people - As my network is expanding, I’m starting to meet more and more people. I’ve been able to consistently meet 10 new people a month but I have a few secrets I have planned where I can easily meet a lot of new people.
Release a large Redmine plugin - Open Sourcing my code has really helped me refine my process for delivering software. My Redmine plugins have also created a good amount of traffic to this blog, so I want to keep this up by releasing a larger Redmine plugin. I’ll have more details about it when it is ready but it will help to make Redmine the best project management tool for freelancers.
Some lessons I learned from this month:
Don’t waste energy dreading work when you can just do it: I procrastinated finding an accountant for over 3 months because I was afraid of all the time it would take. Finally when I had no choice but to find one, it took less than 6 hours to finish. I spent more time dreading the work than actually doing it.
Share your knowledge: I’ve gotten several projects just by offering my knowledge to someone. Something as small as a few emails helping someone understand an idea has materialized into a significant project.
I would like to close out this review with an open invitation. If you are running your own business or thinking about running your own business and want to be held accountable for you goals, send me an email. Joshua did it and now his February goals are public and I’ll make sure he is accountable for them.
Eric
Personality Quirks - the Other Subatomic Particles
I’ve been tagged by Shane, he’s looking for 7 of my personality quirks. Here’s what I could come up with, when my wife gets home she’ll get out her list. I think she just upgraded to a three ring binder.
1. I have to have something in my hands at all times
Doesn’t matter what I’m doing, I always have to have something in my hands to fidget with. When I’m on the phone it’s usually a pen or a set of Magnetix. If I’m out walking it’s usually my keys or my jacket pockets.
2. I hate having my food touch
I’m getting better with this but I cannot eat food that is touching. Up until about a year ago, when someone cooked spaghetti I would require them to separate the pasta from the sauce. This hit a wall when I discovered that I love Chinese food.
3. Swim? You mean like what the fishes do?
Like WAH(web)Mommy I cannot swim. Even being born in San Luis Obispo didn’t help. Of course, being 6 foot tall I can bounce my way around a pool, while entertaining onlookers.
4. I rock my chairs to death
Whenever I am sitting, I tend to rock back and forth. Because of this I’ve gone through about four office chairs in the past two years. My last chair actually broke the internal tension spring, you know the one that is half inch steel and weighs 3 pounds. Thankfully I get Staple’s one year no questions asked warranty.
5. I have three hands; right, left, and mouth
Whenever my hands are full (see #1) and I still have something I need it hold, it goes into my mouth. Pens, documents, books, iPods… nothing is safe.
6. I have the attention span of a butterfly
In the time it took me to write up this post I’ve:
- sorted some books
- checked my mail
- answered a phone call
- opened a window
- built a new desk toy
- weighed my water cup
- checked on my garden
- read a blog
- carried on an IM conversation
- checked my mail again
What was I writing about again? Oh yea, attention. Amazingly the only thing I can really focus on is coding, I just get into a flow and magically everything goes away.
7. I can’t waste electricity
Call me green or eco-friendly or whatever but I hate seeing electricity wasted. If a light or TV is left on, even for minute I shut it off. I unplug my cell phone charger when it’s not in use. I refuse to use non-rechargeable batteries
The ironic thing is I keep my computers on all the time. I guess I see them as an essential appliance, like a refrigerator. Refrigerator keeps food cold, computer keeps bits hot.
Whats the funniest personality quirk you have?
Eric