Friday, December 21, 2012

Dev Tools for Quick Mockups

Just so that I don't forget about it now:

  1. JSBin makes it easy to mockup some real HTML with some real JS and see the real result, then iterate through it with versioning.
  2. will take your Github gist and render it for viewing.  Here's the blurb:  "This is a simple viewer for code examples hosted on GitHub Gist. Code up an example using Gist, and then point people here to view the example and the source code, live!"

Friday, December 07, 2012

Color & Git Branch in your BASH Prompt

This one will be easy.  Place this into your .bash_profile:

This defines a function called "parse_git_branch", which reads the symbolic reference for the HEAD pointer (sending errors to /dev/null) and assigning the value to the "ref" variable.  Then, it echos the value of the variable, but filters out "refs/heads/" from the answer (See example 10.10 here at

After setting the value for some colors, it sets the first level prompt to print the current working directory in green and the git branch in yellow.


Test your webpages from outside of your domain

I love tools like Firebug and Chrome's Developer Tools.  But a tool originally developed at AOL and the open source has captured my attention:  Web Page Test does a great job of displaying all the nitty gritty details that are otherwise hard to get, such as DNS lookup time.  There are even developer tools with a RESTful API.

Highly Recommend

Thursday, December 06, 2012

Scrum Planning Poker for the Distributed Team

I've taken on the role of Scrum Master for our team and wanted to get everyone participating in issue scoping with independent votes.  So I searched for a Planning Poker scoping tool for distributed teams. The one I like the best is Pointing Poker.

It's free, requires no login, is very easy to use and effective.

One person logs in and starts a new session.  That person then distributes the URL with the session identifier to the rest of the team (we use Skype).  Everyone else then visits the site and enters their name.  No user account, no registration, no nothing.  From there it is easy to clear the last vote, have everyone vote and see the results. Want to change your vote?  Simply click on a different value.

Kudos for an effective tool.  Hey Matt Ruwe, if you were to put a donate button so I could donate a few bucks, I would.

Monday, November 19, 2012

Introducing the Mamo

A while back, I was considering the infinite.  I had some time on my hands, what can I say?

Infinity, as the saw goes, is really, really big.  You think you know big?  You don't know anything.  Aunt Bertha's behind? Insignificant. The Earth?  Pish.  C'mon: the Milky Way galaxy is the smallest starting point with some 200 to 400 billion stars.

OK, now we're starting with something: a Billion.  A 1 with 9 zeros: 1,000,000,000.  We have 200 to 400 of these Billions when we count the stars in the Milky Way. And there may be some 100 Billion galaxies.  That's 100,000,000,000 galaxies times 300,000,000,000 stars per galaxy!  That's a lot of stars, but we can think of even bigger things!

OK, let's get sexy.  From 2010, in the Huffington Post, Scientists believe there may be up to 300 Sextillion stars -- that's 1 with 21 zeros: 1,000,000,000,000,000,000,000.  You know, typing that is quickly going to get boring.  We're switching to scientific notation: 1021.  But that's stars, not galaxies, so let's keep our units straight.  If each galaxy had about 300 billion stars, then it would be 1021 divided by 109, so we subtract exponents and get 1012.  Back to a Trillion.  Boring.

Wikipedia talks about large numbers, and we get up to funky numbers like Vigintillion (1063) and Centillion (10303).  Of course, there's also the Googol (10100) and the Googolplex (10googol).

But this really doesn't do it when one considers the infinite. Let's go back to the Billion; we can grasp that.  Try this on for size, you may have heard it: if you spent $0.25 every 15 minutes playing video games, then you, and everyone else in your 100 person company could play non-stop for nearly 7,000 years.  That's freaking big.  Or, you could buy 1/3 of a nuclear powered submarine.

Or, you could build 3 schools.  And hire 200 teachers and administrators. And build a police department and buy cruisers and all the nifty equipment. And a fire department with trucks.  And hire 60 police officers and 30 fire fighters. And build a hospital.  And staff it with 40 doctors and 80 nurses. And hire 50 engineers.  And build houses for all of them.  And pay their salaries.  For over 14 years..

Or buy one B2 Stealth Bomber.

OK, that's helped me tremendously with one Billion.  One.  Just one.

We think there are a Trillion (that's 1,000 Billion) galaxies.  Each galaxy with 200 - 400 Billion stars.  And that doesn't even do the infinite justice.

No, we need another number.  That Googol doesn't help us either.  Psh, it has only 100 zeros in the exponent.  No we need something really massive.

So, I invented a new number:  The Mamo.  The Mamo is 101,000,000,000.  Yep, 10 raised to the Billion.  Now that's a number.  Now we can think about a Mamo sub-atomic particles in the conceivable universe and really expand our concept of wicked big.

But for the infinite, we need even more: We need the SuperMamo.  That is MamoMamo.  Yes, a Mamo raised to the Mamo.

Phew.  I need to rest.

Tuesday, October 16, 2012

ActiveRecord, JSON & hashes

While testing a new script for some data loading, I found myself on our testing platform and stymied because the foundation things I needed were not part of that database.  I needed certain license records and Forge records.  While the staging system has a more or less complete copy of our production system, the testing system has a much more constrained data set.  This is a one of my bugaboos: making sure there is sufficient data for testing. And, once again, I questioned the decision to NOT use TDD for the script development.  That way, I could have mocked all the scenarios I needed and probably would have completed the script in less time to a greater level of quality.  But I digress.

I was in the console of the testing environment (not the "test" environment) and needed to have a particular license as part of the testing dataset.  I wanted to use the tools I had, not have to write a migration, start up PSQL, or any of those pathways.  I wanted to be lazy and get the record from the staging environment and copy it into the testing environment.

So, I found the license in the staging environment and converted it to json with license.to_json. That was wicked easy.  The next step was to parse the JSON, which will convert it to a hash, then extract the license value. That looks like this:

license_hash = JSON.parse(json)['license']

The result was a pretty little hash with all the necessary data that could be copied from one console to the next and then pasted into place.  In no time at all, I had the needed record in the testing database.

Wednesday, October 10, 2012

Nil Object in Reality Land

Recently I was reviewing some code with a colleague; we were looking at some new widget code.  We switched to the branch and started our server.  Looking at the first randomly selected project, everything looked good, so we copied the widget code and took a look at what the user would actually see.

Problemo.  The user was going to see a 500 message through the tiny view port of the widget.

The problem was that there was code looking for the filename of the project logo in order to display the logo.  However, this particular project did not have a logo.  So, project.logo (which was nil) caused a problem when the code then sought to access project.logo.thumbnail.  Boom.  No method "thumbnail" on NilObject.  heh.

Looking at the code, the obvious pattern would have been to do something like:

if project.logo && project.logo.thumbnail

But this is cowardly, timid code and I have been influenced by Avdi Grimm's thoughts on Confident Code. Once it was pointed out, it was clear that I was never very enamored with all those protective "if this and if that and if the other thing, then and only then do something".  I really like the idea of writing code that knows how to handle itself.

My colleague and I decided to address the issue by using a NullObject pattern. Examining the code, we saw that we could have a NullLogo object that responded to a "public_filename" method and if the project had no logo, it would return the NullLogo object instead of a Logo object.  The NullLogo#public_filename method returns "no_logo.png" and so we are always guaranteed to show something reasonable.

We eliminated quite a number of lines of timid code and were very pleased.

So we pushed our code onto the staging server and looked.  Yes, the empty logo behavior was correct. So I deleted a logo from an existing project, something that can easily be done by our users.  Boom.

Digging in we saw that the Logo derived from Attachment and Attachment did magic things.  Including using a gem that managed file sizing and thumbnail generation and pushing logos to S3.  A former colleague implemented clever logic to put files in the local filesystem during development and on S3 during production; all quite reasonable.

But, deleting the logo did not trigger the cascade of cleanup; the author of the gem had no support for cleaning up attachments and all the thumbnails it had created.  Now the database had data about attachments that did not exist and S3 had files of logos that no one would ever see or even want again.

It turns out that this is the behavior that has been present in the system for ages.  Our use of TDD and careful testing revealed this problem that no one has notice although this functionality has been in the product for a long time.

To wrap up the story; we implemented functionality to clean up the database and left it as a future exercise to clean up the logos from S3.  After all, these are a tiny fraction of the storage we use there, so let's not get side tracked by the bicycle shed when we have a nuclear reactor to build.

Tuesday, October 02, 2012

SSH to VirtualBox Guest in Mountain Lion

My development system is OS/x 10.8, Mountain Lion.  I run Ubuntu 10.04 LTS Server in a VirtualBox VM and all the development work is done in that server (easiest for the entire team to ensure we all have the same dev environment).

I switched over from a desktop system (Mac Pro) to a laptop (MacBook Pro), copied over my .vbi file with my Ubuntu server and something was different.  I had been ssh'ing into the VirtualBox guest without any issues.  Set up my ssh keys and an alias.  Sweet.  But, with the laptop, I couldn't get there from here.  The host name couldn't be resolved.

Yes, VB Network mode was Bridged Adapter.  At first, the issue was waiting for the DNS servers to refresh the IP address of the guest OS, which was now on a different subnet because I was connecting over Wi-Fi instead of Ethernet.

But, after closing the laptop for the night, the issue was back and I knew it wasn't from switching subnets.  A clue was that I couldn't also connect to one of our development utility servers.  Checked wireless -- default configuration had wireless connecting to the guest Wi-Fi and not the corporate Wi-Fi.  Fixed that, but no love.  Flushed the DNS cache and voila; ssh to the guest machine.

Here's the key: on Mountain Lion use:

sudo killall -HUP mDNSResponder

dscacheutils is still present, but doesn't work in all situations.  Use the mDNSReponder.

Tuesday, September 25, 2012

Nifty VIM stuff

I've been building some of these techniques over time as I move from TextMate to VIM. Today, I came across the venerable "Seven habits of effective text editing" by Bram Moolenaar, who is the primary author of VIM and wrote this post, ah, 12 years ago now.

Please feel free to help yourself to my dot_vim repository on github, which has my working vimrc and plugins

Here are some of the wicked good things I've come across:

  • Windows.  One of the biggest drawbacks to TextMate was the one window thang.  
  • To create a new window in VIM do:
    • Ctrl-W S (for Split): creates a horizontal split
    • Crtl-W V (for Vertical): creates a vertical split
  • To navigate between windows, use Ctrl-W plus the navigation keys h,j,k,l
  • To close a window, use Ctrl-W C
  • Tabs.  Tabs are collections of windows.  All tabs have access to all the buffers, so you have access to any open file from any tab
  • To create a new tab do :tabnew
  • To close a tab to :tabclose
  • To move to a tab use:
    • :tabnext
    • :tabprevious
    • :tabfirst
    • :tablast
    • :tabmove
    • My .vimrc has some mappings for these
  • To reposition the buffer in the middle of the window, simply press 'zz'
  • Here's the one that got me really, really excited.  For searching, I've been using the standard '/' thing.  Well, check this out; you can simply put the cursor on the word for which you are looking and press '*'.  Yep, pretty nifty.
  • Block Comment / Uncomment.  This is the shizz:
    • To block comment, use Ctrl-V to enter Visual Block mode.  Navigate across all the lines you want to comment out, then use I  ESC to insert comment characters.  I just did this in SQL to insert "-- '
    • To uncomment a block, use Ctrl-V to enter Visual Block mode.  Navigate across all the comment characters, then use d to delete.  Voila!
  • To combine two lines: position the cursor at the end of the top line and press "J" to delete the newline
  • From Vim, you can run the current buffer with :!ruby %
  • Special for Rails: I added the command-t plugin for quickly finding your favorite file.  Sweet.

Tuesday, August 28, 2012

Ruby & Rails Tools: Pry, Guard, Spork, RubyFiddle, Null Object Pattern

Here are some Ruby and Rails things that have caught my attention.  In the interest of sharing and documentation, in no particular order:

Pry is a powerful alternative to the standard IRB shell for Ruby.  I learned about it at CodeSchool, on one of the Code-TV videos.  Pry provides source code and documentation browsing, the ability to live edit defined methods, syntax highlighting, command shell integration and other things of goodness.

Also recommended is the CodeSchool Code-TV episode on Guard and Spork, which look like a great 1-2 punch for driving TDD.

From a recent Ruby MeetUp at the Punchbowl  place in Framingham (thanks for the hospitality, pizza and beer!), I picked up these two tidbits:

RubyFiddle is a website that lets you try out Ruby code in the browser and save snippets as gists.  It lines up nicely with my personal philosophy that to be a great ROR engineer, one needs to be a great Ruby engineer. RubyFiddle has easily selectable key bindings for none, vim or emacs, which I find rather considerate and helpful.

I also learned about the Null Object Pattern, which has some compelling features and deserves to be in the toolbox of the enlightened engineer.

Sunday, July 15, 2012

Emre Sokullu Advice on Getting New Product Started

Along the lines of "Getting Real", this is an excellent set of advice for getting a new product started: "How to Create  Minimally Viable Product", by Emre Sokullu, founder and chief architect of

Sunday, May 20, 2012

What can you do to help?

This is one if the most difficult things that I have to write. Nothing to do with technology, software, process or products. Far, far more important. This is about a 13 year old girl who is in danger and being abandoned and endangered by the very systems that are in place to help her.

Everything here is my understanding and opinion. The facts come from the girls aunt, a friend of mine. I've not yet met this girl, but I know my friend and her family. I trust my friend and have confidence in the accuracy of the details she has shared. I am going to share them here, with the blessings and support of my friend and her sister, the girls mom.

I will refer to the girl as "B". Her mom is "D" and my friend is "P". B is 13. Her folks divorced almost a decade ago. Her dad, "S", has remarried. B has an older brother. I am told that B is popular in school, maintains good grades, is a very attractive girl, and is a cheerleader. B is required by the divorce documents to split her time 50/50 with her mom and dad.

She has stated that she does not want to spend any time with her father. All indications from this perspective is that B is regularly abused by her father, S. this abuse is most definitely psychological and physical. It may also be sexual.

The family lives in Florida. S's new wife is significantly more wealthy than D. S's new wife has even told B that she has given over $100K to S in legal help to fight D. The upshot is that D has been lambasted and pummeled in court. I don't have the highest degree of confidence in D's legal counsel, though P has said he's considered the best in the area, whatever that means. In any case, although B complains that she has her period every day that she is with S, although B had been whipped with a leather belt that left a wicked mark for over a day, although the school refuses unsupervised access to S, although B states that S and his wife confiscate her cell phone whenever she is with them and they scream at her all the time and restrict her contact with friends and mom and impose severe, punitive punishments for minor infractions, no one seems to be able to protect B and keep her away from S.

It seems that Judge H, who has been involved in this case for a while did a complete 180 not too long ago. He had issued orders that prevented S from having any contact with B. It seems that based upon a highly irregular psychological report, Judge H reversed himself and gave S full control over B 50% of the time.

And B is suffering. Inexplicably, neither the Department of Protective Services nor a crisis center were effective in protecting B when she came to school branded with the huge welt from S's belt and buckle. B is in danger. She needs help. She needs someone or some group to dig into the specifics of her case. She needs to be kept away from S.

Tuesday, May 08, 2012

Mantra for Outstanding Products

We demand excellence of ourselves and look for it in our colleagues because we know that outstanding results require outstanding people making outstanding efforts.

Wednesday, January 04, 2012

Nice Step Forward for VirtualBox

I just downloaded version 4.1.8 of Oracles VirtualBox Manager and was delighted to see that it offered to download the extension pack and install it for me.  That was always a bothersome additional step that needed to be done and bringing that into VirtualBox improves the usability of the product.  Also, this encourages me to stay more current with updates, since the update process involves "manually" downloading and installing one file instead of two. 

Nice improvement and an "Attaboy" to the VirtualBox developers!