Latest posts

Think like a git

While we’re on the subject of git… oh, what’s that? We weren’t? Never mind. While we’re on the subject of git, this looks like possibly the best tutorial on anything, anywhere, ever:

Think like a git

Terrific demo of the AJ Buildings Library

Basic git commands

I’m using my old Macbook which is still on OS 10.4, and was very happy to find a git binary already built for Tiger

And to get familiar with the basics, there turned out to be a really good tutorial as well as introduction to version control in general on A List Apart, Getting Started with Git

Here are the basic commands, which are all familiar from svn:

git init // creates an empty repo in the current directory
git status // lists any changes in the current directory
git clone  // creates a new local repo cloned from a remote one
git log // lists the recent changes from the current repo
git add // add a new file to the current repo, or add a modified file to the staging area prior to commit
git commit // commit changes

Getting started with Git

Well, I finally decided to spend a little while getting used to git, the distributed version control system originally written by Linus Torvalds for managing the development of the Linux kernel.

I’ve been aware of the rapid growth of interest in distributed version control over the last couple of years in particular. Being a relatively long-time user of subversion, I’ve taken the view that using any version control at all is the important thing and that which system you use is a secondary issue. I still believe that, but it’s also clear that people have been surging to the two new arrivals on the scene with startling enthusiasm. My reluctance to learn either git or Mercurial up till now has stemmed from two things:

Firstly, the fact that I am quite happy with subversion, and have no big unsolved problems with it. Spending time learning another vcs is just going to be time I’m not working on productive work…

Secondly, I’ve not been sure which of the two I might want to invest time in if I did learn one. Git is obviously the poster child of the open source movement; suddenly everyone and everything interesting you find is on github. But Mercurial has been adopted with massive enthusiasm by other parts of the developer community; Fog Creek loved it so much they just about dropped everything to write a hosted Mercurial product, because they believed it was so good everyone should be using it.

I have no opinion on which of the two is “better” than the other, if either. Obviously, they’re both good, they’re both better than subversion at making branching and merging accessible to ordinary joes like me, and they’re both good things to use. So how should one decide which one to learn?

Well, in the last few months it became clear that in my chosen sphere at any rate, git has been surging ahead in popularity and has gone past a tipping point where you’re expected to know it as often as not. I think subversion is going the way cvs did; a dying incumbent which was once the standard but which has now been superceded by newer and better technologies that are just, frankly, less of a pain in the ass to use.

In my case, the final stimulus turned out to be simple; I’ve applied for a contract with a development team, and they use git. So clearly, it’s time to learn it…

Ampersands, URL parameters and wget

So there’s this queueing system we wrote for the AJBL, which racks up processor intensive tasks like image crunching to do them in the background. We add commands to a database table as URLs that get called with wget from the app in the background, and it all works remarkably well.

Except this time the command had ampersands in it. It worked every time when you called it directly, but from wget it failed to pick up the second and subsequent params. Just getting to this point took longer than I cared to think about, and because all this happens indirectly in the background, it was a nightmare trying to work out what it thought it was doing. I ended up writing a logger just to be able to find out what it was thinking when executing things in the background like this.

There went another good few hours of my life I won’t see again – this seems to be a common refrain nowadays! Once I found out what was happening, it wasn’t much longer before I tracked down the cause, and of course the marvellous Stackoverflow came to my rescue again

Because the wget command is being executed in the shell on the box in question, the ampersands in the URL are being interpreted by the shell instead of being passed to wget. Simply wrapping the URL in quotes fixes it.

$cmd = 'wget "' . $cmdURL . '"';

I don’t actually mind hitting problems like this; the satisfaction when you solve them is great. But it makes estimating projects even more of a joke than it already is, and the loss of momentum is horrifying.

Another picture that kind of says it all


Steve Job’s 2005 Stanford Commencement Address

Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure – these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.

Full text here

Stay hungry. Stay foolish.

Steve’s last keynote

steve applause crop

On June 6, 2011, Steve Jobs took the stage at the Moscone Convention Center in San Francisco to a rapturous round of applause that lasted almost a minute. I was watching online, like many thousands of others, sometime after the event – but for us it was as though we were there. We didn’t know for sure, though some of us watching were pretty sure, this was us saying goodbye. I think he knew it was the last time he would stand on the stage before an Apple audience.

I was shocked at how frail he had become, though John Gruber writes movingly of how his eyes still held their their weapons-grade intensity.

Anyway. I was just watching it back just now, feeling like I wanted to see him again, and I noticed the iPad in the foreground shown above. I couldn’t quite work out what it was until I went back and hit pause. An attendee was using Facetime to share the back camera on his iPad 2 so that their friends or colleagues back home could experience the event too.

In a sense, that summed up and validated everything the man was working towards. I mean, how fricking cool is that? Steve would have loved it, I’m sure.

“bindParam in a loop eats your data” shock

Well, there’s a couple of hours of my life I won’t get back.

So it suddenly seemed like a good idea to abstract the construction of PDO queries into a base class (since I had it anyway) and do a lot less typing. And it all works brilliantly, except as it iterates through the $data hash I’m giving it, somehow the last value gets used for all the columns I’m updating. Something wrong somewhere. So I check everything.

$query = $conn->prepare($queryString);
foreach ($data as $key => $value) {
    $query->bindParam(':' . $key, $value);




So two hours later, still no idea why it’s happening. Until I finally trawl StackOverflow and find the explanation – which is that bindParam binds by reference to a variable, not by value. So the last $value used is the one evaluated for all of them. Completely by design. You use bindValue instead, of course.

$query = $conn->prepare($queryString);
foreach ($data as $key => $value) {
    $query->bindValue(':' . $key, $value);

And the worst thing is I knew this already, and had forgotten. That happens a lot these days…

Steve Jobs 1955-2011


I first used a Mac back in 1985 as a student in Edinburgh, and fell in love with it. Since then the products, company and the ethos Steve Jobs created have constantly inspired and delighted me, as well as formed the foundation of my entire working career.

I have watched the stratospheric rise of Apple in the 21st century with amazement and delight, and every day I marvel at these most incredible devices it’s a privilege to own and use – the Mac, the iPad and the iPhone. It wasn’t hyperbole – they really are insanely great, and the best thing about watching Steve’s product announcements was the sheer infectious joy he found in the things Apple created.

I am sure Apple has a great future ahead of it – I am sure much of Steve’s efforts went to building a company and a culture which would continue on beyond him – but I can’t help wondering how much better still it would be if Steve were to be with us for another twenty years.

More importantly, however much a perfectionist or demanding task-master he was, he always seemed to be a profoundly decent man who was loved and respected by many. It is the family man I think of now, and my thoughts are very much with his wife and family.

The world will be a much less interesting place without him in it.

About Verso Systems

Formerly zStudio, Verso Systems builds great web applications. Our founder and chief technologist is Ian Anderson, who was previously technical director for The First Post and Dennis Interactive, the digital division of Dennis Publishing. We specialise in creating highly usable, useful applications using PHP, JavaScript and related technologies, and are always open to discuss projects or consulting opportunities.