Andrew Maddison

Flowerchild.

Babylon JS Experiment

Very quickly – I’ve been playing with Babylon JS to do some WebGL animations. I’ve got a scene to draw but am having trouble with animations. Here are the results so far:

Spiky BabylonJS experiment

You can fly around with the cursor keys and mouse (Babylon default behaviour). Then hit the ‘a’ key to trigger an animation (and an error – after which you can’t fly around any more!) [Edit – fixed thanks to the peeps over at the HTML5 game devs forum]

The whole reason I wanted to do this was for fun, and to try and provide a visualisation for this 3d dogfight Code puzzle, but someone beat me to it, so now it’s just for fun.

Chronhorama Project Idea

I suffer from a surfeit of ideas and not enough time and willpower to get them all finished (coughany finished). Most never leave the confines of my head. I’ve mulled over giving a lightning talk called “Ideas I’ve had but will never get round to”, so that if anyone else thought they were good ideas, maybe they could implement it.

I thought I ought to tell people about them. So here’s one of them:

Introducing Chronhorama

From the Greek: Chronos (time) and horan/horama (see/view). (Name only recently made up and liable to change at any moment)

The gist of it is: a sort of time traveling google streetview of my own garden.

What?

I’m currently working on a bit of hardware (because that’s fun). A motorised turntable, controlled by an Arduino, that can position a camera quickly and consistently. The x-axis turntable is almost ready to be sent away for laser cutting. The Y axis is going to be phase two and will be a bit trickier. It’, still in the mulling-over phase. My progress so far is now public and open source on bitbucket.

Phase three will be to get a raspberry pi to control both the turntable (via the Arduino) and the camera (via usb) to take a whole panorama automatically. Coincidentally, the same setup could probably serve as a gigapixel rig or a time-lapse setup.

Finally, once I’ve got a few panoramas, I plan to shove it all up on a website so you can pan and scroll around a virtual view of my garden (or anywhere else). The nifty thing is, there will also be a control to travel back in time to see the same panorama on a previous date.

Why?

I’ve got a new garden I don’t know very well and I often find myself trying to remember what was growing in a spot months earlier so that I know if I’m about to hide/enhance/kill it. If I can take seasonal panoramas, I can simply refer back to the website and see that nondiscript bush (A) was covered in flowers last summer, while non-descript bush (B) is a sucker that can get hacked, hoicked and composted with appropriate malice.

Yeah, but…Why? It all seems a bit overcomplicated.

I’m not re-inventing the wheel, I’m merely re-implementing it. How else do you learn to be a wheelwright?

More accurately, it’s fun, it’s blog fodder and I want to.

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:

1
https://vpn.example.com/vpnname

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*

1
2
  chmod +x vpnsetup.sh
  ./vpnsetup.sh

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:

1
  sudo /opt/cisco/vpn/bin/vpn_uninstall.sh

*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.

1
2
3
4
5
6
7
8
FileInputStream inputStream;
try {
    inputStream = new FileInputStream(someFile);
} catch (FileNotFoundException exception){
    System.out.println(someFile.getAbsolutePath());
    //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:

1
2
3
{
    "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.

1
2
3
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

1
NetworkPrinter>LPD/LPR host or printer

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

1
lpd://123.0.0.1/SomeQueueName

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:

1
SyntaxError: Unexpected token \u001f

tl:dr

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

1
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.

1
2
3
4
5
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 “*”)

1
2
3
4
5
alias find_from_here_wild='ffs'

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