Andrew Maddison

Flowerchild.

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.

comments

Code Club

I’ve volunteered to help a local primary school which is running a Code Club after school thing. It was our fourth week on Tuesday, and it’s been a lot of fun. Big thanks to ThoughtWorks for letting me shuffle my hours about so I get away really early one day a week.

Code club provide really awesome prepared lesson plans that we print out for each of the kids that use Scratch. It’s a super low barrier to entry; visual programming language with drag and drop coloured blocks in place of keywords. It also comes with loads of resources like artwork and sounds to get you started.

A challenge we’ve had is that the plans are written for Scratch 1.4, but the ICT computers at school have the older 1.1, so sometimes the instructions don’t match the application. Last week we tried to use the latest, online only 2.0 version, but this added complications (every child needs a login) and a slightly different set of mismatches with the instructions.

For next week, we’ll probably stick with the online version, but I’m going to run through the lesson plan ahead of time and either try to modify the instructions, or just prepare the kids for a few changes at the beginning of the club.

comments

Octopress on Amazon S3. If You Can Read This, I’ve Migrated!

So I wanted to cut my blog hosting costs, so I’ve ditched my expensive Windows virtual server running Subtext in favour of Octopress hosted on S3, which is free for a year and hopefully cheap thereafter (for my puny blog anyway).

It wasn’t crazy hard, there are loads of good guides to be found on Octopress and S3, and a couple on importing from BlogML (which Subtext can generate).

The only fail so far is comments. As Octopress is a static blog generator (ie, ruby scripts on my local machine generate static html which gets uploaded) it doesn’t support comments natively. You can use a third party system (Disqus) but it doesn’t support BlogML, so more wrangling is needed before I can get all your lovely comments back.

If I get time I’ll write up what I did (which seems to be code for: I’ll never write this up!).

comments

Jersey / Dropwizard Server.Transfer

I was looking for a way of doing something equivalent to ASP.Net’s Server.Transfer in DropWizard. Basically, while processing a page in a Jersey resource I want to abort processing the page the user requested and switch to processing a different page, (probably an error) with a different http response code (the easy bit) generated by a different Jersey resource. I’m not sure if this is the correct way to do it (feel free to comment), but all we ended up doing was simply to call the public method of the other resource, and return that from the method of our original resource/exception mapper. Something like the following (in an ExceptionMapper - but you could do something similar in a resource itself)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;

public class ExampleExceptionMapper implements ExceptionMapper<SomeException> {
    private ErrorResource errorResource;

    public ExampleExceptionMapper(ErrorResource errorResource) {
        this.errorResource = errorResource;
    }

    @Override
    public Response toResponse(SomeException exception) {
        return errorResource.getSomeErrorResponse(exception.getRequestId());
    }
}
The only problem with doing the same from a resource, is that it will probably have to return a response, rather than a DropwizardView, so that you can set the http status which might muddy the intent of your resources.
1
2
3
4
5
6
7
8
9
10
11
12
13
@GET
    public Response getSomePage(@QueryParam("someIdParam") String id) {
        Response response;
        if (someRepository.contains(id)) {
            SomeView view;
            //Build up some view.
            response = Response.ok(SomeView).build();
        } else { //no record found
            ErrorView errorView = someErrorResource.getMissingRecordErrorPage(id);
            response = Response.status(Response.Status.NOT_FOUND).entity(errorView).build();
        }
        return response;
    }
PS .Net folks - the above code is Java - so don’t shout at me about the brace layouts - it’s the Java way.
comments

The Pinnacle of Awesome - Climbing Mount Effectiveness

I was thinking about the balance between pragmatism and perfectionism. If you plot Perfectionism on the X axis against effectiveness on the Y, you get a right shifted curve. On the left slopes you’re just not being effective, and on the right slopes you probably never finish anything. In the middle is a point of maximum effectiveness - pragmatic peak, at the top of mount excellence, the pinnacle of awesome!

The peak of effectiveness against perfectionism

The fun part is, that in reality the mountain is rocky and craggy. It’s often foggy up near the top, so it’s hard to tell if you’re at the major peak or not. If you’re lucky there may be a  guide you can ask, or a map. It’s worth it, near the top the air is fresher, the view is great, and the sun is warm (when it’s shining).

What I think does happen on the slopes that is valuable is learning. On the left you might be learning from people who already know, and on the right you might be exploring processes and practices hitherto unknown.

And what can you find on the top of the mountain? Well if your company is anything like mine, you’ll find some programmers arguing about where the peak is! The smaller the boulders you’re arguing about, the closer you probably are to the top.

Two people arguing over stood on boulders

This metaphor seems to be almost infinitely extendable, and maybe I’ll draw up a few more cards one day. It’s worth remembering that your current project, and your next project, are probably on whole different mountains! Team size, tech stack and the work you’re doing all change the kind of perfectionism that is going to work best. It’s also possible you’re mountain is really a volcano, and tectonic shifts in scope or learning may move the peak even as you’re climbing.

It might be pragmatic to stay on the left side of the slope in order to stay in sight of colleagues who are still climbing. What you mustn’t do is settle with sitting on the slopes, not climbing, because it seems too steep. Try and work around it. Climb as a team, or maybe find a guide who has climbed similar peaks before.
comments

Git Revert Workflow

I recently had trouble remembering how to revert in Git, or more accurately, how to recover the work afterwards in order to fix it. Here are the commands for a straightforward revert.

git log

Make sure you know the hash/number of the commit you want to revert

git revert [Hash of commit to revert]

This will revert the commit, and apply it (locally) as another commit. You can now push or whatever. Then to retrieve your changes back into your working copy (to fix etc)

git revert -n [hash of the reverting commit]

This should get you back to having your changes locally - so you can fix ready to push again.

comments

NUnit System.BadImageFormatException

I Recently got sent a .net project which loaded and compiled fine (and even ran fine), but when running the tests it threw the following exception:

SetUp : System.BadImageFormatException : Could not load file or assembly 'SomeProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I found a solution here: The summary is - check the properties on all your projects (test and system under test) and make sure the Platform Target ia set to “any cpu”. In the linked blog is was the Tests that had been set to x86, in my case it was the system under test.
comments

Infinite Whitespace - Rubymine - Caret After End of Line

So that pesky “allow placement of cursor after end of line” which manifests itself as seemingly infinite whitespace at the end of every line seems to be true of all Jetbrains IDEs. I’ve just found that RubyMine does the same thing as IntelliJ Idea.

You can turn it off in exactly the same way as you do in IntelliJ
  • Go to the menu “RubyMine -> Preferences” (on OSX) or “Edit -> preferences” on windows.
  • Then either just start typing “caret” in the seach box - or click on “editor” in the menu on the left.
  • Then uncheck “Allow placement of caret after end of line” Just like in IntelliJ


comments

Netduino Controlled PWM Model Railway Controller

Just before Christmas I made a present for my brother. He’s a model train geek, who’s away from home (and his trains) for the next 6 months. I’m a software geek and dabble in electronics, so I came up with this little project ostensibly as a gift, but possibly just for the fun of it. It’s a little Pulse Width Modulation electronic speed controller for an ordinary 12 volt model railway, using a Netduino for the control (although you could just as easily use an Arduino).


The object of the exercise is to produce a train controller for a 3 year old, that only has one knob, but that limits (in software) both top speed and acceleration/deceleration. The theory being that the little hands of my Brother’s 3 year old nephew are unlikely to ruin his embarrasingly expensive trainset by either crashing a loco at full speed or mashing the gears by going from full ahead to full reverse in a split second.

What I did was wire up a simple motor shield using an H-bridge. If you know what that means, skip ahead. If not, read on. An H bridge is an arrangement of transistors (or other switching gidgets, such as relays) in an H shape. The transistors switch on and off in response to the Netduino’s very feak and weeble signal. The transistors work in diagonal pairs across the H shape, to allow you to reverse the power to the motor (or in this case, the train tracks) to reverse the direction of rotation (or locomotion).

Home made motor shield on my Netduino

But it wasn’t enough to make my brother a train controller, I also had to send him a whole model railway, including a train. I needed something I could pack up small (tiny) for shipping, which meant n-gauge, but not too expensive, which doesn’t really mean n-gauge. God Bless Ebay! I was able to find the tightest radius N-gauge track in production and have it shipped specially from Japan Tomix C103-60 if you’re interested - I bought set 91080 “super mini oval layout set” but left out the straights. (You weren’t interested were you?)

I also found a miniscule little 0-4-0 train from Bachman. It’s an American design, but it’s also the shortest wheelbase train I could find. This thing would think twice before staring down a cockroach. Coupled with a couple of little trucks (which grumbled on the tight radius) and some comedy cargo I had a complete, self contained model railway, complete with power supply, controller (software re-programmable), track and rolling stock, and the whole lot fit into an old 3.5” hard disk box for shipping to the other end of the world.

Tiny Bachman n-gauge 0-4-0 model steam train

This is the entire trainset dismantled and ready for packing up. The whole lot was squeezed into an old 3.5” hard disk box.

Netduino powered n-gauge train set dismantled

I’ll write up the electronics and software details in another post (including evidence of my super-human ability to make soldering look harder than it is).
comments

Presentations in Small Rooms

A few weeks ago I went to the awesome little one day conference No SQL Exchange, at Skills Matter. I learnt a lot, but the seeds of the following presentation started to form in my mind.

If you’re presenting or organising a conference in a small room* (ie not a purpose built lecture theatre with a raised stage or banked seating) please remember the following gripes from a geek who likes to hide at the back.

*Last Thursday at Thoughtworks counts.

comments