Saturday, April 28, 2012

Running Tests, Boodhoo Style

Watch this and weep at the beauty of Jean-Paul Boodhoo’s development environment.  In particular marvel at the whole “saving a file causes compilation, runs tests and lists failures in a toast pop-up” thing.  WANT.
JP publishes everything you see in the dnrTV episodes on github, so we can all learn.  He recorded a webinar about his setup, but hasn’t published the video yet.  I couldn’t wait so I went digging.
At the core is a Ruby script that checks every second for updated files and runs msbuild  to compile and then the MSpec test runner.  The script parses the MSpec runner’s output for failures and sends the text to Growl for Windows, which produced the toast notification.  It even customizes the icon that Growl to use depending on whether there are failures or not – a fiery (red) Mario for failures and a happy Mario for success.
It’s a somewhat complex system that does a few other things, like dissolving each subfolder in the main project into separate assemblies and batches some git commands.  I was particularly interested in implementing the Growl notification with the failed tests.
My setup:
  1. Growl for Windows installed in c:\utils\growl for windows
  2. JP’s Mario pictures (red.jpg, green.jpg) from github copied to c:\utils\growl for windows.
  3. MSpec extracted to C:\utils\Machine.Specifications-Release.
  4. runspecs.bat (content below) added to the tests project in my solution and set to always be copied to the output folder.
  5. A post build command on the tests project:
    $(TargetDir)runspecs.bat $(TargetFileName)
Now, every time you build your solution tests will run and failures, or a success message, are sent to Growl.
The batch:
@echo on
setlocal EnableDelayedExpansion
C:\utils\Machine.Specifications-Release\mspec-clr4.exe --html .\specs.html %1|find "FAIL">fail.txt
set fail=
for /f "tokens=*" %%a in (fail.txt) do set fail=!fail!\n%%a
if not "!fail!"=="" "c:\utils\growl for windows\growlnotify.exe" /t:Build /i:.\red.jpg "!fail!"
if "!fail!"=="" "c:\utils\growl for windows\growlnotify.exe" /t:Build /i:.\green.jpg "All passed"

Visual studio passes the name of the DLL with the tests in the variable %1.  The batch asks mspec-cl4.exe to create an html report of the test results into specs.html (for later examination if needed), and also picks out the lines in mspec-cl4.exe’s console output containing “FAIL”.  Those lines are piped to fail.txt.
Next, it for loops through the lines in fail.txt and builds a batch variable called fail.  Each line in fail.txt is separated by a “\n” so that Growl puts each one on a separate line.  The !fail! syntax, alone with the setlocal EnableDelayedExpansion command, causes the batch processor to update the contents of the fail variable each time through the loop.  The usual %fail% syntax won’t do this.
Finally the batch decides if there are any failures or not and sends the appropriate message to growlnotify.exe.
image
image
Now to learn VIM and be a keyboard junkie like JP!

Friday, April 27, 2012

I Can’t Say the Ford E-250 Is A Pleasure To Drive, But It Does Its Job Well

Ikea delivery will be $169?  Bah!  We can do better than that ourselves, right?  Let’s rent a van and go get the stuff ourselves.

Such was our plan one recent Sunday morning.

You can rent a cargo van at U-Haul for $19.95 plus $0.49/km.  Great, just $20!

Wait, what’s that small print?  Oh, $0.49/kilometer.  It’s about 30 km to the Ikea in Etobicoke, so 30 km x 2 (there and back) x $0.49 = $29.4.

So we’re up to $50.

Our plan was to take the whole family to Ikea, have lunch there, let our son play in the kids area and get some big pieces of furniture.  If all went according to plan, we’d all drive to the U-Haul, I’d get the van, and we’d all drive on to Ikea.

Only, we’re a little behind schedule.  How to get me to U-Haul while mummy gets the kids ready?  Take a cab.

We’re now up to $75.

One could argue that this wasn’t a direct, unavoidable cost, but it is something I had to pay for in order to get this furniture.

At the U-Haul all went very well.  This was a Sunday and it was not busy at all.  The guy at the counter said that the previous day would have seen me waiting over an hour.  Pro tip #1: don’t rent at U-Haul on Saturday.

I decided to rent a dolly to move a big piece of furniture already in the house.  That’s another $7.  (Really?  A $40,000 van for $20, a $100 dolly for $7?  I think I’ll start a business renting just dollies.)

The U-Haul guy offered me some optional insurance on the van for about $17.  I had no idea if my car insurance or if paying by Visa covers me, so I bought that.

So all totaled, U-Haul will cost $20 + $30 (mileage) + $7 (dolly) + $17 (insurance) + HST = $83.62.  Add in the cab ride and our total so far is $108.62.

And I have to replace the gas I used before I drop off the van.  Yay.

Off to Ikea in a bill board on wheels on a windy day.  This isn’t a just a big minivan.  This is a Ford F-250 pickup-based, almost full lane-wide, 7 foot tall, 18 foot long monster.  Basic everything inside.  Geared and built for 1 thing – carrying a lot of heavy stuff from 1 place to another.  Totally exceeded my requirements.  I’d have been happy with a GMC Savana, or even just a minivan. But, it did have a line-in jack on the AM/FM radio.

The reason we chose the Etobicoke Ikea was the covered parking.  I hadn’t checked the dimensions on the van before entering the 9-foot limit parking garage, but it fit.  It quickly became obvious that I’d need to park far from other cars because of the tight spaces and corners.  Pro tip #2: when driving a new vehicle know it’s dimensions.

Shopping was ok, but the play area was full when we went to drop our son off, so there was much crying.  It was a little heartbreaking to have to tell him because we’d been mentioning it all day.  Ikea is really best visited with children on a weekday.

Ikea has spots near the door for loading your car, but in the covered parking you cannot back an 18 foot van into one of those spots.  Pro tip #3: stick to the uncovered parking with anything bigger than a minivan.  Or just wheel your purchases to your present, easily accessed parking spot.

Furniture loaded, we headed home.  Do not try to drive in anything but the right lane on the highway in a Ford E-250.  It really shouldn’t go above 110 km/h.  Anything more is a little hard to control.  It’s so wide that even the smallest variation can leave you too close to the next lane.  That’s how it felt, anyway.

By the time it was time to take the van back both children were fast asleep.  This meant I’d need another cab ride home.  Add another $25.  Replacing gas cost $20.

The final total for the day was $83.62 for U-Haul + $50 for 2 cab rides + $20 for gas = $153.62.  We saved $15.38 over Ikea’s deliver cost.  On the plus side, we got the furniture on the same day.

This could be done for much less than Ikea’s delivery cost.  Eliminate the need for the taxi, research insurance coverage, won’t need the dolly next time.  Renting a smaller vehicle from a car rental place would probably help, too. Enterprise rents a GMC Savana/Express for $50, which includes 200 km. They’d probably pick you up, too.

By the way, I didn’t even need the dolly.  The thing I wanted to move was too big for it, and it came apart just like Ikea furniture.  Live and learn!

Thursday, April 26, 2012

A Wizard Should Know Better

http://www.youtube.com/watch?v=v7NzBTRzCkg

I recently quit at CIBC and started working at Evault.  This means that my wife and I lost our immunity to account fees, kind of like when Superman transformed into a normal human.  We already had a couple of President’s Choice Financial accounts so I decided to work towards closing the CIBC ones and use only the PCF accounts.  It’s been a lot more complicated than I thought.  And the reason should embarrass any developer:  our accounts have dependencies.

In programming, one aims to create a system where no one part knows anything about how other parts work.  This is so that you can change one part without other parts caring.  Changes are limited to individual parts and don’t ripple through the system.  Thus you create a system with few, if any, dependencies on parts working a certain way.

You know how it goes with banking, though.. Sure, employer, direct deposit my paycheque. Sure, insurance company, direct debit my premiums. Sure, bank, direct debit my mortgage. Convenience now, pain later as the dependencies pile up.

Some of these are probably unavoidable, and worth the hassle, like the mortgage payment, the paycheque and withdrawals for investing.  But that’s about it.  We really should be paying everything else as a bill monthly.  Companies don’t care where the money comes from, just that account 12345 is paid in full.

The dependencies can get created recursively on you, too.  Your employer passes on the account info to your benefits and group RRSP provider(s), so you have to update those.  Hopefully these are provided by the same company, and can be changed online.  Otherwise you have to call someone, and possibly send in a void cheque.

This money stuff is all virtual.  There is no technical reason for any of this to involve talking to humans on the phone, in person, or sending snail mail.  The reason that these settings typically aren’t available online is that the systems that process this stuff within and between companies is very complex.  This is because it’s been built up over 30+ years.  Electronic payment systems predate the web by a large margin.

Our transition from CIBC to PCF is so complex that I created a Trello (task management) board.  As I write this we’re at 10 tasks done, 7 pending.  Until we complete the process we have to auto-transfer money from CIBC to PCF so that there’s money for the insurance, mortgage, etc..  Programmers might call it a bridge.

The thing that makes this transition process possible is PCF’s ability to link accounts at other banks to PCF accounts, allowing you to transfer to and from PCF accounts.  I’m pretty sure this is available at other discount banks, like ING.  Why not at the main banks?  Not in their interest, plus it’s technically complex (though not impossible.)  This would be much, much harder if the switch were from CIBC to, say RBC.  There’s no way to pay your CIBC line of credit from an RBC account online.  You’d be forced to transfer your line of credit to RBC, or visit a CIBC branch once a month with an RBC cheque.

So, do yourself a favour and limit the dependencies on your big-5-banks accounts to paycheques, strict-deadline payments like mortgages, and accounts at other banks between which you transfer money, like investment accounts.  And transfer to a low cost bank like PCF.

Keep your accounts agile.

The Truth Come Out

A few days ago:

Me:  “Should we have some of [3 year old] Ethan’s Easter chocolate?

Wife: with apparent shock, “Oh, no, that’s his chocolate.  If we want some we should just go to Mac’s.”

Me: “Ok, I’ll just have some fruit.”

Tonight:

Me: digging through the cupboard to find an empty Hershey’s Snapsy chocolate bunny box: “Mummy, what happened to Snapsy?”

Wife: sheepish grin.

Me: “His chocolate, eh?  At least he still has this other chocolate bunny.”