Author Archives: Alex Forbes

5 tips on travelling with a wide-angle lens

Three years ago, on a bit of a whim, I bought a Canon EF-S 10-22mm lens. The action was probably symptomatic of Gear Acquisition Syndrome, but I’ve fortunately managed to keep it under control since – I’m still using the same set of lenses I bought around that time!
Canon EF-S 10-22mm f/3.5-5.6 USM

It was a pricey item, and to this day I don’t really know what possessed me to spend such a sum on a piece of glass that I didn’t really know how to use. What’s more, I wasn’t sure I’d use it regularly. But all the pictures in this article were taken with it, and these days it hardly leaves the camera.

Others have asked me about wide angle photography, and I’ve even loaned my 10-22 out a couple of times, so I thought it was about time I put down some words about traveling with a wide angle lens.

Continue reading

Changing boot order in Ubuntu 13.04 (or Debian) – the easy way

I wanted nice, concise instructions on changing the boot order in Ubuntu 13.04, which uses Grub 2. Being a newbie focused OS however, Googling “ubuntu boot order” results in SEO blogs with lots of fluff, and then the actual instructions start out with “install package from ppa”…

What the hell, I just want to change the boot order!

Continue reading

Site move

Just moved this site to a larger VPS. If you can see this message you’re visiting the new host so the migration was clearly a success!

It should also be accessible over IPv6, although this has yet to be tested.

Calling mysqldump in Python

Python is a fantastic tool to know, and despite being a beginner I find myself using it more and more for everyday tasks. Bash is great for knocking together quick scripts, but when you want to something a little more complex such as interfacing with APIs or other systems over a network, you really need a more fully-featured programming language.

The topic of this post, however, is the kind of task that bash is perfect for. Thanks to mysqldump, a database backup script can be written in a few lines and dump/restores are easily automated. So why on earth would we do this in Python?
Continue reading

Targus Laptop Mat – Buyer Review

While staying with a friend recently I was instantly jealous of his Belkin Laptop cushion. It looked like a great way to chill out with a laptop in the evening while avoiding a hot lap.

While researching the Belkin above though, I came across the Targus Laptop Lap Store Mat, which was almost half the price. There were no negative reviews, so living by the philosophy that if you regret buying the cheaper one you can always get the more expensive one later (poor philosophy, but both are cheap enough to get away with applying it here!), I decided to give it a shot.

Continue reading

How not to program Bash

Came across this gem today:
[shell]
COMP=$1

if [ -e $COMP ]; then
echo “Please supply a competition_id”
exit
fi
[/shell]

On first read it looks backwards – “if exist $COMP then exit”, and the programmer clearly wanted to do the exact opposite. However it actually works as desired. Mostly.

If no argument is supplied, $COMP will be a blank string, i.e. “”. Thus [ -e $COMP ] will parse to [ -e ], which returns 0 (effectively true). It’s basically like saying “does nothing exist”.

This is because the -e argument tests whether a file exists. So if an argument is supplied, [ -e $COMP ] will return 1 (effectively false), which does what the programmer intended UNLESS the argument supplied is a valid file path.

In this case a number was expected, so sure it’s unlikely to fail in this way, but it’s still an incredibly bad way to test if an argument is set. Not to mention confusing to read!

The correct way to test this by the way would be to use -z, which simply tests if a string’s length is zero:
[shell]
COMP=$1

if [ -z “$COMP” ]; then
echo “Please supply a competition id”
exit
fi
[/shell]

Or better still, use getopts. For more info run ‘man test’ from a bash terminal.

Nexus 7 jelly bean update brings home screen rotation

image

Brief post as I’m writing this on the device in question – an update to Jelly Bean (4.1.2) came through a few minutes ago. I think this is the slickest handling of screen rotation yet – effectively the layout is the same, the Android engineers simply moved the launcher and (the useless) search to the sides. This is a nice improvement for Nexus 7 owners.

Xen Server “The SR failed to complete the operation”

Had this problem when trying to start a newly created VM and install from certain ISO files. Some ISO images would work and others would not.

Removing the ISO image allowed the VM to start but obviously there was no OS image to install from.

The error message is generic and not very helpful, but if you do encounter it check that the ISO is readable by the Xen server. In our case it was on an NFS share but the permissions were read-only to all but the owner…. so a simple `chmod a+r *.iso` fixed it!

Google’s new app policy seems a little… hypocritical

Google updated its Play Store policy recently, and the changes appear to be designed to reign in spam on its app store. One of the policies reads “Product descriptions should not be misleading or loaded with keywords in an attempt to manipulate ranking or relevancy in the Store’s search results.”

Amusingly, the description for Google’s own Maps app contains a block of text which would do just that:

Continue reading