Technocamps Beachlab 2014

Aberystwyth Technocamps Beachlab 3D Printing Minecraft

Photo by Arvid Parry Jones

On Saturday Aberystwyth University held an “Access All Areas” event; opening the university up to the general public. As with last year we worked together to combine it with the Technocamps beachlab.

Aberystwyth Technocamps Beachlab 3D Printing Minecraft

Last year I got to demonstrate our relatively new 3D printing and scanning setup. This year things weren’t as exciting owing to some broken kit, but it was still a good day nonetheless. The recent news regarding 3D printing of gun components has clearly led to a major increase in awareness (some good, some bad). In many ways it was better that the machines weren’t in use as I got to had some in depth discussion with a variety of people.

Beachlab 2014 Dalek Doris

Aberystwyth Technocamps Beachlab 3D Printing Minecraft

Aberystwyth Technocamps Beachlab 3D Printing Minecraft

Photo by Arvid Parry Jones

A Nasty Hack for Image Landing Pages

I saw this on the Aberystwyth Comp Sci facebook group: It’s a little example of embedding image data within a HTML pae, in a similar (but less pleasant) way to using data URIs for embedding images stored as base64 strings (see below). It’s a very hacky way to give direct-link (rather than inlin/hotlinked) users a page rather than the image alone.

I was intrigued so took a quick look at the source and replicated it.

I don’t see much practical use, it’s ugly and I wouldn’t rely on it, but it’s straightforward to replicate and as the page states, all the magic is done client side.

Should work with most images (only tried with jpeg), the first few bytes (APP0 segment) go before the tag, that way it’s recognised as an image (we need to make the body hidden so that doesn’t show, then the page itself goes in the next few bytes – so we’re hoping the browser ignores these. Lastly we put the image data in an unclosed html comment. I suspect with a longer page we’d see the image becoming corrupt.

It even preserves exif.

So what’s the use? Well, you can use the same URL for the img src tags as you do for a landing page. But at the end of the day, you’re serving a corrupt page that shouldn’t work and can’t be relied upon.

It’s interesting, but the correct way to deal with hot linking, or image landing pages is to use mod_rewrite (in Apache). But at the end of the day, file extensions exist for a reason and you shouldn’t really be serving up binary data in such a messy manner anyway. There’s simply no point in forcefully redirecting users away from data like this; those that want it, will get it.

Here is an example of an image that can be copied and pasted directly as HTML. Many browsers recognise data URIs in which we can store data 9such as images as base64:

Where “XXXXXXXXXXXXXX” is the base64 string.

Base64 is a binary-to-text encoding mechanism that allows binary data to be transmitted as ASCII (a mere 127 printable characters) strings, when you see “MIME” referenced in relation to email, it’s about getting attachments added, and that’s how it works. Very roughly, encoding data as base64 (using fewer bits) increases size by a third.

Barebones Distance Function for pdist()

I had a bit of bother when adding my own distance function for use with Matlab’s knnsearch (and other functions). Surprisingly, custom functions aren’t discussed much and can be a bit troublesome the first time, so here’s the template I’m using from now on:


%Structure as specified by knnsearch.m:
% function D2 = DISTFUN(ZI, ZJ),
% taking as arguments a 1-by-N vector ZI
% containing a single row of X or Y, an
% M2-by-N matrix ZJ containing multiple
% rows of X or Y, and returning an
% M2-by-1 vector of distances D2, whose
% Jth element is the distance between the
% observations ZI and ZJ(J,:).

function [ L ] = distanceFunction(sample, models)
B = length(sample);

if size(models, 2)~= B
error('Mismatched vector lengths!');

model_count = size(models,1);
L = zeros(model_count, 1);

%compare the sample to each model
for m=1:model_count
model = models(m,:);
L(m) = 2.*(sum((sample.*log(sample+eps)) - (sample.*log(model+eps))));

I’ve left loops in for clarity, naturally, try and vectorise all that you can.

Also, eps is a useful function; it returns the distance to the next larger in magnitude floating point number. In most cases, you can take this to mean a really tiny number that prevents division by zero errors. A nasty but generally trustworthy trick.

First try with the 3Doodler


I backed the 3Doodler project back in March and in what must be a Kickstarter first, the folks at WobbleWorks have delivered well ahead of schedule. Today I got an email with a tracking number, I was pleased to find it had already passed customs and even more pleased when it arrived this afternoon.


Caroline and I got it running with no problems, though I think some practice is in order. It may not suit me, lacking an artistic skill, but it’s a lot easier to setup than a makerbot!


My only complaint is that it does seem to eat the PLA – we played with it for less than 5 minutes (just long enough to take a photo) and we went through a 25cm piece. I think the flow may be slightly inconsistent.. I’ll update once we’ve had chance to play some more.

Quick and dirty automatic old file deletion

I’ve started using my VPS to store stills from my IP cameras. It’s easy and quick – I’ve got a script running on my openwrt router that fetches the stills periodically from 8 different cameras. Whilst some support FTP upload, others are less well connected (hence the need for the script).

Unfortunately whilst I was away, without Internet last month, the storage on the VPS filled up with these images taking down most of the services running. This was the quick and dirty fix I managed to implement using on my phone:

This code adds a daily crontab that uses the ubiquitous find command to simply delete old files. In this case I’ve used 10 days, but you can get flexible with the mtime option if you check the man page. We use exec as this doesn’t expand the entire list of found files so avoids “argument list too long “issues.

Couple of caveats -

  • I ran it as root, because that’s what I had.. Many users are ingrained with a fear of the root; but I consider it a personal preference which is best debated elsewhere.
  • You should use  crontab -e to modify your cron files as it verifies the syntax.

Being able to do these quick fixes is what I love about linux. I highly recommend following bash one liners on twitter - who also have a QDB style website.

Coins for 2014

We’re still in the first week of the year and thanks to parents and other family my 2014 coin collection has had a great start.

2014 Coins

The 2014 definitive coin set.

A few years ago I came into ownership of my grandfather’s coin collection. Since then I’ve been working on cataloguing the various not inconsiderable quantity of currency; mostly from the commonwealth but ranging from ancient to modern times with a few imitations thrown in to make things interesting. It’s led me to develop my own collection – like most people, I began with the change from my pocket, but more recently have sought out proofs and piedforts.

Last year I invested a fair amount of time tracking different coins down so decided from now on I’ll do things thoroughly form the start. To that end, I’ve signed up for an

My coins to start the year off with:  2013 Dinosaurs PMC, 2014 Lunar Horse 1oz Silver PNC, Silver/Gold Guinea Anniversary, 2014 Definitive Set, 2014 Definitive Set, Harry Potter Noble Collection coins, Miscellaneous bullion coins.

My coins to start the year off with: 2013 Dinosaurs PMC, 2014 Lunar Horse 1oz Silver PNC, Silver/Gold Guinea Anniversary, 2014 Definitive Set, 2014 Definitive Set, Harry Potter Noble Collection coins, Miscellaneous bullion coins.

annual subscription to the Royal Mint’s premium coin collection – the definitive set, with the addition of a number of commemorative coins and a collector’s medal all in distribution alloy. It’s a fantastic presentation, if a little pricey, though I see all of the coins in my collection as an investment.

Continuing with the 2014 collection, I got the first of the new Lunar year coins as a PNC. It’s a lovely 1oz silver coin. I enjoy PNCs as they usually have a wealth of historical information, though this one is a bit lacking in that respect. It does come in a nice, tactile envelope though.

Lunar Horse 2014 PNC



The Noble Selection produces a fantastic display of coins from the Harry Potter films. These are weighty though only plated with their respective metals, but a very nice addition to predominantly muggle collections.

Galleon, Sickle, Knut (Gold, Silver, Copper plated).

Galleon, Sickle, Knut (Gold, Silver, Copper plated).

I’ve also taken the opportunity whilst I was in a buying mood to pick up a small amount of older silver bullion coins (4.5oz) whilst prices are fairly low as well as the 2013 Dinosaurs PMC.

350th Anniversary of the Guinea

50 Shades of Grey for Android

This week I’m doing Technocamps work with AppInventor (a visual programming tool for Android development) at Coleg Ceredigion.

I’ve been playing around with some simple demo apps to introduce ideas and really wanted one that had swiping actions. So I made 50 shades of grey.

When you swipe left or right, the app increments or decrements the intensity of grey – providing 50 distinct shades of grey.

Alt42 50 shades for android

Alt42 50 shades for android

I’m not adding it to Google play, but you can download the source code here and the apk here.

Simply upload the .zip file from the “My Projects” page of AppInventor. Find more about AppInventor, and get started, here: I have some professional concerns about AppInventor as a viable development platform, I also dislike the term “app”. Nevertheless, it is certainly fun.

You need to enable USB dev mode on your android device (under settings, varies slightly for phones/tablets) If you’ve got an HTC make sure you install HTC Sync, for a Nexus install the Nexus drivers. Avoid using the emulator unless your computer is fast (you might need to increase memory allocation to the JVM).

Alt42 50 shades for android

Alt42 50 shades for android

I hope it’s a nice simple example for anyone looking to integrate swiping action into their apps. Here’s a few other quick ones:

Sarcastic 8 ball:

Coin Toss:

Homework Excuse Generator: