css (1) jQuery (7) linux (38) mac (70) php (29) python (1) svn/git (9) trac (4) ubuntu (1) virtualbox (6) vista (2) windows (14)

Monday, 28 November 2011

OS X Lion VPN server "Authentication failed"

When setting up a Lion VPN server if you get "Authentication Failed" when trying to connect (after putting in the user and password of a system account on the remote server) check to see if the shared secret contains a double quote " if it does remove it, that worked for me.

Thursday, 17 November 2011

iCloud calendar on iOS 4

To add an iCloud calander to ios 4 go to settings > mail, calendars, contacts > add new > other
For the domain put your icloud email for the username, your icloud password for your password then save. That's it!

Saturday, 29 October 2011

OS X Lion server install "Can't download Server Essentials because of a network problem." Error

I recently downloaded and tried to install OS X Lion server on my mac mini which a server, and when configuring it kept coming up with "Can't download Server Essentials because of a network problem." Rebooting no joy, resetting the routers/modem no joy, google brought up this  for some reason best known to apple if you create a new network location, copy your settings over and delete the old one it works fine, this fix oddly enough has been used to fix weird network issues before.

Friday, 28 October 2011

Windows Vista/XP and OS X Lion Filevault 2 driver issues

If you run windows vista/xp and can't upgrade to windows 7 for some reason, then boot camp with os x lion and file vault 2 won't work, you'll get a BSOD. This is due to the old boot camp 3 drivers which don't support the new partition types. Sadly boot camp 4 doesn't work with xp or vista.

The solution enter C:\windows\system32\drivers\ and rename AppleHFS.sys to AppleHFS.sys.old and AppleMNT.sys to AppleMNT.sys.old before you enable file vault this will prevent windows from trying to mount the mac partitions.

Sunday, 16 October 2011

Migrating my Mac with Lion and Windows 7 to a new hard drive

So as a treat to myself (and for a productivity boost) I decided to upgrade my mac book pro's hard drive to a seagate momentus XT 500GB hybrid drive.

Basically it's a 7200 rpm drive with a 4gb solid state bit that acts like a big cache.

Now I've never done this before so it was quite an interesting experience, here's how I did it.

1. Caddy for old hard drive, I used a USB SATA caddy, you'll need this to copy your data
2. Two writable CD store the firmware on and recovery software
3. Tools (see the ifixit guides for which ones)
4. A copy of OS X Lion burnt to dvd/usb stick (see
5. An external drive or a bunch of DVDs to store your windows backup on
6. Filevault is disabled (I didn't want to try this with it enabled)

The process:
1. Backup Lion using time machine.
2. Backup windows using some great software I found paragon backup and recovery free ( it's the only one I tried that would backup and restore windows on bootcamp successfully (more on that later), and create a backup recovery CD.
3. Download the latest firmware for the hard drive from seagate, this is quite important since they're have been problems with older firmware, at time of writing S28 is the current version. (
4. Burn the iso downloaded to a CD
5. Following the guides at swap the hard drives, putting the old one in a usb/firewire/thunderbolt caddy (is there a thunderbolt caddy yet?) in my case I used USB, if you're lucky and have a unibody mac IMHO changing the hard drive is easy. If you have an older model it's more fiddly (I have an older model)
6. Once swapped I the drives around and put the laptop back together I booted up from the Lion usb stick and installed a fresh copy of Lion on the entire drive, this ensures the recovery partition works
7. Boot into the recovery partition, plug in your old hard drive and then use disk utility to clone over the partition, you should then run first aid on the partition to make sure there's no errors.
8. Boot into your OS X partition you just cloned as normal (you can unplug your old drive at this point you won't be using it again)
9. Run boot camp wizard create as much space as you want as long as it's big enough to hold your old windows partition, before rebooting insert the paragon recovery CD.
10. Boot into the paragon recovery CD then plug in your windows backup drive.
11. Run the recovery wizard just follow the default steps and restore to the "BOOTCAMP" partition
12. Reboot, eject the recovery CD, unplug the windows backup drive and you're done.

You can then enable file vault again if you wish.

As for the backup software I tried the following:

  • Windows 7 Backup - Easy to use, backs up great, one problem the restore function requires restoring the whole disk not just the partition so it nukes the OS X partition.
  • Acronis True Image Home 2010 - Again easy to use, backs up great, nice compression, however restoring doesn't work as well it doesn't restore/fix the boot loader so you get unable to boot messages and then the windows 7 repair cd can't find the partition so it can't be repaired easily
  • Lastly I tried Paragon backup free - Backups up easily, sadly it can only take full images (I think), it has good compression and comes with a recovery cd that fixes the boot loaders and master boot record, it restores perfectly even to different sized partitions (and it's free!)


I've been using the drive for a few days, performance is incredible compared to my old 5400 rpm drive, it tool 30 minutes to install Windows 7. It takes less than 20 seconds to boot up into mac or windows and have it usable.
Running 4 virtual machines using disk heavy operations no longer causes my laptop to crawl.

All in all I'm very happy.

Sunday, 25 September 2011

Check hard drive SMART status on windows.

To check the hard drive SMART status on windows run the following

Open a command prompt (start > run > cmd)
Press enter
diskdrive get status
Press enter
If everything is ok it'll say OK

found at

Recreate Bootcamp virtual machine in VMware fusion

If your bootcamp virtual machine won't launch for whatever reason try going to ~/Library/Application Support/VMware Fusion/Virtual Machines and delete the Boot Camp folder.

Friday, 23 September 2011

Drupal 7 Anonymous Sessions

I recently upgraded a site from Drupal 6 to Drupal 7 and the site uses the administration menu module which amongst other things shows the number of anonymous/logged in users in the top right. However on Drupal 7 the anonymous users always showed as 0, turns out the Drupal guys/gals set it so anonymous sessions are only created if data is actually put in them (this is a good idea since it improves performance). To fix this simply put a line of code that stores something in sessions in your theme template.php file something like the following:

function your_theme_name_preprocess_node(&$variables) {
  //set session so we can track anonymous users


Tuesday, 20 September 2011

Comparison of Mac virtualisation software

I've been using VMware Fusion 3 for a while without too many issues. One niggling issue I've had is that vmware tools doesn't work on Debian 6 it brings up the error "Protocol Error" when mounting vmware shares. So I decided to try upgrading to fusion 4..and then the saga began.

VMware Fusion 4 has some problems...vmware tools segfaults on startup in Debian 6 and doesn't install on ubuntu reporting errors writing to /usr/lib/vmware bit weird so I decided to check out the competition.

Parallels Desktop 7 - Great software, the parallels tools install on everything I tried, one major caveat for me is that the shared file system doesn't support symlinks, I can't develop without those so that's a show stopper sadly.

VirtualBox 4 - Free (yay!) downsides no image convert i.e. can't import a parallels/vmware appliance. And cannot boot bootcamp partitions (so far as I know). Previously I switched from virtual box to vmware fusion 3 due to random crashes in virtual box.

So conclusion - I'm sticking with vmware fusion 3 for boot camp and my existing machines which are ubuntu, for debian I installed virtual box and going to give it a go.

Thursday, 25 August 2011

XCode 4.1 (Lion) installer hangs

If installing XCode 4.1 (Lion) from the app store hangs around 9x% then right click the Install file, click show package contents, enter the Resources folder and run the  Xcode.mpkg file thanks to

Tuesday, 2 August 2011

OS X Lion Finder "Bug"

Not sure if this is a Bug or just some weird mis-configuration issue, but if I have a folder open in finder and delete a file from that folder in terminal the file doesn't disappear from finder, not sure why I'm not the only one with this issue either

I found that deleting and recreating fixed the problem, no idea why :/

Monday, 25 July 2011

XBMC SMB (Samba) and OS X Lion

(Phew that's a lot of acronyms)

Anyway XBMC (and probably a bunch of other programs) can't connect to SMB shares on OS X Lion. Why? Well apple wrote their own SMB client/server which supports a different authentication protocol that XBMC doesn't support.

Now I've read a bunch of solutions i.e. try UPnP, use NFS, install SMB from mac ports, but I've found a much simpler solution.

1. On Lion set up SMB/AFP sharing as normal
2. On your computer that runs XBMC create a shortcut to the share, in the case of OSX connect to the share and then drag a copy to say your ~/Movies folder this will create an alias, for Linux consider editing /etc/fstab with the following
//server/share /mount/point cfis nounix,sec=ntlmssp,guest,user=guest 0 0 
3. Navigate to the shortcut/alias on your local machine in XBMC instead of trying to connect to the share. This will let XBMC use your operating systems SMB client to connect to the share instead of it's own internal client (or in the case of OS X it will use AFP).


Thanks to for the nounix and sec options for linux

Note check your cfis version, Fedora has 4.5, ubuntu 10.04 has 3.5 which doesn't support the ntlmssp sec option

Friday, 22 July 2011


I decided to open source my Redis PHP library, it's now on git hub and is fully documented with doxygen (documentation in git source). 

If you like it please flattr me

OS X Lion first impressions

Well on release day (about 15 minutes after release...yes I'm sad) I purchased OS X Lion. The download took around 2 hours on my 10mb connection.

After download and having taken a backup of my mac mini which is the first (and currently only) mac I have it installed on I proceeded to create a installer DVD following this guide

Next I chose a clean install of Lion by erasing the old Snow Leopard partition and installing. This sadly didn't work the first time, probably something I pushed! So I did a clean install again and it worked.

A couple of notes on the installation process.

  1. It takes a looooong time to boot from the dvd around 5-10 minutes in my case, using a USB stick should be faster
  2. If you have an internet connection enabled the installer will attempt to download Lion from Apple's servers which will take hours, so disable your internet connection first.

Once installed everything works fine, all the new features seem great.

A few notes on the initial experience

  1. I reverted the mouse scrolling style to the Snow Leopard way i.e. scrolling down scrolls Lion it's backwards you can do this by unticking the top checkbox in the mouse system preferences
  2. File vault and time machine have had a major overhaul, file vault now encrypts the whole drive, and time machine can back this up, time machine can also encrypt backups which is a major boon for me since I have problems with those two interacting (something to do with how sparse bundles are backed up I believe)
  3. Encrypted volumes can't be read on older versions of OS X so if you plan on using target disk mode keep this in mind.
  4. iTunes 10.4 isn't included it comes with software update
  5. Java isn't installed and going to a web page with Java just crashes the page instead of warning you, you can download java here
  6. Flash isn't installed by default but you can download it from
  7. Mac mail has been redesigned if you want the old version go into preferences > viewing an enable classic look
  8. Safari is wayyyyy faster
  9. Full screen apps are cool
  10. Lion remembers the state of your applications when you close them so when you open them again they have the same files open
After playing for a while I decided to try an upgrade install, so I restored my time machine backup of Snow Leopard using the Lion disk, it went off without a hitch.

I then booted Snow Leopard, ran the Lion installer from the DVD and it rebooted and upgraded in around half an hour.

The performance afterwards is as good as a clean install, no problems with my apps, the mouse inverted scrolling came back which was annoying but easily rectified.

All in all for £20 Lion is a decent investment, for me the file vault and time machine updates are worth that.

Thursday, 21 July 2011

Unable to save automator service

When creating a Service using automator if you get the error message

The document "Untitled" could not be saved as "<your service name>". You don't have permission.
To view or change permissions, select the item in the Finder and choose File > Get Info

Friday, 1 July 2011

Xcode and the App Store

I bit the bullet and paid the £2.99 for Xcode 4 from the app store (damn you apple making us pay for what was free!) Anyway it's a bizarre installation process, the app store downloads and installer that installs xcode....then it leaves the 4.5GB installer in your /Applications folder. What a waste of space. Luckily there is a way to get most o that space back, right click the Install package and click show package contents, in the Contents/Resources folder you will see a Packages folder, this is where the real Xcode installer files are, delete that and you'll be left with a 4.6MB Install file. You sadly need to keep this around for the App Store to know it's installed and to inform about updates, however you don't need to keep it in /Applications it can be anywhere on your hard drive, I put mine in /Applications/Utilities out of the way. I've no idea how this will effect updates, I imagine it will have to download the whole installer again, but updates should be few and far between since Xcode 4 has been around a while.

Sunday, 19 June 2011

Nginx PHP FCGI "No input file specified" instead of 404

If you run PHP using fast cgi on nginx, you may have noticed that if you access a php file that doesn't exist it splurts out "No input file specified" this is because nginx is passing back to php which tries to use the file name but since it doesn't exist it throws that error. Not very elegant really.
To resolve it this is my preferred way.

1. Create your custom 404 file, we'll call it 404.html and upload it to your site.
2. Edit your nginx virtual host and add error_page /404.html; into your server block
3. Add fastcgi_intercept_errors on; into the bit before your fcgi_pass
4. Reload the nginx server

What this does is it tells nginx to catch all 4xx and 5xx errors from php and if there is a error_page directive set for that code return that page.

Thursday, 16 June 2011

Slow web interface on xbmc using fedora

I use XBMC as a media player and like to control it with my iPod well I've recently installed Fedora 15 on my desktop and my god was the web interface slow. The solution in my case, disable IPv6 in Fedora.

To do this edit /etc/modprobe.d/blacklist and add blacklist ipv6 then reboot.

Probably my old hardware doesn't like IPv6 :(

Monday, 30 May 2011

Internet explorer 8 and below, files won't download over https

If you get "unable to download file, unable to connect to site" errors when trying to download via IE < 8 and you're using a secure connection (https) you've probably been bitten by if you're a web server/app admin like myself and your site is doing this, add the following headers

Pragma: public;
Cache-Control: 60;
Expires: 60;

Those allow caching for 60 seconds, apparently IE caches files in the temporary internet files and if the headers aren't there it doesn't cache so fails to download.

To be honest you probably only need Pragma: public; 

Sunday, 22 May 2011

Changing drupal tmp path

If you need to change the drupal tmp path, set the TMPDIR environment variable in PHP and update the variables table in your database setting the key named 'file_directory_temp' to the serialized string of your new tmp path.

Alternatively to setting the TMPDIR in PHP you can set it in your web server and restart your web server and PHP.

Tuesday, 17 May 2011

PHP Constructors

Note to self, PHP classes with namespaces before 5.3.3 any method with the same name as the class is considered a constructor (see

Friday, 6 May 2011

NFS mount no such file or directory

If you get the error
Reason given by server:
No such file or directory
When trying to mount a nfs directory and it does exist, add fsid=0 (or whatever the id of your drive is) to your /etc/exports configuration.

Also remember that the path you mount remotely may not be the same as the one you have in exports i.e.

If your exports contains

Then you would mount / to get /home/user and  /downloads to get /home/user/downloads/

Friday, 29 April 2011

Make Ubuntu distribution updates faster!

Ubuntu 11.04 has just been released and if like me you're getting errors "Cannot download release notes" this is because the servers will be overloaded.
To make your download faster and put less pressure on the update servers open Update Manager, click "Settings", click the first tab "Ubuntu Software", select "Other" in the "Download From" box then click the "Best Server" button, this will choose the fastest server. The more users that do this the more the load is spread and quicker updates will be.

Wednesday, 6 April 2011

Vmware bios

To access the bios of a vmware machine add bios.bootDelay = "xxxx" to the vmx file where xxxx is the microseconds to delay

Monday, 21 March 2011

Time Machine, File Vault and error -36

Recently I wanted to restore a folder from my file vault backup, so I do the usual and mount it, copy the folder, ack! Error -36 from finder, after some experimenting it seems that this is because Disk Utility mounts the sparse bundles as read/write, using the following command hdiutil attach -readonly -stdinpass <path to backup> mounts it as read only.

Thursday, 3 March 2011

Ubuntu boot ordering

Here's something interesting, due to ubuntu using upstart and having symlinks in /etc/init.d/ to upstart jobs it fails the checks for dependancy based booting for the old insserv scripts, so it goes back to legacy style boot ordering i.e. in the order of symlink file name i.e. to set up ordering use update-rc.d <service> defaults SS KK where the lower the SS the sooner it's started and lower the KK the sooner it's killed.

Saturday, 5 February 2011

Changing the OSX Path variable globally

Changing the PATH variable globally on OSX isn't the same as Linux, it's stored in a few places, firstly you have /etc/paths which contain each path one per line, and then you have /etc/paths.d

OSX reads the /etc/paths first then everything in /etc/paths.d so all paths are appended to the variable, in my case I want /usr/local/bin searched first, to do this edit /etc/paths and move the bottom line to the top problem solved!

Saturday, 15 January 2011

PHP PGSQL PDO and null bytes

Here's an interesting quirk of pgsql/php/pdo that took me hours to figure out.
I was trying to store a serialized php object in a pgsql text field via pdo. However whenever the object contained a private variable the string was truncated.
It turns out php serialized private/protected variables are surrounded by null bytes and pdo doesn't escape null bytes for pgsql so the null byte terminates the string.
However pdo mysql does escape the null byte which causes total confusion.
I've reported it as a bug with php however it maybe a problem with the underlaying pgsql driver, would be pgsqls problem to fix, I'll let the php people figure that out.
Lastly as a work around setting the field to hold the serialized data to a bytea type solves the issue setting the pdo data type to PDO::PARAM_LOB. Or you can use pgsql text fields and base64 encode the data.
(btw a subject containing nearly all acronyms, awesome!)