Aug 12

Last week-end I went to Brands Hatch for the British Superbike Championship.

I had a great time and loved hanging around the paddock and talking to drivers and mechanics. Also, a friend of mine was racing in the Harley Davidson XR1200 championship so it was a good opportunity to spend some time with him and cheer him on.

I loved the historic bike races and have taken quite a few pictures. Here’s some of my favourites.
Classic race 3

Classic race 2

Cassic race 1

And here’s a picture of my friend, Rhys Boyd, racing the XR1200 for the Rockforge GFI team.
Rhys on the GFI team Harley

Tagged with:
Aug 02

Over the past couple of weeks I’ve been interviewing candidates for a Java developer position.
I can’t find words to describe my feelings now so I’ll recycle something a friend of mine, who’s also hiring, said:

It’s next to impossible to hire anyone useful now.

My complaint with most of the applicants is that they behave – there’s no other way to say this – machines.

I did what I did because I was told to it. Never really thought about it.

This infuriates me beyond belief.

So here a few tips for your (and my) next interview:

  1. Don’t make up stuff on your CV. Sounds obvious but you’ll be surprised by how many people list technologies they have barely used on their CV and when asked about it don’t have a clue. You have no idea how bad this looks. (The red bullshitter light starts flashing in my head instantly)
  2. Show that you have passion for what you do. Being a Sun certified Java developer is all well and good but when I ask you what you have been looking into recently, or if you’ve worked on something on your own make sure to have an answer; or, if you don’t, make sure you have a good excuse.
  3. If you have 1000 years of experience with something I expect you to have some thoughts about it. Once again, Sun certified Java developer, if I ask you where do you see java going in the next 5 years have an answer! There must be something you think needs improving in Java or that you’d do differently. I’ll go wherever Sun takes me is just not an acceptable answer.
  4. Have an opinion! For God’s sake have one. I’ll even settle for half an opinion. If not about a technology you have used for 10 years at least about the coffee I just bought you during the interview. There’s no point in talking for an hour with somebody who has nothing to tell me other than “I’ll do everything you want, I always did.”
  5. Know what the company you have applied for does! This sounds stupid but I have called people after 1 week of their application and after 10 minutes with them over the phone I found out that they have no idea what the company they applied at was doing. That’s an instant goodbye!
  6. Fill the gaps in your CV, and proof-read it before sending it out for goodness sake. It’s fine that you have taken one year off to travel the world. If your CV does not list anything for the whole of 2009 I’m going to ask you about it. Give me a sincere instant answer and there’ll be no problem. Give me random excuses and it’s goodbye. As for proof-reading I had somebody applying who had listed “quick apprehension” as a skill. I’m not into hiring failed super-heroes. (I assume they ment quick comprehension)
  7. Apply for jobs you are genuinely interested in. You are not likely to get a job if your interviewer notices you don’t give a toss about what you do and who you do it for, and it shows. So Unless you are applying for a position as a nut-packer make sure you’re going for a job you’d actually enjoy doing and are interested in.

Needless to say my search continues.

After reviewing more than 60 CVs I have almost completely given up on websites such as Monster and CWJobs and I’m going to go entirely through connections now.

Tagged with:
Jun 14

The new version of MapKit in iOS 4 supports polylines, finally. MKPolyline to be precise.

I have been working with the Google Maps API for a while and now I’m learning Objective-C and writing an iPhone app ro Route.ly

Since the best way to send around the net the data to draw a polyline on a map is in encoded format I decided to write a small Objective-C function to decode the encoded string. Since I couldn’t find this anywhere on the net I decided to publish the code here.

You’ll notice that at the beginning of the function I replace “\\\\” with “\\”. This is because I use the encoded data both in web pages with javascript and my iPhone app. In javascript “\\” would be considered an escape and would therefore break my array of points. This is not the case in Objective-C so I switch back to the normal “\\”.

- (NSMutableArray *) decodePolyline:(NSString *)encodedPoints {
        NSString escapedEncodedPoints = [encodedPoints stringByReplacingOccurrencesOfString:@"\\\\" withString:@"\\"];
        int len = [escapedEncodedPoints length];
        NSMutableArray waypoints = [[NSMutableArray alloc] init];
        int index = 0;
        float lat = 0;
        float lng = 0;
               
        while (index < len) {
                char b;
                int shift = 0;
                int result = 0;
                do {
                        b = [escapedEncodedPoints characterAtIndex:index++] - 63;
                        result |= (b & 0x1f) << shift;
                        shift += 5;
                } while (b >= 0×20);
                   
                float dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
                lat += dlat;
                       
                shift = 0;
                result = 0;
                do {
                        b = [escapedEncodedPoints characterAtIndex:index++] - 63;
                        result |= (b & 0x1f) << shift;
                        shift += 5;
                } while (b >= 0×20);
                   
                float dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
                lng += dlng;
               
                float finalLat = lat * 1e-5;
                float finalLong = lng * 1e-5;
               
                Waypoint *newPoint = [[Waypoint alloc] init];
                newPoint.lat = [[NSString alloc] initWithFormat:@"%f", finalLat];
                newPoint.lng = [[NSString alloc] initWithFormat:@"%f", finalLong];
                [waypoints addObject:newPoint];
                [newPoint release];
        }
        return waypoints;
}

Waypoints is a simple model class I’ve written with two NSString properties: lat and lng.

Tagged with:
May 30

Route.ly - Discover and share the best driving routes around the globeIt all started a couple of months ago. I am a keen biker and on one of the rare sunny weekends the weather god bestows upon England I decided to take my motorbike out for a spin.

The problem is, I’m not English. I didn’t grow up here so I know very few routes outside of London. I didn’t have a specific destination and wasn’t looking for culture. All I wanted was a spectacular windy road with breathtaking views to enjoy myself doing what I like most. Driving.

I quickly fired up a browser and asked Google whether they knew of some good driving roads around me. Needless to say I couldn’t find anything except for some blog post detailing how the writer had a blast that day with their friends.

When I arrived home that evening I decided to build a website to do just that – Discover and share the best driving routes around the globe – and now, after a couple of months of work, Route.ly is here.

No more disappointingly random day trips for me, or any other biker in unknown surroundings all over the world!

Tagged with:
May 09

Brilliant video posted by Fred Wilson on his blog.

If you can spare half an hour definitely watch it!

Tagged with:
Mar 09

I love calculating driving directions on Google Maps and then drag the blue line marking my directions to change the route. Everything is updated automatically on the page and the directions are re-calculated to go through the new point I defined.

I’ve been playing around with the Google Maps APIs recently and imagine my disappointment when I found out that Google does not allow directions calculated through the APIs to be dragged around.

Not put off by this I decided to try and replicate the directions-dragging myself. How hard can it be?
As it turns out. Very, at least if you want to make it look as smooth as Google’s own solution.

When generating directions Google Maps adds a GPolyline element overlay to your map. You can set the returned line to be editable but this makes an awful lot of vertices appear on it, which makes reading your directions quite hard. Even so, once you dragged one of this vertices around you are not editing the route but just changing the shape of the line.

Mine is not a complete solution and I’m interested in feedback and ideas on how to improve it.

First off calculate your directions:

map = new google.maps.Map2(document.getElementById(‘map_canvas’));
var wayPoints = [];
wayPoints.push(startPoint.getLatLng());
wayPoints.push(endPoint.getLatLng());

var myDir = new google.maps.Directions(map)
myDir.loadFromWaypoints(wayPoints, { travelMode: G_TRAVEL_MODE_DRIVING });

This will calculate your driving directions and plot a GPolyline on your map. The line is easily accessible in the GDirections object once the directions are calculated. To intercept this I have decided to use the addoverlay event on the GMap object. This event is triggered every time something is plotted over the map (says on the tin).

google.maps.Event.addListener(myDir, "addoverlay", function() {
var dirLine = myDir.getPolyline(); // Get the polyline from the directions object
});

At this point we can ask the APIs to make the GPolyline editable. This will make the vertices appear on the line and make then draggable. As I said before this only changes the shape of the line and doesn’t actually affect your directions object. Luckily the GPolyline comes with a nifty event called lineupdated.
This is triggered once the user has finished dragging a vertex. By intercepting this we can look through the vertices and know what’s been changed on the line and where the vertex has been moved to.
In order to do this we must also know the previous position of the vertices (latitude and longitude) to be able to compare the old and the new “edited” line.
Another challenge is the fact that the GDirections object can accept only so many waypoints (25 if I’m not wrong). Which means we’ll have to add only the vertex that has changed to the directions and not all of them.

// In the addoverlay event also save the original vertices of the line
var origLine = [];
for (var i = 0; i &lt; dirLine.getVertexCount(); i++) {
origLine.push(dirLine.getVertex(i));
}
// DONE saving vertices

// Now intercept the lineupdated event and add the new waypoints
google.maps.Event.addListener(dirLine, "lineupdated", function() {
routePoints = [];
for (var i = 0; i &lt; dirLine.getVertexCount(); i++) {
var savedPoint = origLine[i];
if (!savedPoint || (savedPoint.lat() != dirLine.getVertex(i).lat() &amp;&amp; savedPoint.lng() != dirLine.getVertex(i).lng())) {
routePoints.push(dirLine.getVertex(i));
}
}

// Now we remove the previous directions and recalculate the route
map.removeOverlay(dirLine)
calcRoute();
});

This works quite well but does not look as smooth as Google’s solution.
The problem is that while you are dragging a vertex only that bit of the GPolyline moves and the rest stays in its original position. which makes the shape of your directions quite awkward while you are dragging. Unforunately the GPolyline does not come with a “startdragging” event, otherwise we could just recalculate the route every few seconds while the vertex is being dragged.

This is not the most elegant of solutions but it does the job.

Tagged with:
Nov 26

What do you need to know? Java Enterprise Edition. That’s the simple answer.
If you read between the lines what I’m really saying is: “You better make sure you really don’t give a flying toss about technology and don’t care about how frustrating what you spend most of your day doing is.”

A few days ago I was talking with a friend who’s in the process of interviewing with a few big financial institutions in London. The most common questions according to him. Struts, JEE.
Spring was also mentioned by I don’t have much against Spring. If used properly it really does keep your code tidy and avoids duplication.

You see a bank’s idea of a high performance reliable system is a monolithic Java application running a million-billion threads at the same time on a huge machine. Maybe that’s a bit too harsh. Sometimes they do distribute. They just add 15 layers shooting messages at each other in between the 2 they actually need.
Then they wonder why the best talent winds up working for Google, and their budget to deliver 1 application is twice what Facebook spent to build its entire social network.

What I have a problem with is the architects who design these systems. And the clearly-drunken bank managers who hired them.

Dumb and DumberThe most common profile for architects in investment banks (and I met quite a few) is 50-something, stopped following/reading about technology in 1995 and prior to being employed by Mr Mighty WankBank (Thanks City Boy for the name) was VP of over-engineering at the Apache Software Foundation (focused on Struts).
First thing in their TODO list is hire some bright spark straight out of university who has a keen interest in over-engineering and never had to deliver anything in less than a geological era.
That’s when an overpaid team of consultants comes in to “sort-it-out”, at which point the bank loses control over its source-code and none of their developers can understand it any more.

Oh, and then there’s the process, oh the bureaucracy.

Fortunately I also know that in London there are a few sunny spots (techonology-wise) such as Hedge funds who started using Erlang (for example) to distribute their heavy computations over a network.

Now don’t get me wrong I have nothing against JEE per-se. Some of the libraries are actually very useful and improve a developer’s quality of life quite a lot. Just think about JTA.
What is wrong is the way they are used by people who never left the nineties.

Nov 21

While skimming through my RSS feed I stumbled upon an interesting article on Ajaxian about server side JavaScript programming.

I really, really enjoy writing JavaScript code so I decided to read through the article and take a look at the node.js library linked there.

node.js logo

Node is a framework to build server-side event-driven JavaScript applications. Developed in C++ on top of Google’s V8 JavaScript engine and accompanied by a set of JavaScript libraries Node seems to make building distributed (over a network), fast applications a piece of cake even for inexperienced developers.
Event-driven here really is the keyword because it represent a big change in the way applications are built (and architected in your brain).

Node is similar in design to and influenced by systems like Ruby’s Event Machine or Python’s Twisted. Node takes the event model a bit further—it presents the event loop as a language construct instead of as a library. In other systems there is always a blocking call to start the event-loop. Typically one defines behavior through callbacks at the beginning of a script and at the end starts a server through a blocking call like

EventMachine::run()

. In Node there is no such start-the-event-loop call. Node simply enters the event loop after executing the input script.

The example below (taken from Node’s website) will make everything clear… hopefully.

var sys = require(‘sys’),
     http = require(‘http’);

http.createServer(function (req, res) {
  setTimeout(function () {
    res.sendHeader(200, {‘Content-Type’: ‘text/plain’});
    res.sendBody(‘Hello World’);
    res.finish();
  }, 2000);
}).listen(8000);
sys.puts(‘Server running at http://127.0.0.1:8000/’);

Can you see the beauty?!

I have only one worry. This is an open-source effort. The community behind it on Google groups is just 181 members strong (so far). What if node.js suddenly stops being the cool thing and the community disappears.

As much as I love writing JavaScript and I can really see the value in what they are building I’ll still wait until there are 100 Google Groups for node.js and a trillion members in each before using it in anything close to a production system.

Having said that I’m going back to writing silly node.js apps now. Well done to all the developers involved in the project and keep it up!

Tagged with:
Nov 18

When I started developing TweetSentiment I decided that the interface should have as little text as possible. Most of the information I was interested in could be displayed graphically, with a chart.

So I looked at all the options available for chart generation.

  1. Backend code to generate a static image (JFreeChart or PHP)
  2. Flash object to draw a chart retrieving the data from a URL
  3. Draw charts in JavaScript directly on the client’s browser

I’m not a huge fan of option one. Primarily because TweetSentiment is hosted on a tiny linux box which would not be able to handle the load for the traffic the site gets, also because it’s a static image – it’s just not very funky – no interaction possible.

Option two would certainly create spectacular looking charts but I have almost no experience with flash and I wasn’t about to start learning a new language/technology. Plus I’m not into browser plugins if I can avoid them.

JavaScript is a language I’m familiar with and I remember seeing some cool-looking charts generated with Dojo. Unfortunately for TweetSentiment I have used jquery since the most important thing for me there was DOM manipulation (and jquery is just better for that).
I then started shopping around for jQuery plugins to generate charts. There are a few around but none of them impressed me. They just weren’t as good looking as I’d hoped nor they were interactive.

By coincidence I stumbled on RaphaelJS. A JavaScript library to draw Scalable Vector Graphics directly from JavaScript based on jQuery. I tested the samples on the website with a few browsers and I was happy to discover it worked just fine with all of them.

Scalable Vector Graphics (SVG) is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic (i.e. interactive or animated).

The SVG specification is an open standard that has been under development by the World Wide Web Consortium (W3C) since 1999.

I also discovered that there is a charting library built on top of RaphaelJS, which is exactly what I was looking for. However, being a geek, I decided to go ahead and try to develop something on my own. You know, just for kicks.

As I delved deeper into RaphaelJS I found the library to be incredibly powerful. It’s a shame that the documentation provided on the website lets it down a bit.
The most powerful bit is the ability to extend objects and attach new functions to them. Something scarcely mentioned in the available documentation.

For example if you need to use curved lines (paths as SVG calls them) you can just defined a default function you can then call from your code simply by adding it to the el “object” in RaphaelJS

Raphael.el.curveTo = function () {
  var args = Array.prototype.splice.call(arguments, 0, arguments.length),
  d = [0, 0, 0, 0, "s", 0, "c"][args.length] || "";
  this.isAbsolute &amp;&amp; (d = d.toUpperCase());
  this._last = {x: args[args.length - 2], y: args[args.length - 1]};
  return this.attr({path: this.attrs.path + d + args});
};

Another very useful function I found in one of their samples is the andClose() This is used to close a polygon you have started drawing with paths. No matter where you got to it will reconnect to the initial point.

Raphael.el.andClose = function () {
  return this.attr({path: this.attrs.path + "z"});
};

This can then be used this way using chaining.

RaphaelJSElement.lineTo(x, opts.height - bottomgutter).andClose();

I’m still developing the chart library I used in TweetSentiment and I’m planning to publish it here with some documentation under MIT licence.

Tagged with:
Nov 15

Every single journalist on the interwebs has already chanted praises for this game. And I intend to do exactly the same.

Last week I optimistically bought a copy of the PC version of Dragon Age. Optimistically because I realised only after the purchase that my PC at home was an old AMD 2.2GhZ with 1GB or RAM and a puny geforce 7900 GTX (or something like that).

It took some compromising but the game runs. More then my computer being able to deal with it I suppose it’s the game caring for my PC as you would with a senile pensioner.

Nevertheless I played for a few hours yesterday and I have this to say. They got it just right.

Dragon Age Battle ScreenshotI was a huge fan of the original Baldur’s Gate series and played it over and over. Mostly because I was at school at the time and spare time was plentiful and cheap.
Why was I fan? Because of the storyline. It was stupendously enthralling.
After BG I stuck with BioWare and bought Neverwinter Nights. Everybody raved about it yet I didn’t like it. Very little control over the whole party. And the little you had was spoiled by a  slightly awkward control system.

The toolset they released with Neverwinter Nights was also mightily impressive. You could see that was the start of a revolution in the way RPG were played and content was created for them. Unfortunately, as most first editions/tries, it lacked in functionality and flexibility.
This, as far as I’m concerned, also put a cap on game designer’s creativity when they were writing the main campaign story.

I’m glad to see they have worked all these things out. Everything I didn’t like in Neverwinter Nights is now fixed in Dragon Age.
The game just flows.
This is thanks to a beautifully written and very compelling story, a more intuitive and usable control system and a fantastic toolset. Which I believe put the power back in the game designers’ hands and allowed them to really go to town with the storyline.

It’s a fantastic game. If you don’t know it watch the trailer video, buy it, lock yourself in your room and start playing.

Tagged with:
preload preload preload