Macbook Air’s SSD died – here’s my new backup strategy


My mid-2011 Macbook Air‘s SSD died last week. I’d spent a lot of time setting this up just how I wanted: dual boot OSX and Win 7 (then Win 8) – 50Gb for each OS, and a 150 Gb shared exFat “Data” partition which is writable by both OS. The Data partition contained all my music, photos, and source code.


My backup strategy was:

  1. OSX backed itself up automatically to my Time Capsule using Time Machine.
  2. Windows I never backed up because I don’t mind re-installing a new Win machine in the event of failure since it’s a good chance to start from scratch and get rid of old crap – old versions of Visual Studio etc.
  3. The Data partition – the most important one – I backed up manually both to my Time Capsule’s shared network disk and an external USB drive, using Syncback Free. I’d usually do this once or twice a month.

I’d had an inkling that the SSD was about to die for about a week before – every morning on boot the Mac would display a flashing question mark icon. Usually it would boot OK on the second or third attempt. Until it didn’t (on my birthday, no less)…

Cue the usual ranting and gnashing of teeth. Every day I’m not working is a day I’m not getting paid (contractor, ya see). All of the Mac service centres in London promised a 3-5 working day turn around, because they would have to order in a replacement SSD. Which means I’d have to make an appointment with the dreaded Genius Bar since they probably would have the part in stock.

The staff at the Genius Bar are always great, but I HATE the process you have to go through to see them – booking an appointment online. To cut a long story short, I was able to get a walk-in appointment later that day, and because I had AppleCare (which I bought specifically because SSDs are unreliable), the £600 replacement part cost me £0. But it still cost me a day’s productivity (and pay!).

In terms of lost data, not a lot. I lost a Linux VM which I could rebuild in about a day. Source code is on git / svn servers so none. Personal data – some photos of a trip to Portugal but I was able to get lower res copies of most of them from Facebook.

Since then I’ve changed my backup strategy slightly, so as to avoid downtime, by embracing the Mac way of doing things:

  1. No more dual boot – I’m gonna run Windows 8 in VirtualBox when the need arises
  2. Everything is on the one Macintosh HD partition. However, old habits die hard – I still have the content of my old “Data” partition located at /Data on that hard drive, organised how I like it to be and not how OSX wants me to have it organised.
  3. Time Machine + Time Capsule now backs up everything automatically when I get home.
  4. Super Duper backs up and creates a bootable version of my Macintosh HD on an external USB drive. This means that if my SSD dies again, I can boot straight off the USB hard drive and carry on working. At the moment I’m doing this every night, which takes about 20 mins (using the Smart Copy – I purchased a license). But if I think about it, once a week or so should be adequate since my personal files should be getting backed up by Time Machine, and I usually commit / shelve source code every night.

I still feel a bit uneasy about running Windows in a VM, but lately I’ve only been using OSX at work. I’ll see how it goes when I start coding in .NET again in a few weeks.

Book review – Instant Meteor Javascript Framework Starter

Leave a comment

Last year I started playing around with Meteor, a new javascript framework. I didn’t get much further than playing with and tweaking sample applications.

When it came time to start creating my own app in Meteor though, I was a bit lost. I didn’t really know where to start.

I was given a copy of Instant Meteor Javascript Framework Starter which I read over the weekend. The book was a good read – I especially enjoyed the opening chapters which covered what Meteor is and why it’s cool, better than the official Meteor docs cover.

It covered all the Meteor basics well, and I would recommend the book to anyone who wants to get started building their own app with Meteor. Reading it has gotten me excited about Meteor again!

RavenDB – Input string was not in a correct format

Leave a comment

In a RavenDB ASP.NET MVC app I was recently working on, I was constantly seeing good ol’ System.FormatException – “Input string was not in a correct format”.

My entities all use ints for their Ids.

After a while I noticed (via the RavenDB Management Console) that my entities had Ids like “tab/123″, but previously the Ids were like “tab-123″.

The problem turned out to be that I had accidentally removed this line while doing some refactoring:

documentStore.Conventions.IdentityPartsSeparator = "-";

Once I put that back in I stopped seeing the System.FormatException and all was right in the world.


Retrieve child items with an integer ID in a many-to-many with RavenDB

Leave a comment

I have a many to many relationship, like so

public class Movie
   public int Id { get; set; }
   public string Title { get; set; }
   public int[] ActorIds { get; set; }
   // etc

public class Actor
   public int Id { get; set; }
   public int Name { get; set; }
   // etc

When I load a Movie, I also want to load all of the Actors associated with that Movie.

This can be done using Raven’s Load<T>(IEnumerable<System.ValueType> ids) method, and casting the int[] to an array of ValueType, like so:

var movie = RavenSession.Load<Movie>(movieId);
var actorIds = movie.TabIds.Cast<System.ValueType>();

var actors = RavenSession.Load<Actor>(actorIds).OrderBy(x => x.Name);

Upgrade a Macbook with Boot Camp from Windows 7 to Windows 8 Pro


I have a mid-2011 Macbook Air running both OSX Lion and Windows 7 using Boot Camp.

Over the weekend I upgraded it to Windows 8 by doing the download only installation. The process was quite simple and it worked fine. Here’s the steps:

  1. Boot into Windows 7
  2. Go to and click “Buy Windows 8″. Download the installer and start it up.
  3. Pay! The installer will ask for you billing details, credit card / debit card / Paypal details etc. At £25 I thought it was a cheap enough upgrade, especially since I would be going from Windows 7 Home Premium to Windows 8 Pro which means I’d get Remote Desktop etc.
  4. Wait half an hour while the installer downloads the OS.
  5. Once the install starts, it will ask you if you want to
    1. Keep all your programs and your personal info and settings
    2. Keep your personal settings only
    3. Keep nothing. I went for this option as I always like to start fresh.
  6. Now I had a few problems. The install demanded that I have 20Gb free on my C: and I only had about 5 Gb free. I had to stop the installation to free up some disk space. I did this by:
    1. Running Disk Cleanup
    2. Disabled Virtual memory, which shrunk the pagefile.sys from 4Gb to 0Gb.
    3. Disabled hibernate, which removed the 4Gb hiberfile.sys
    4. Deleted c:\Windows\TrustedInstaller folder – but that was a mistake, because then I couldn’t uninstall any programs to free up the necessary space!
    5. Since I was choosing to keep nothing on C: anyway I deleted folders willy-nilly from C:\Program Files and C:\Program Files (x86)
  7. After that I was able to continue the installation which took another 20 mins or so. It rebooted 3 or 4 times, during which  I had to hold down the Mac’s option key at boot and choose the Windows partition.
  8. All done! Windows 8 works fine.

Once it was installed I did a couple of clean-up tasks.

  1. My C: was almost full again, because the install had backed up everything in the C:\Windows.old folder. So I ran Disk Cleanup again and clicked the “Clean up system files” button to remove those.
  2. I no longer had Apple’s Boot Camp drivers installed in Windows, so I had boot into OSX, start the Boot Camp helper and copied the Boot Camp drivers to a USB memory stick. Then rebooted into Windows and installed those drivers. Worth doing so that the Mac’s hotkeys (volume up/down, screen brightness etc) would work.

Regular expression replace in Visual Studio

1 Comment

I can never remember how to do replaces in Visual Studio using regular expressions, so here’s a quick example.

I’ve got 30 classes that implement BasePage. I want to change this:

public class VariationsPage : BasePage

to this:

public class VariationsPage : BasePage<VariationsPage>

The regex should find:

public class {.*} \: BasePage

and replace with:

public class \1 \: BasePage<\1>

Meteor todos sample – add buttons to move items up and down

Leave a comment

This is the sixth in a x part series about Meteor for beginners.

Let’s add the buttons to the UI first. I’ve decided to put them next to the delete button, so I will copy the html and css for the “destroy” class so that the UI is consistant.

<template name="todo_item">
  <li class="todo {{done_class}}">
    {{#if editing}}
      <div class="edit">
        <input id="todo-input" type="text" value="{{text}}" />
      <div class="move-up"></div>
      <div class="move-down"></div>
      <div class="destroy"></div>
#item-list .todo .destroy {
    cursor: pointer;
    position: absolute;
    margin-left: 50px;
    left: 5px;
    top: 15px;
    height: 20px;
    width: 20px;

#item-list .todo .move-up {
    cursor: pointer;
    position: absolute;
    left: 5px;
    top: 15px;
    height: 20px;
    width: 20px;

#item-list .todo .move-down {
    cursor: pointer;
    position: absolute;
    margin-left: 25px;
    left: 5px;
    top: 15px;
    height: 20px;
    width: 20px;

#item-list .todo .display, #item-list .todo .edit {
    margin-left: 80px;
    height: 100%;
    width: auto;
    float: left;
    padding-top: 18px;
    line-height: 1;

#item-list .todo:hover .move-up {
    background: url('/arrowup.png') no-repeat 0 0;

#item-list .todo .move-up:hover {
    background-position: 0 -20px;

#item-list .todo:hover .move-down {
    background: url('/arrowdown.png') no-repeat 0 0;

#item-list .todo .move-down:hover {
    background-position: 0 -20px;

PS. I spent longer making the up down arrow icons in an image editor than writing the code for this post!

Items in each todo list are currently sorted by their timestamp:

Template.todos.todos = function () {


  return Todos.find(sel, {sort: {timestamp: 1}});

I will continue to use the timestamp to control the sort order. When the up button is clicked, set the current item’s timestamp to be 1ms less than the item above it. = {

  'click .move-up': function() {
    var todos = Template.todos.todos().fetch();
    var currentItemIndex = todoRanking(this, todos);

    if (currentItemIndex > 0) {
      var todoAboveMe = todos[currentItemIndex - 1];
      Todos.update(this._id, {$set: {timestamp: todoAboveMe.timestamp - 1}});
var todoRanking = function(todoItem, todoArray) {
  var ids = (todo) { return todo._id; });
  return ids.indexOf(todoItem._id);

We can do something similar to move an item down.

  'click .move-down': function() {
    var todos = Template.todos.todos().fetch();
    var currentItemIndex = todoRanking(this, todos);

    if (currentItemIndex < todos.length -1) {
      var todoBelowMe = todos[currentItemIndex + 1];
      Todos.update(this._id, {$set: {timestamp: todoBelowMe.timestamp + 1}});

See the code on github.

Older Entries Newer Entries


Get every new post delivered to your Inbox.