Andrew Maddison


QCAD Unity Launcher in Ubuntu

I recently tweeted that QCAD is all the CAD I want. I only need 2D, it’s keyboard friendly, cross platform and the default file format is DXF, which is compatible with everything and text based so git likes it (although I wouldn’t want to diff/merge one).

Anyway, it doesn’t come with a .desktop file for unity/ubuntu, so I knocked one up, which I published as a Github gist.

QCAD desktop file gist

By default, qcad is installed by just unpacking into /opt/qcad[…]/ and run from the command line. If you drop the desktop file into either /usr/share/applications/ (for all users) or ~/.local/share/applications for the current user (create the folder if it doesn’t exist). You should then be able to find the icon/launcher in unity, and be able to pin it to the sidebar if you wish.

Ubuntu 13.10 Cisco vs Openconnect Vpn

I couldn’t connect to my client’s vpn from Ubuntu 13.10 using openconnect (the open source cisco compatible vpn client that integrates nicely with Ubuntu). This seems to be a known problem in 13.10 and AFAIK shouldn’t affect 13.04 or older (certainly, it works on a colleague’s 12.04 box)

So instead I went with cisco’s own anyconnect client and it seemed to work fine. First, just browse to the vpn address in a browser. Ours is something like:


If you have java enabled in browser the client should download, if not (like me) wait for it to time out and you’ll be presented with a link to a shell script which installs the cisco vpn client. Give the script execute permissions and run it with sudo*

  chmod +x

Then I simply found the cisco anyconnect client in the launcher, type in the vpn url (without the https scheme), username and password in the box, hit connect, and it seemed to work fine.

Edit: I’ve since found some links to uninstall instructions on ubuntu forums and cisco’s site, the gist of which is, run another shell script:

  sudo /opt/cisco/vpn/bin/

*As this came from inside my trusted client’s domain behind valid ssl I assumed it was safe. On your own head be it if you go running random shell scripts on your machine as root and you end up getting a new mortgage in downtown Vladivostok.

Java Diagnose File Not Found Exceptions

Having trouble figuring out those pesky file not found exceptions? Usually it’s some relative path to a test resource file from a mystery working directory somewhere on a test slave (or in my case, a completely sensible path on my local machine that I’d mis-read). Well, the answer is so obvious I’m forcing myself to write it down as pennance for not thinking of it years ago.

FileInputStream inputStream;
try {
    inputStream = new FileInputStream(someFile);
} catch (FileNotFoundException exception){
    //Logging to debug or trace here would be more sensible, especially in live code.
    throw exception;

If the file isn’t found the full path is barfed out so you can figure out where you’re going wrong. No more randomly adding “../” into paths. I really wish something like this happened out of the box, but I guess you’d be leaking a lot of internal system info by default.

Changing Sublime Text Font Settings in Ubuntu

tl:dr – use sudo to launch sublime before changing settings (or they won’t persist).

In addition to using sudo, you need to edit the font preferences in the user’s preferences as opposed to default preferences (apparently the platform prefereces override the setting, and are between default and user in the heirarchy, but not listed in the menu for some reason).

I copied the font size property from the general preferences, and pasted it into the user prefs, which looks something like:

    "font_size": 14

Feel free to comment if I’ve misunderstood this :)

PS – the same seems to be true of entering your license key – make sure you start sublime using sudo, or it wont persist.

Installing Xerox 7855 Printer Drivers on Ubuntu

Here’s how I installed the printer drivers for my current client’s Xerox 7855 printers. Worked on my machine, your milage may vary!

First, download the drivers. They come as a self extracting zip file (windows .exe) from the Xerox support website here.

Then you need to use Wine to unpack the zip, this turned out to be pretty easy.

sudo apt-get install wine
[blah blah...]
wine WC78XX_PPD_English.exe

That will unpack the zip, then you play hunt the files, the default location for me was ~/.wine/drive_c/Xerox/WC78XX_PPD_Driver

Then fire up the printers dialogue from System Settings, and add a new printer. At this client I then chose

NetworkPrinter>LPD/LPR host or printer

The host and queue were provided to me by the client in the form:


In the Dialogue box, put just the ip address (not scheme or path) into the Host field, and the queue name into the queue box (duh).

Finally, for this client, they have a follow you printing system, so you have to get your id card registered with your computer username, so that your print jobs get delivered to you when you visit the printer.

Import BlogML to Disqus for Octopress - Comments Are Back!

I’ve finally managed to import the comments from my old blog into Disqus, which can then be included in Octopress just by editing _config.yml

I’ve written a Ruby script (my first!) to convert the BlogML from Subtext into Disqus’ wordpress based custom XML import format.

BlogML to Disqus custom XML import Ruby script

Things to remember:

  • it works on my machine – your milage may vary (let me know if you have problems, or even better, fix them in the script).
  • I had to edit all of my previously imported blog posts, adding the “comments: true” header line before the comments would show up.
  • Comments only appear on the permalink page – not the homepage.
  • I manually tweaked the XML generated to fix my own username and email address so my gravatar appears consistently where I’d inconsistently replied to other comments.
  • Definately create a test shortname, and try your import out on that. Re-importing to the same shortname (for example, because you’ve fixed a mistake) doesn’t seem to update the already imported comments. I created another test shortname.
  • I can’t seem to delete test shortnames once I’m done with them.
  • Don’t forget to uncheck “Enable Promoted Discovery” – That’s adverts which Disqus will inject into your blog with the comments.

Cube and Jersey Dropwizard SyntaxError: Unexpected Token /u001f

We’re experimenting with Cube which is a tool that aggregates and indexes a bunch of events, and allows you to query them to produce live dashboards etc. It’s written in javascript, and runs on node with a MongoDb back end.

We’re calling it from a Dropwizard java service, which used Jersey’s client under the hood, but when we posted an event into Cube, we got a slightly weird error, a 400 (bad request) with the following message:

SyntaxError: Unexpected token \u001f


add the following to the httpClient section of your Dropwizard config,

gzipEnabledForRequests: false

Long version:

What seems to happen is that Jersey’s client gzip encodes all requests by default, (and duly sets the Content-Encoding header to gzip).

We used Charles Proxy to look at the request – and noticed that the first character of the compressed request is “1f” in hex, which happens to be the hex representation of the offending unicode character “\u001f” (which is an obscure non-printing control character, and a big fat red herring.)

So either Cube, or node or something is unable to accept gzip encoded requests, and barfs out a bad request.

Bash Alias to a Function for Find Command

So my bash-fu is weak, and my memory for which arcane switches to pass to command line incantations is even weaker, so I created the following in my bash_profile to alias the most common uses of find (for me). Which is just search, from the current path, for this file name.

alias find_from_here='ffh'

find_from_here() {
  find ./ -iname $1 -print

The Alias is optional really, as a function in bash_profile can be invoked from the command line directly, but it let me have a descriptive name in the source and a very short name on the command line.

I also created another one that’s case insensitive and with a wildcard appended (in case I can’t event be bothered to type “*”)

alias find_from_here_wild='ffs'

find_from_here_wild() {
  find ./ -iname $1* -print

Octopress Rake Errors - You Have Already Activated X but Your Gemfile Requires Y

I came up against an error using Octopress, when I ran rake generate I got the following error:

rake generate
rake aborted!
You have already activated rake 10.1.0, but your Gemfile requires rake Using bundle exec may solve this.

Edit Following a comment from Josh below, I’ve tried his suggested fix of upgrading the version instead – delete your Gemfile.lock and edit the version of rake specified in your Gemfile to 10.1. Job done! It’s working fine as far as I can tell. /Edit

Not really understanding ruby, bundler, gemfiles et al, I hit the g**gles and figured out that this was probably because I built another unrelated project which had specified a higher version of rake in it’s gemfile, and by the magic of gems, the new version was installed. The local (to octopress) gemfile.lock specifies the lower version, and refuses to work with the higher version. (As far as I can figure out, Ruby and Gem versioning is the new, DLL-hell).

Work around

The work around mentioned in the error message (bundle exec) is to invoke rake as follows:

bundle exec rake generate

This works, I gather it causes bundler to dynamically find the version specified in the Gemfile.lock and use that for this one invocation, but it’s bit of a kludge.

You could paint-over-the-rust by adding a bash alias or something to reduce the keystrokes, but a slightly more fixy fix is to run the following (found in this blog post and it’s comments)

bundle install --binstubs

This gets all the gems, in the versions specified in your gemfile.lock, and puts them into a bin directory local to the project. From then onwards, for that folder, you don’t need to care and can just invoke rake as normal.

rbenv plugin needed

This didn’t actually work for me, probably because I use rbenv instead of rvm, so some more searching turned up a plugin, rbenv-binstubs that sorted it out: (it was super easy to install, just clone the github repo straight into a rbenv plugins folder).

add bin to .gitignore

Finally, add the following line to your .gitignore so that the bin folder doesn’t get checked in.


If RSA SecurId on Android Rejects Your Token - Try Upgrading

I just had to import a new RSA SecurID key into my phone, as the old one had expired. Unfortunately two things frustrated me. As the page on installing RSA’s SecurId app on Android and iPhone is one of the most visited on my blog, I thought I ought to post an update here.

First, the app consistently rejected my key as invalid. In the end I noticed that I had the slightly out of date 1.1 version. Play didn’t seem to want to update it, so I uninstalled, and then installed the latest 1.2 version. The new version installed the key with no problems.

Secondly, as the link doesn’t seem to have a magic protocol to launch the RSA app any more (or mayby that was only ever on the iPhone) you have to copy and paste the key from your email to the RSA app. Irritatingly the standard press-and-hold to paste didn’t work, but there is a paste menu item which solved the problem.