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:


.autotest file:
#!/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
Tagged: autotest development ruby ruby on rails testing
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.
Tagged: ruby on rails
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
Tagged: business business-reviews
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
Tagged: personality
In a previous post, I setup custom data with Redmine to track specific criteria with my development projects. Since then I have written a plugin to make tracking scores easier. Like my other plugin, I'm releasing this under the GNU GPL v2.
Alpha Release
Unlike my other plugin, this one will be undergoing some major changes soon so it should not be used on a production system. I'm releasing it early to get some feedback for the next release, which should be production ready. If you could help send some code or suggestions, please visit my bug tracker.
Purpose
This plugin will let a user score a project on different criteria. I use it to score my consulting projects and pick the ones that are the best fix for my business.
Features
- Projects can be scored based on user defined values
- Score groups can be setup to rank a project in different areas (e.g. Profitability, Fun)
- Total score for a project is calculated
Install
Download the archive file and extract it to your vendor/plugins folder. You can also download directly from my Subversion server using Rails's plungin script
script/plugin install svn://dev.littlestreamsoftware.com/redmine_project_scores_plugin/tags/release-0.0.1
Or the very latest copy:
script/plugin install svn://dev.littlestreamsoftware.com/redmine_project_scores_plugin/trunk
- Follow the Redmine plugin installation steps.
Setup the databases using the migrations.
rake db:migrate_plugins
Login to your Redmine install as an Administrator
- Enable the "Score Module" permissions for your Roles
- Add the "Score module" to the enabled modules for your project
- The link to the plugin should appear on that project's navigation
The database setup includes some default data, feel free to change it or add your own using the Rails console.
Help
If you need help you can leave a comment here or enter an issue directly into my bug tracker.
Tagged: open source redmine
This is a guest post by Joshua Clanton. Joshua is a freelance web designer who writes about design, productivity, and creativity on his blog. If you would like to write a guest post for theAdmin, email me.
For a couple of months now, I've been considering writing monthly goals for myself, but never quite seemed to get around to it. So when Eric offered me the opportunity to write a guest post for theAdmin.org and suggested starting my own progress reports I jumped at the chance.
So here it is, my first Monthly Progress Review. In the future, I plan to post a review on my own blog at the beginning of each month. Since I think that marketing is my weak point, that's where I've chosen to focus my goals for now.
January Goals and Actions
1. Add 40 more RSS subscribers to my blog
Despite what it looks like, this wasn't stolen from Eric. Towards the end of the month it looked like I wasn't going to be able to meet this goal, since I'd been stuck at 25 new subscribers, but just in the last couple of days there has been a jump of 17 more subscribers.
Goal accomplished, plus some.
2. Write 4 guest posts
This month I wrote the following guest posts...
- Avoid Freelance Horror - 6 Lessons from Stephen King on Freelance Folder
- Focus and Flow for the Insanely Interested on Jarkko Laine's blog Insanely Interested in Everything
- 3 Ways to Become More Productive by Drawing on Your Inner Artist on Productivity in Context
- And of course, this post itself.
Goal accomplished.
3. Create an AdWords campaign for one of my niches
I accomplished this goal fairly early on in the month. Haven't had great results from it yet, but I'm looking to improve that.
February Goals
1. Add 60 more RSS subscribers to my blog
Since I met my goal for January, its time to up the ante a bit, and I think 60 new subscribers will be enough to be challenging without making me insane about it either. Want to help me out? Go ahead and subscribe!
2. Write 4 more guest posts
I have been very happy with the success of my guest posts so far, but I also want to maintain a high quality of posts on my own blog, and at this point, I think that 4 guest posts per month is a good balance.
3. Obtain at least 2 guest posts from other bloggers
Related to the goal above, I think it would be good to feature a couple of guest posts on my blog, both to get more of others' perspectives, as well as to give me the opportunity to focus on some very high quality posts. If you're interested in writing for my blog, contact me.
4. Optimize my AdWords campaign
While I think my keywords are good, I need to rewrite the ads and landing page to increase clickthrough and conversion rates.
5. Release a free WordPress theme
This will be my first attempt to create a theme for a broad audience, so I will also be asking for feedback on the theme before it is released.
6. Outline an ebook and write one chapter of it
I've had an idea in the back of my mind for a short (25 page) ebook for a while now. This month I intend to take the time to draw up a formal outline and write at least one chapter of the content.
Lesson learned
If you are posting quality content on your own blog and leaving quality comments on other people's blogs, there's a pretty good chance they'll ask you for a guest post before you ask them.
Thanks to Eric for letting me guest-post!
Joshua Clanton is a freelance web designer who blogs about design, productivity, and creativity. If you liked this post, you might also like 18 Productivity Haikus - Get Things Done and Achieve Inner Peace through the Power of Poetry.
Tagged: business guest-business-reviews
Was able to start to catch up on some developer links I had bookmarked this week:
- No True "mod_ruby" Is Damaging Ruby's Viability On The Web - Peter Cooper wants to know why there isn't there a good
mod_ruby for Apache.
- Merb 0.5.0 is out - Hot on the tails of my last set of links, Merb has just released their latest version. It sounds like their next point release will be separated into the core and extras.
- loupe.js - Cool JavaScript library to "zoom" over parts of an image. It can also display part of another image under the magnifying glass (X-ray).
- Reinventing the Clipboard - Coding Horror talks about the limitation of the Windows clipboard to only hold one thing at a time. Linux and Emacs have had multiple clipboards for some time now, it's amazing Microsoft hasn't added this feature.
- 2007: The Ruby on Rails Year in Review - Very nice review of the progress Ruby on Rails made in 2007. Let's make 2008 even better.
Tagged: merb ruby ruby on rails
Your personality says a lot about you and how you react to the world. Several months back I found a programmer personality test that will describe how you like to program. Today, I decided to take it again to see how I've changed.
Originally I took it along with all the other programmers where I worked, and the results were valid. The guy who loved writing tight data structures in C was a "Low Level" programmer and the one who stringed 10 function calls on a single line to save space ended up being "Conservative".
Both times, I came up as DHSB. Not a bad type for a freelance programmer:
- Doer - I would rather get the general idea of a feature and then dig into the code. Most plans change as you start implementing.
- High level - I love Ruby and she loves me. I've been flirting with Common Lisp just to learn how it's macros work.
- Solo situation - I prefer to work on a solution by myself or with a few people. I've seen too many bad ideas result from large meetings.
- Liberal - To help support my High level, I try to build up abstractions in my code to make it easier on myself and my team. Since these are usually used by many people, I try to be extra clear so to prevent misunderstandings later.
I had my friend Peter Chester take it and he said this would be a good way to help decide who should work on a specific project. Got a prototype? You will want a Doer. Need an embedded driver for a cell phone? Low level is for you. Need a n-tier system? You will want a Team.
What personality type are you? Does it fit you?
Eric
Tagged: development programming
Mason over at Small Fuel Marketing just wrote a great post about how small business blogging can grow your business. I want share my own first hand experience of my own business blogging.
This blog has been online since 2005 but it was mostly just a place I stored thoughts and ideas I had. Around July 2007 I started my own software company and decided to start blogging about it with the goal of helping people see what is involved with starting a web business. Since then I've tried to post monthly business reviews to give an in depth view of my business.
Here's some benefits I've received over the past 6 months.
6 times increase in subscriptions
I started with about 20 regular subscribers to my blog. Today I have over 120 people subscribed. To restate that, there are 120 people who are coming to my website daily wanting information I write about. Anyone interested in exponential growth? I am!
Tripled my visitor count
Just from blogging about my business and what I'm doing, I've tripled the number of people coming to my websites. This by itself is good but if you know that I do 0 advertising other than links in comments, this is amazing.
Started a Relationship that will be worth six digits this year
From one comment I posted to another blog, I started a relationship with a very influential group of people. This relationship, along with their network will provide me with at least six digits of revenue this year.
Are you brave enough to take action?
All of this was done with the basics Mason outlined, without any advertising or any networking off the Internet. I think I've spent about 3-8 hours a week updating this blog and connecting with others. Not a bad investment at all.
Head over to the Small Fuel Marketing Blog now and see how your business can grow in the next 6 months.
Eric
Tagged: blogging business
Every businessperson makes mistakes, but how do they make up for them?
Today 37 Signals had a major outage on all of their websites. These websites are used by thousands of people every day to run their business, including me. I found out about the outage when I tried to lookup the phone number of a customer I was about to call. Luckly for me I had a copy of the number some place else.
It turned out that the outage wasn't 37 Signals' fault, but it did impact their customers. These customers pay to have access to their websites, and to use the data they have stored in them. Once the services were back up 37 Signals issued a great apology and even offered to go the extra mile for their customers:
... While we don't have a formal service-level agreement (SLA), we still want to compensate anyone who felt they were negatively affected in their work because of this outage. Please write support@37signals.com and we'll get that taken care of. ...
Any business that didn't provide a SLA like 37 Signals could have just said "Yep, we had downtime. Sorry, deal with it". Instead they are offered to help the people who were affected, even though they have no obligation to. This is how a business should deal with a mistake, even if it isn't their fault.
It even appears they took the same action in the past and tried to do their best to make it up to people.
So how does your business handle mistakes? Are you proactive and try to go the extra mile to please your customers?
Eric
Tagged: business customer service