Upgrading to WordPress 2.5 with subversion

The quickest way to upgrade wordpress is via subversion. Assuming you had already installed your blog via subversion then you can upgrade using the following steps:

Backup your database
Since the wordpress db contains only MyISAM tables, you can backup with a simple file copy.

cd /var/lib/mysql
cp -Rp wordpress/ wordpressBACKUP

Switch to the latest subversion url
Just run the svn switch command. This will add, update and delete scripts as required to bring you to the latest version.

cd /path/to/your/blog
svn switch http://svn.automattic.com/wordpress/tags/2.5/

Run the upgrade script
Finally, run the wordpress upgrade script, which upgrades the database and anything else it might need to do. Simply visit http://www.yoursite.com/blog/wp-admin/upgrade.php

Secure browsing on an insecure network – the easy way!

In my post yesterday, I talked about how to securely browse the web on an insecure Internet connection. The method I used was to install a proxy server (squid) on a trusted machine and ssh tunnel to it. However, one of my developers, Andy, kindly pointed out to me that there is a much easier way – just use SSH’s dynamic port forwarding as a SOCKS proxy.

To create the tunnel:

ssh -D 3128 [email protected]

To configure OS X to use the proxy, go to System Preferences > Network > Advanced > Proxies

OS X SOCKS Proxy Settings

Tick SOCKS Proxy, and specify the server as 127.0.0.1 port 3128, then click OK and Apply on the following screen, and that’s all you need to do!

Secure browsing on an insecure network with my Macbook

UPDATE: There is a much easier way to achieve a secure tunnel/proxy that doesn’t require squid to be installed. I’ve blogged it here. The method described on this page may be useful if you want to log the pages you visit. Also, if you wanted to block out ads, you could swap out sphinx for another proxy such as privoxy.

I’m currently on holiday in Avoriaz in France, and I’m browsing the Internet via an open wireless hotspot. Given how easy it is to intercept traffic on an open wlan, this could have posed a bit of a security problem as a lot of the website admin panels I access (including my blog’s wordpress admin) are in an insecure (http) area.

However, there is a solution that ensures that all my traffic (not just https) is encrypted, at least until it gets back to a more trusted part of the Internet.

The solution involves setting up a proxy server (squid) on a trusted server somwhere (e.g. a datacentre, or your home or office) and then connecting to this server via an SSH tunnel.

For this particular howto you will need the following:

  • An Apple laptop running OS X 10.5 (Leopard)
  • A Linux server (preferably running Centos / RHEL) in a trusted location

Installing Squid on your Linux Server

Firstly install squid using your desired package manager… I have a Centos 5 server, so I’m going to use yum:

[root@pablo ~]# yum install squid

Next, edit the squid config to allow any local ips that might be listening on that server:

[root@pablo ~]# vim /etc/squid/squid.conf

I added a line to allow my servers public ip. NB, at this point we aren’t permitting your laptop’s IP, only the local IP addresses on your server.

acl localhost src 127.0.0.1/255.255.255.255
acl localhost src 87.124.70.62/255.255.255.255

Now setup the runlevels for squid so that it starts when your server starts:

[root@pablo ~]# chkconfig squid on

If that worked, it should be set to on for run levels 2,3,4 and 5:

[root@pablo ~]# chkconfig --list squid
squid 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Finally start squid if it isn’t already running:

[root@pablo ~]# service squid start

Setting up your laptop to use the secure proxy

To get the laptop using our secure proxy, we must do two things. Open an ssh tunnel to the proxy, and then setup Safari (or your browser of choice) to use this proxy for any required connections.

To setup the secure SSH tunnel from port 3128 on your laptop to port 3128 on the squid server, just run the following command:

paul-macbook:~ paul$ ssh -L 3128:localhost:3128 [email protected]

Then all you need to do is configure Safari (or Firefox) to use port 3128 on your local machine as its proxy, and all traffic will be routed via this secure tunnel before being re-routed to the rest of the Internet. Of course, this won’t secure your browsing from then on, but you can at least be sure that it is not being intercepted by fellow users of the wifi hotspot.

So click on the Safari Menu at the top of the screen, and then click preferences (or press CMD + ,) This will open up the Safari preferences. Make sure you have the advanced tab open.

Safari Advanced Settings Menu

On this menu, click the Change Settings button next to Proxies. This will take you to the System Preferences Proxy menu.

OS X Leopard Proxy Settings

Select the protocols you wish to enable the proxy for (in my case I just chose HTTP), then fill out the proxy server address, which is 127.0.0.1 (localhost) and the port, 3128.

And that’s it! You should now be able to browse the web as if you were using your Linux server directly. This method has the added advantage that it can be used to bypass geographic ip based restrictions, as it makes you appear to be where you server is located.

Downloading iPlayer MP4 streams on Linux

Last week, the BBC made their iPlayer content available for the iPhone, and by doing so they unwittingly made all their content available to download DRM-free as an MP4 stream.

The process is simple; change your browser’s user agent to replicate an iPhone, then you will be able to view and download the mpeg 4 videos.

Download MP4 iPlayer videos in 2 steps

In this example I am going to use wget to download the files via the command line.

1. First you need to lookup the URL for the MP4 stream. The easiest way to do this is to use a web tool that extracts program information from an iPlayer URL (e.g. Eastenders). Paste the iPlayer URL you want to download into the search box on that page and submit, then right-click download the MP4 video and copy the url.

2. Now fire up a terminal and run wget, replacing the URL with the URL you copied from the first step:

wget --user-agent="Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3" http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/b0094z1j

An alternative method is to use this ruby script, which takes an iPlayer URL directly and does everything for you.

BBC Reaction

So far the BBC haven’t said a lot about this revelation. Currently, their official line is as follows:

The BBC iPlayer on iPhone and iPod Touch is currently in beta, which enables the BBC to pick up on these issues and find a solution that ensures the content is delivered to users in a secure way before the service is rolled out

According to their technology blog, they will be posting a fuller response in the next few days. My hope is that they don’t do a u-turn on the MP4 format. If any staff from the BBC Media team read this post, here is my message to you:

Dropping the DRM from your mp4 streams for the iPhone is a fantastic step forward, so please embrace it!

Using an open standard will allow license paying users of any platform to enjoy the content they have a right to view, with minimal additional development costs to yourselves.

There is no DRM when people save shows on Sky+ or their video / dvd recorders (or even straight to their computer via a DTV tuner), so why cripple the iPlayer service with it?

At the very least you could make your in-house productions available on MP4 to all, whilst you get the third party producers on board.

Downloading MySQL rpms with a Linux one liner

I love linux. It’s almost one year now since I switched my main work desktop machine to Linux from Windows XP, and I’ve not looked back. Windows was slow, unreliable (regular blue screens) and lacked many of the advanced features that linux has out of the box (or should I say off of the web).

Linux’s features are too numerous to list, but every now and then I use one that just reminds me how superior it is to it’s proprietary rival. In this case I needed to download the latest MySQL 5.1.23 rpms for installation on an ndb cluster.

Normally I would go to MySQL’s download page, and manually right click to save them individually, but since I have been doing it so frequently recently, and that I was likely to need to do it again in the future, I thought there must be a better way.

The answer lay with a few bash commands strung together with pipes:

wget -O - http://mirror.fubra.com/www.mysql.com/Downloads/MySQL-5.1/ | grep -o -P 'href=".+5.1.23-0.glibc23.x86_64.rpm"' | grep -o -P 'MySQL[^"]+' | xargs -I {} wget http://mirror.fubra.com/www.mysql.com/Downloads/MySQL-5.1/{}

The command above (which should be all on one line) does the following:

  • First we use wget to download a directory listing of all MySQL 5.1 downloads from our local MySQL mirror (but this could be any mirror). We invoke the -O – option to direct the output of the webpage to STDOUT rather than a file.
  • The output from wget is piped to grep which does a perl regular expression to look for links to all rpms from the particular version of MySQL we want, in this case generic 5.1.23 for x86_64 machines. This is returned as a list of every link from the html source containing a link to one of these files.
  • The output from grep is piped to another instance of grep. The reason for this is that we want to cut out the href=”” from the links so we are left with just the file name.
  • The tidied list of filenames is piped to xargs which runs wget for each one, pre-pending the full path to the beginning of the filename

And that’s it. We end up with each rpm being downloaded to the current working directory.

I know that it is technically possible to do things like this with Windows Power Shell, and cygwin, but they are not native solutions that are available to every machine by default, as they are on all *nix machines.

Bed Bugs

My friend Jake is currently staying in Malaysia. Last week his Mother came to visit him, and they stayed in the Heeren Inn in Melaka. Unfortunately for them, the beds were ridden with bedbugs, and after their first night’s stay Jake’s poor mum was bitten more than 50 times. The worst thing is that the owner of the hotel did not even care!


Under the microscope….
Bed Bug
A bed bug feeding….
Bed Bug
Full with blood….
Bed Bug

Office Toilet Facility Regulations

Recently we have been considering upgrading the toilets at our office, and part of this would involve removing 2 urinals in the men’s toilet and replacing this with a shower cubicle. Of course, before doing this we have to ensure that we will still be in compliance with Health and Safety laws.

The key issue for us is whether an employer is legally obliged to provide a urinal for male employees.

After spending a while researching on-line, I found conflicting information from various government departments. Southwark council have a page about Toilet Facilities on their site, as does business link and there is a guidance document on HSE’s website. Both Sourthwark council and the HSE guidance document offer two tables listing the minimum number of facilities required, one for a mixed sex work force and one for a male only workforce.

Business link are the only ones who say that the provision of a urinal for male employees is mandatory, saying:

“If any of your employees are men, you must provide the relevant number of toilets and urinals as outlined”

So who is right?

Well the law that governs the provision of toilets by an employer is the Workplace health, safety and welfare. Workplace Regulations 1992, and this is accompanied by another document published by the Health and Safety Executive know as the Approved Code of Practice and guidance.

At this point I couldn’t find the whole book reproduced anywhere online, so I ordered a copy and I have scanned in the relevant pages as you will see below.

Page 33 Page 34
Workplace Health, Safety and Welfare - Page 33 Workplace Health, Safety and Welfare - Page 34

There are two tables in the “Minimum numbers of facilities” section.

Table 1 may be used by all businesses (with a mixed gender, or an all male workforce).
Table 2 may be optionally chosen by employers of an all male work force.

The exact wording is as follows:

In the case of sanitary accommodation used only by men, Table 2 may be followed if desired, as an alternative to column 2 of Table 1

So it would appear that, in fact, urinals are optional but not compulsory.

Minimum number of facilities

The minimum number of WCs and WHBs in a mixed sex office is therefore:

Number of people at work Number of water closets Number of wash stations
1 to 5 1 1
6 to 25 2 2
26 to 50 3 3
51 to 75 4 4
76 to 100 5 5

As a rule of thumb you need at least 1 toilet and wash station per 25 employees + 1 extra. Unless you are planning on having unisex toilets, you will need to run this calculation separately for both men and women. For example, in an office with 50 men and 50 women, you would need either a) 3 men’s toilets, and 3 women’s toilets or b) 5 unisex toilets.

Local Petrol Price Data

A lot of people have been requesting a summary of petrol price information in their local area, so today I built a tool that will allow them to include this on their site:

View the source of this page to see how to include it in your own site (via an iframe).

Macbook Air brings iPhone’s multitouch to a laptop

Steve Jobs announced a new Macbook for their laptop line up during his keynote speech at the Macworld Expo today. The Macbook Air will be the world’s thinnest notebook, but even though it’s small in size, it’s not short on features:

  • Aluminium case
  • Illuminated keyboard with ambient light sensor to auto detect darkness
  • 5 hour battery life (with wireless enabled)
  • Multi-touch (iphone style) Touch pad
  • Wireless 802.11N networking (up to 250mbps)
  • Bluetooth 2.1 + EDR (up to 3mbps)
  • Just 1.94 cm thick and 1.3 kg total weight (just over half the weight of current macbooks)
  • Fits in an A4 envelope? (or the US equivalent)
  • LED backlit screen for lower power consumption
  • Optional 64Gb solid-state drive.

Macbook Air
You can buy the new Macbook Air for £1199 from Apple’s online store or pay a whopping £829 more for the SSD version!.

Organic Eggs? You need a Hen Home

Over the past few weeks I’ve been watching Hugh Fearnley Whittingstall’s Chicken Out campaign on Channel 4 with interest and it certainly has opened my eyes to the appalling conditions in which we raise our feathered friends. I guess I’ve always known that battery hens were kept in cramped conditions, but not to such an extend.

So what can I do? Well the most obvious change I can make is to ensure that I always buy free range or organic eggs, but actually I can go one better than that. My friend Stuart has just designed and built a wooden hen home so that he can have his own pet chickens in his garden.

The Hen Home

Each chicken should produce about an egg a day. You can’t get fresher than that!