Tag Archives: national rail

Hackference 2016, Part 2 – The Hackathon

<- Part 1: the conference
On Saturday, once everyone had got a good night’s ‘sleep’ (our hotel was just next to a loud club which only got quiet after 3am), we walked over to the Impact Hub.

Before I get started, I’m using the word ‘hack’ in the non-malicious form. Tabloids use the word ‘hacker’ to describe someone with malicious intent who steals data or takes down websites (for example, this article in the Mirror). We use it to describe someone who thinks the best way of learning is by doing. A hackathon is just a group of sleep-deprived developers playing with something new.

The event itself was free – paid for completely by the wonderful sponsors.

Before the hackathon started, not many people knew what they wanted to make (including me). Luckily the sponsors got a chance to inspire us with their products and announce their prizes. There was a variety of companies attending, each with some cracking prizes for the teams making best use of their services.

Continue reading

Advertisements

Trntxt bumper update

It’s been a while since I’ve posted an update on trntxt, and in that time lots of things have changed. Most of those things haven’t changed the site’s appearance at all, but I can assure you that I’ve been very busy with it over the past few weeks.

Service messages and bus times

Trntxt now shows you service messages from National Rail and timings for any rail replacement bus services. Days and days of work condensed into a single sentence…

nrcc

In order to make those changes simpler to implement, I had to make quite a few changes in the background. In doing so I learned more about the Jade templating engine and created a Mocha test framework with the help of Thom Wright at one of the Hack Nights run by CodeHub Bristol.

Little changes

Better station search

When typing a station name in the address bar, a more complex search takes place. Beforehand in order to match a station, the input had to match a portion of the station name exactly. Take for example, the station ‘Heathrow Airport Terminals 1, 2 and 3’. Originally, if you searched for ‘terminal1’, it wouldn’t produce a match. Trntxt removes all spaces and punctuation from the station name, but even then ‘terminal1’ doesn’t appear exactly in the station name – you’d need to have ‘terminals1’ which isn’t immediately obvious. Now it checks the station name to see if all the characters are there in the right order. You can type ‘lonwat’ for London Waterloo and it will return the match.

While writing the improvements to the search function, I made sure that the changes didn’t break anything else by running the tests. The test framework essentially contains a list of inputs along with their expected outputs. When I wanted to write a new feature or fix a bug, I’d put in some failing cases with the result it should return, then I carry on coding until the tests pass.

By running the tests automatically each time I save the code, I can be confident that the new code doesn’t negatively impact any of the past test cases because they are all checked every time.

tests

Appearance improvements

appearance

I decided that while still being minimal, I could improve the appearance of trntxt’s output. The 4 dashes I originally had to separate items have been replaced by a line; I’ve reduced the wordiness of each item description and the CSS fits inside a tweet (just because)!

#TweetYoCss

Preventing unnecessary app icon downloads

While investigating the network traffic to trntxt from different devices, I noticed that Android devices wanted to download the high resolution app icons for Apple devices, which is a bit of a waste when that icon is never shown. I now run a check to see what device is accessing the site, and only send links to appropriate icons for that device. It’s fairly unnecessary and especially not worth the effort to do it, but I did it anyway. Turns out it’s easy enough to modify the content of Jade documents based on various parameters, plus I was annoyed that all the icon tags almost doubled the size of the response (see below). I probably shaved nanoseconds off the page load time.

appicons

More to come

I’m not finished yet! There’s always something else I want to add to trntxt. Search suggestions coming soon!

suggestionMockup

Train Times Made Simple With trntxt.uk

TL;DR: I made trntxt.uk, a data-friendly train times website.

Over the past few weeks, I’ve meed putting a little bit of my free time into developing a train times website.

The idea came to me after a JSOxford talk by Tom Lane about open rail data. It turns out that the data you see on train station departure boards is all accessible, so long as you register for a free API key.

I decided that the reason why the train times app on my phone wasn’t working was because the data was taking too long to arrive over a 2G connection, so I thought I would try and speed things up a bit. I’d make a website without using anything unnecessary, and in doing so I’d have a website that works well on whatever device you’re using.

trntxt.uk

I call it “Train Text”. It works like this. Let’s say you’re at London Paddington and you want to find out when the next train to Bath Spa is.

You would point your phone’s browser at trntxt.uk/paddington/bathspa. You don’t need to use the full name of the station – just use part of the name and trntxt will probably find it. Just ignore spaces or any other punctuation. If you know the 3-letter station codes, you can use those too and save some typing time in the process (trntxt.uk/pad/bth). trntxt makes these station codes visible to help you remember them.

The website was designed so that even my old Nokia 6303 can access it correctly on a slow 2G connection.

image

I’ve stripped out everything unnecessary so that you can get the fastest responses possible (more on that in another post). That’s why it doesn’t look very good 😛

There are, however, some limitations. One of them being it can only handle direct routes. If you’re traveling from Swindon to Oxford, you need to change at Didcot. You’ll need to make a request for Swindon to Didcot, then another from Didcot to Oxford.

It doesn’t do arrival times yet, but I’ll get them in soon!

What’s more annoying is that after I made the site, I realised that it seems to work everywhere apart from Bath Spa station.

image