Why you don’t get mock objects

Why you don’t get mock objects

Fascinating talk by Gregory Moeck from RubyCon 2011

While this deals quite a bit with TDD and mock objects, it’s also largely about a particular style of OO design, one that reminds me a lot of some of Allen Holub’s writings. It’s not very specific to Ruby (it has some examples in RSpec – that’s about the extent of the Rubyness).

Fixing VMware guestOS setting after the fact

I set up an OpenIndiana vm in VMware Fusion (see earlier post) but while setting it up, I accidentally selected “Other” for the guest OS type instead of “Solaris”. As a result, later on when I wanted to install VMware Tools, it wasn’t available in the menu because the system didn’t know which CD image to mount.

The fix was to edit the guestOS setting in the .vmx file.

But first I needed to figure out what the valid settings are for guestOS.

I took a clue from this page and did this:

$ strings '/Applications/VMware Fusion.app/Contents/Library/vmware-vmx' | egrep '^solaris[0-9]'
solaris6
solaris8
solaris9
solaris10-64
solaris11
solaris11-64
solaris10
solaris7

From this, I knew that I needed to put:

guestOS = "solaris11-64"

in /Users/marca/Documents/Virtual\ Machines/OpenIndiana\ Build\ 151a\ Desktop.vmwarevm/OpenIndiana\ Build\ 151a\ Desktop.vmx

Setting up OpenIndiana b151A

I’m in the process of installing OpenIndiana b151A in a VMware Fusion virtual machine.

Main reason is that I’ve become interested in DTrace and DTrace comes from the world of Solaris. OS X has DTrace too, but I’m noticing that it differs quite a bit from DTrace on Solaris, especially when it comes to developing with it — i.e.: instrumenting software with USDT probes.

OmniFocus sqlite completedDate

A while back, I posted about how OmniFocus maintains a sqlite database. This could be really interesting for writing software to do new stuff on that data.

Jared just dug into this and noticed that the completedDate field was an integer, but it did not appear to be a unix epoch time.

I just did a little experimentation and it seems that OmniFocus is setting dateCompleted to the number of seconds since Jan. 1, 2001 00:00:00 GMT.

I figured this out by setting my time zone in System Preferences to GMT and then I went into OmniFocus and created a task and set the completion date to “1/1/01 00:00:00″. Then in sqlite:

sqlite> select name, dateCompleted, datetime(dateCompleted + 978307200, 'unixepoch', 'localtime') from task where dateCompleted is not null;
...
Take clock out of Honda                 351241538.054  2012-02-18 07:05:38
Ate sushi                               351241498.856  2012-02-18 07:04:58
Order replacement light bulb from Amaz  351241558.269  2012-02-18 07:05:58
Test -- item completed on 2001-01-01 0  0              2001-01-01 00:00:00

and after setting my timezone back to GMT-8:

sqlite> select name, dateCompleted, datetime(dateCompleted + 978307200, 'unixepoch', 'localtime') from task where dateCompleted is not null;
...
Take clock out of Honda                 351241538.054  2012-02-17 23:05:38
Ate sushi                               351241498.856  2012-02-17 23:04:58
Order replacement light bulb from Amaz  351241558.269  2012-02-17 23:05:58
Test -- item completed on 2001-01-01 0  0              2000-12-31 16:00:00

bash: Displaying the time at which historical commands were executed

Yesterday’s find. This will be indispensable the next time I wonder how long a command took which I forgot to time. Or the next time I want to know when a certain change went into effect.

$ HISTTIMEFORMAT="[%s] [%Y-%m-%d %H:%M:%S] " history 5
  653  [1329580687] [2012-02-18 07:58:07] sleep 5
  654  [1329580693] [2012-02-18 07:58:13] date
  655  [1329580698] [2012-02-18 07:58:18] sleep 5
  656  [1329580704] [2012-02-18 07:58:24] uptime
  657  [1329580709] [2012-02-18 07:58:29] HISTTIMEFORMAT="[%s] [%Y-%m-%d %H:%M:%S] " history 5
marca@scml-marca:/usr/local$ HISTTIMEFORMAT="[%s] [%Y-%m-%d %H:%M:%S] " history 100 | grep brew
  571  [1329173341] [2012-02-13 14:49:01] mv /Users/marca/perl5/perlbrew/perls/perl-5.15.6/bin/tarcolor /Users/marca/perl5/perlbrew/perls/perl-5.15.6/bin/tarcolor~
  574  [1329173354] [2012-02-13 14:49:14] brew uninstall tarcolor
  585  [1329173533] [2012-02-13 14:52:13] brew install -v tarcolor
  586  [1329173547] [2012-02-13 14:52:27] mv /Users/marca/perl5/perlbrew/perls/perl-5.15.6/bin/tarcolor~ /Users/marca/perl5/perlbrew/perls/perl-5.15.6/bin/tarcolor
  642  [1329528177] [2012-02-17 17:22:57] brew outdated
  643  [1329528194] [2012-02-17 17:23:14] brew home bdw-gc
  644  [1329528223] [2012-02-17 17:23:43] brew upgrade
  651  [1329580648] [2012-02-18 07:57:28] HISTTIMEFORMAT="[%s] [%Y-%m-%d %H:%M:%S] " history 100 | grep brew

Discovered this at http://stackoverflow.com/q/1862510/638434 while looking up how to add the execution time of the last command to the bash prompt. There is a nice tip there for doing that as well as adding growl notification for long-running commands.

Here’s the former in action:

marca@scml-marca:/usr/local$ export PS1='[last: ${timer_show}] '$PS1
[last: 0] marca@scml-marca:/usr/local$ date ; sleep 60 ; date
Sat Feb 18 08:23:29 PST 2012
Sat Feb 18 08:24:29 PST 2012
[last: 60] marca@scml-marca:/usr/local$ uptime
 8:27  up 4 days, 18:47, 3 users, load averages: 0.02 0.10 0.13