iOS5 installation -5000 error

Whilst trying to update my daughter’s iPod 4 to iOS5 I had the following error:

An error occured while backing up this iPod(-5000). Would you like to continue to update this iPod?

Continuing will result in the loss of all contents on this iPod.

That doesn’t sound good… I then remembered that we have restrictions enabled on this iPod as my daughter is only 6 so no internet, app store, etc. I disabled restrictions and tried again and it has worked fine this time. The only other thing I did was close any open apps. I don’t know, perhaps turning the iPod off and on again would have had the same result, but this worked ok here.



A little while back a friend of mine Anthony Casey decided to make an iOS friendly HTML5/CSS3 based clock similar to the Flash based The Colour Clock. This is a digital clock where the background colour changes with every second of the day. You can view the completed HexaClock here, though you will need a HTML5 browser (no Internet Explorer 8 or below I’m afraid).

Anthony is a whizz with all things HTML/CSS, and asked me if I could help out by coming up with some JavaScript to make the clock change colour and tell the time.

Figuring out which colour to show

First things first, how do I make every second of the day a different colour? As we know the current time of day is made up of three parts, hours (0-23), minutes (0-59) and seconds (0-59). Luckily for us colours on the web are also made up of three parts, combinations of red, green and blue (known as RGB). The amount of each colour to use is a value between 0 and 255, e.g. 255 red is solid red, 0 red is no red at all, and 128 red is a dark maroon type colour. Using this knowledge we can create colours and shades, for example:

Red – R:255 G:0 B:0
White – R:255 G:255 B:255
Black – R:0 G:0 B:0
Yellow – R:255 G:255 B:0
Purple – R:195 G:48 B:255

It’s kind of like the opposite of mixing paint – here mix lots of each colour and you end up with white instead of a mucky browny black colour. There are plenty of sites out there that explain RGB colours in more detail.

How much of each colour to use

The amount of red to use maps to the hour of the day, green to the minute in the hour, and blue to the second in the minute. Using the actual value of hour, minute and second would result in lots of dark colours as we would never get a number higher than 59, so instead we will figure it out as a proportion of 255:

Red = (hour / 24) * 255
Green = (minute / 60) * 255
Blue = (second / 60) * 255

Making it tick

With the colour problem sorted the next step is to make the clock update every second. I created a “tick” function to show the current time and the appropriate background colour. To make it update once a second the JavaScript setTimeout function was used to call “tick” again after 1000 milliseconds.

Web browsers prefer their colour values represented in hexadecimal so the numbers need converting first. After first looking at writing a small decimal to hex conversion function I realised there was no need as I could use a nice feature of JavaScript to specify which number base to use when converting a number to a string, e.g. 15.toString(16) = “f”. This should actually be “0f” so the fix2 function tidies up any one digit hex values.

Here is the full code:

function hexClock(bodyId, clockId) { this.body = document.getElementById(bodyId); this.clock = document.getElementById(clockId); this.running = false; this.fix2 = function (n) { return (n < 10) ? "0" + n : "" + n; } this.tick = function () { if (!this.running) return; var now = new Date(); var h = now.getHours(); var m = now.getMinutes(); var s = now.getSeconds(); var hexH = Math.round((h/24) * 255).toString(16); var hexM = Math.round((m/60) * 255).toString(16); var hexS = Math.round((s/60) * 255).toString(16); = "#" + this.fix2(hexH) + this.fix2(hexM) + this.fix2(hexS); this.clock.innerHTML = this.fix2(h) + ":" + this.fix2(m) + ":" + this.fix2(s); setTimeout(function(me) { me.tick(); }, 1000, this); } this.start = function () { this.running = true; this.tick(); } this.stop = function () { this.running = false; } } // this bit runs when the page loads function init() { var clock = new hexClock("body", "clock"); clock.start(); }

Probably not the best bit of JavaScript that you will ever see but it does the job. At some point I might rewrite it using the Prototype approach.

Bye bye Windows? Not quite…

Back in my CompSci days the computer labs were Sun machines running Solaris, so I picked up a sprinkling of UNIX knowledge whilst completing various C and ADA assignments. Other than that and a brief dual boot install of BeOS, I’ve been a Windows user since finally admitting that the Amiga wasn’t going to take over the world, and buying my first PC in 1994.

Fast forward to 2010, Ubuntu 10.04 LTS gets a great write up on The Register, so I’ve decided to have another look. I’m not quite brave enough to go for a true dual boot, but using WUBI to achieve kinda the same thing.

First impressions are great, the installation runs without a hitch and all the hardware on my laptop is detected and works. It’s much faster too than Windows, helped no doubt by not having to run anti-virus and all those task tray programs.

Software wise Firefox is up to date and it was simple to get Flash working. Being a Chrome fan I installed Chromium but it seems to render a lot of text too bold for my liking so I’ll stick with Firefox which seems to run faster than I remember, but that could be down to not having any add-ons installed. Gwibber and Empathy take care of the social networking side of things and I like the built in broadcast feature (now that I realise what it actually does).

The compatibility issues between OpenOffice and the corresponding MS Office apps have been well documented elsewhere, but it seems perfectly fine for my needs.

I admit have an ulterior motive for looking at Ubuntu; as a C# web application developer by day I want to mix things up for my hobby programming, so I’ve decided to learn how to make Ruby on Rails apps. I get the impression that it is easier to get things set up on Linux.

Having said that I’ve been so impressed with Ubuntu and how fast and stable it is that I’ve been using it daily as my main OS for the last couple of weeks. I’ve also replaced the XP install on my wife’s incredibly slow netbook and it now runs like lightening so double win.

I still dip back into Windows to sync my iPod with iTunes and when I need Visual Studio, and I’ll keep it for Picasa (for now, there is a Linux version) . I’m converted though, even if I won’t be saying goodbye to Windows just yet.