Update Mac OS X time from command line

You can update the time on your Mac using the following command:

date 0926095012

For 26th September, 2012, 09:50am.

Note: You may need to run this with sudo.

Where the digits are: mmddHHMMyy

mm => month

dd => date

HH => hour

MM => minutes

yy => year

Display number of processes per user on Linux

$ ps aux | cut -f1 -d ‘ ‘ | sort | uniq -c | sort -r -n
352 root
142 bob
139 dave
138 paul
1 rpc
1 ntp
1 nscd

Hide Gmail’s “Consider including” using Chrome and AdBlock

If you want to hide Gmail’s annoying “Consider including” feature you can do so by blocking it like it’s an ad.

Step 1. Get Chrome and Chrome AdBlock

Step 2. Right-click the red stop icon for AdBlock and click Options

Step 3. Click Options and Edit your manual filters.  Paste in the following:


My coffee grinder

For Christmas I got a coffee grinder as a present.  Having looked at numerous models both electric and manual we opted for a manual grinder.  This was principally as reviews tended to be a bit up and down even on popular electric grinders, and getting them in the UK is quite difficult.  I opted for this:

Shown next to our crappy kettle for comparison of size.  Actually it’s probably slimmer than it looks.  It’s from Amazon:


Like all the best stuff, it comes from China and ALL of the instructions are in Chinese.  Configuring it isn’t rocket science though.

Part of the reason I went for this was it was the canonical burr grinding element bit, which is supposedly the best type.  I can vouch for the quality of the grind as I set to “notch 3” on the first grind, and it came out like powder (suitable for Turkish/Greek coffee I’d imagine).  I now use it on “notch 10” and there’s probably 20-25 notches in total, configured by a three wing nut on the bottom of the black bit.

This is what the innards look like:

And this is what a canonical burr looks like:


I don’t clean it every day as it seems to keep reasonably clean of its own accord.  That’s with about a week’s worth of debris on it.

Part of having good quality coffee isn’t just grinding it, however, it’s keeping the coffee fresh in the first place.  For that I bought some airlock bags from Lakeland, which come with a plunger to suck the air out.  I apportion my coffee into a single cup’s worth and put it in separate bags.  For my large cup it’s 8 grams of coffee beans, so I had to buy some relatively accurate scales too (also from Lakeland).


Vim perl-support error: “Global template file ‘/usr/share/vim/vimfiles/perl-support/templates/Templates’ not readable”

Recently I’ve installed the perl-support plugin for vim.  However having installed as instructed I got the following error:

“Global template file ‘/usr/share/vim/vimfiles/perl-support/templates/Templates’ not readable”

As I don’t really want to mess with settings for everyone I pointed vim at the local version by added a line in .vimrc to set the global variable:

let g:Perl_GlobalTemplateFile=’/home/YOURLOGINNAME/.vim/perl-support/templates/Templates’

Note that ~/.vimrc didn’t seem to work for me.

My fictional blog – The Diary of a Telecommuter

Recently I have been inspired to write some fiction, which takes the form of a diary.  If you have a Kindle you can subscribe here:

Alternatively you can read it online here:

The Diary of a Telecommuter

To be clear: it is ficitonal. :-)

Getting Things Done – command line

Today as a quick aid to tracking some tasks I wrote a ‘getting things done’ style program in perl.  I can’t boast that it’s sophisticated, but it can be found on github here:


Checkers – Trading Positions

I’m often conscious while playing of the value of men further towards the king row than in the ‘home’ position.

Take the fictitious example below.  Red has the option to either (A) swap men to get nearer a king, or (B) swap men with white’s man near its king line.

Assuming only moves A and B are in consideration, which would you choose?

For me, choosing move A is pretty tempting.  You’re getting pretty close to a king, which will force white’s man on white’s second row to have to move.

Move B has more subtle benefits, however.

Firstly, the utility of red’s two back men has very little value.  They’re not causing much of a headache in preventing white getting kings.  The best red could hope for is white getting a king to the left behind man ‘B’, allowing red to move its first line man to exchange a king for a man.  Assuming white is a reasonable player, this isn’t very likely.

Secondly, getting nearer to the end of the game, it’s likely red’s men on its first and second row are going to need promotion to kings.  They’re a long way off that.

Thirdly, and most importantly, red has the opportunity to effectively ‘gain’ moves.  Consider white’s man that red can exchange.  At minimum it has cost 2 moves to get to its current position.  Consider red’s man B, which has cost at most 1 move to get to its current position (2 moves once exchange takes place).  If red can exchange men, it has a net effect of having gained 1 move, as the red man on red’s first row moves 2 places (jumping white’s exchanged man).  The likelihood is white’s man could have moved more than 2 places, effectively making the gain greater.

For homework, consider the costs associated with move A.

So when playing, it’s worth considering the value of the pieces you’re moving.

Perl convert RGB to hex HTML color

Converting RGB to hex just involves understanding the decimal representation of RGB. See below for a small perl procedure.

sub RGB2Hex
my $r = shift;
my $g = shift;
my $b = shift;
my $dec = 0;

$dec += 256*256*$r;
$dec += 256*$g;
$dec += $b;

return sprintf(“%.6x”, $dec);

Use CASE statement in SELECT in MySQL

Sometimes you might want to replace numbers with an enumerate value.  Let’s take an example with a BIT field for HasChildren.

SELECT Name, IsParent
WHEN HasChildren=1 THEN ‘Parent’
WHEN HasChildren=0 THEN ‘Not parent’
ELSE ‘Unknown’ END AS IsParent
FROM Person