Last Thursday (and Friday) proved to be an interesting day, both for myself and the people of Lincolnshire. It’s been well documented by the media how well UKIP did both nationally but in Lincolnshire it was especially interesting as we’ve been a blue county for decades and we now have a very different (and colourful) political landscape.
Here is how the map looked before and after the election:
I spent Thursday evening sat with the guys from The Lincolnite drinking cold water and redbull trying to stay awake as we sat in the county council chamber from 9:30pm until almost 5am waiting for results to come in from across the county.
I took a few photos over the course of the night:
When results came in these boards would be updated with the results
The media teams (The Lincolnite team, BBC Radio Lincolnshire and BBC stringers calling the results into London)
An example results paper that was filled out and passed around when results were phoned in from across the county
Taken around 4am as we waited for the final few results to come in. By this point a few other journalists had turned up as well as successful candidates, political wonks and other interested parties
For the interactive map Daniel (The Lincolnite’s editor) and I really liked the idea of having a “bar of power” across the top of the map which showed a visual makeup of the 77 divisions and was sorted left to right by the parties with the most seats. Each little division was clickable too and zoomed into the map. It also proved a useful way of seeing how many seats were left to be called as some of the divisions such as Stamford North are tiny to see on the map.
At 10pm (when voting stops) we switched the map to one that had no colour and just showed the outlines of the different divisions. Every 30 seconds an ajax request polled the server for the latest results and updated the map and bar of power with the winning colour and when a user zoomed into an area it would show the final results.
As results came in I sat and updated my very sexy admin interface with the number of votes each candidate received:
The Lincolnite team were running a live blog which had the map embedded at the top so for the many readers who were keeping an eye on the page throughout the night they had a nice realtime (ish) experience.
I learnt a few new things whilst developing the updated map. The main thing was how jQuery promises worked which meant that until all 77 divisions had loaded (almost 2mb of JSON) the ajax poller wouldn’t start. I also included a nice little loading message too which appeared and disappeared as the status of the deferred object changed.
I also learnt a lot more about the Leaflet.js API and I’m definitely going to use it again if I can come up with another geospacial project to work on.
We learnt a few things from this little experiment.
First of all is that we need to work really closely with the county council to try and get all of the data required in a more usable format (such as CSV) as we wasted so much time going through 77 PDFs and manually copy and pasting names, parties and districts.
Next we need to work with the local party associations so they can update their candidates biographical information themselves without them having to speak to us every time they want someone’s photo changing.
Tony Hirst wrote a nice roundup of other websites who also created live maps. He also speculates if “this will be the last round of elections without a national live data feed from somewhere pushing out the results in a standardised form”. I’ve been thinking about this a lot and I’m wondering if it might be worth teaming up with OpenlyLocal and MySociety to create some sort of national service. Perhaps more on that later?
All in all I had great fun making the maps, I learnt some new stuff, The Lincolnite got some well deserved coverage and praise and I also decided that I don’t find myself waiting for Stamford North to finish counting their votes at 4:30am again.
A few weeks ago I was approached by the guys at The Lincolnite to look into developing an interactive page for the upcoming Lincolnshire County Council elections on the 2nd of May.
Part one launched yesterday and here’s what I’ve come up with:
The map loads GeoJSON representations pf all 77 electoral divisions in Lincolnshire County Council and renders them on a custom Mapbox map (which hides a lot of unnecessary map detail such as buildings) using Leaflet.js. Each division is coloured in with the colour of the party that is currently represented in that area. When a user clicks on a district it zooms in and displays in the right hand column the current councillor and a list of the 2013 candidates.
In the right hand column users can also enter their postcode which is sent to MySociety’s excellent MapIt service. If the postcode is real and is in the Lincolnshire County Council area then it will return with the ID of the division which will then zoom the map in and show candidates as above.
I encountered a few challenges along the way. First getting the candidates data was the most labour intense thing I’ve done in a while and there was no easy way to automate it.
Basically the council had a semi-complete spreadsheet of results from 2009 which after a bit of mangling provided me with an initial set of results which I could use to colour the map in (and I will use again for part two to compare this year's results to previous results). In 2012 there were two by-elections and I found the results for these not from the council but local newspapers.
To get the 2013 candidates I had to wade through 77 differently formatted (depending on the parent district council) PDFs to manually copy and paste the candidates into my own CSV. One district council didn’t even include the parties the candidates were representing and I had to get this from another CSV provided by the county council (which didn’t include candidates’ first names otherwise I’d just have used that).
All of the CSV data was then loaded into a MySQL database and the Lincolnite guys can easily update candidates with links to photos and manifestos.
The other problem I had was trying to find a javascript mapping library that gave me the flexibility I needed and also wouldn’t grind to a halt when I fed it 77 GeoJSON encoded divisions.
I ruled out Google Maps because I couldn’t easily customise the map of Lincolnshire (i.e. remove buildings and make the roads, land and water lighter). Also everyone uses Google Maps and I wanted to play with something different for a change. I tried Mapbox’s own javascript framework with D3.js but that cried when I added more than about 30 divisions. I finally discovered leaflet.js which I really struggled to get my head around the API in order to make it do what I needed but it was very lightweight and the performance is fantastic.
So part one is out, and there’s just under a week to go until the elections which gives me a few days to finish off part two which is when the map will live update when results come in and update swingometers and other funky widgets on the fly.
On the 13th of September 2008 I moved to Lincoln to study computer science at the University of Lincoln. Fresh faced, excited to move out of my parents’ house and looking forward to experiencing phone signal for the first time, the 18 year old me was ready to start a new life.
Fast forward almost 5 years and it’s time to start again.
At the end of May I’m leaving this beautiful city to move to my other home from home, London. I will be joining Pro-G Media, the proprietors of the very popular and highly respected VideoGamer.com as their new senior developer.
I leave Lincoln with many many great friends, four great years of employment at the University of Lincoln, five JISC projects under my belt, and a new found love of coffee. I’ve made some great contacts at many universities around the country, I’ve attended tens of conferences and I’ve presented my “Introduction to HTML5 and CSS3” presentation more times that I’d like to remember. I even managed to fit a degree in too.
To those who’ve given me opportunities here, especially Joss Winn, I’m incredibly grateful, and I’m sure I’ll be back to visit soon enough. I’m going to miss working (read: eating bacon, drinking coffee and dreaming up crazy hacks) with Nick Jackson, Jamie Mahoney, and Harry Newton every day but we’ll all be living on the East Coast mainline so I’m sure we’ll be regularly meeting up.
I intend to remain in contact with the higher education and library developer community and I remain a strong supporter of the data.ac.uk movement and will try and take part in the discussions where I can.
I’m beyond excited about moving to London and tackling many new challenges, from actually moving to London (more on that later), to helping VideoGamer.com expand to a million daily visitors and beyond.
Not only that but I’m looking forward to being able to explore a different Sunday market every week of the year, go to far more music gigs than I’m currently able to, and I’m sure there are many delightful bars and coffee shops that I need to research and visit. Also I’m determined to live in a flat again that has gas hobs on the cooker - my wok can’t wait!
So thank you Lincoln, thank you Lincolnites, and thank you @unilincoln. London, please put the kettle on!
“The story of life is quicker than the wink of an eye, the story of love is hello and goodbye...until we meet again” - Jimi Hendrix
I'm sat writing this as I watch the One Show which is the final ever live broadcast from BBC Television Centre.
I've been fortunate to visit Television Centre twice, once just a fortnight ago today, and also back in July 2011. My close friend Josh was working there both times I visited and he gave me a full tour of the entire building in 2011. I remember walking round in near silence as I absorbed 50 years of broadcasting history - it really is an incredible building which just oodles culture. I particularly remember visiting the Blue Peter garden and having my photo next to the Tardis. We also stood in the tech gallery and watched as the audience were warmed up for Jool's Hollands show.
Whilst I don't have any more experiences that I do feel truly honoured for having the opportunity to visit somewhere where so many of my favourite TV shows were filmed, from Blue Peter to Black Adder and Fawlty Towers.
On Tuesday I presented at the first ever PHP North East conference in Newcastle. Hosted in the fantastic Tyneside Cinema (which is the last surviving Newsreel theatre still operating as a cinema full-time in the UK), it was a very well organised event and I’m incredibly grateful to the PHP North East group for accepting my talk proposal.
My topic was “API driven development: Eating your own dog food”, I’ve embedded my slides below:
Unfortunately they weren’t able to video my talk so my slides may seem a little out of context but hopefully you can get the overall gist of what I talked about.
Once again, I’d like to say thank you to Anthony Sterling and the PHPNE crew for putting on a wonderful event.
Basically if you are developing an OAuth authorisation server then you must whitelist the entire redirect URI, not just the domain. In the OAuth threat model specification there is a whole section (4.1.5) dedicated to discuss pitfalls with open redirectors.
If the authorization server allows the client to register only part of the redirection URI, an attacker can use an open redirector operated by the client to construct a redirection URI that will pass the authorization server validation but will send the authorization code or access token to an endpoint under the control of the attacker.
Also if you have to use the implicit grant for whatever reason then as I said in my guide to OAuth grants you must bear this in mind:
If you decide to implement this grant then you must be aware that the access token should be treated as “public knowledge” (like a public RSA key) and therefore it must have a very limited permissions when interacting with the API server.
Unless you have a very very specific need and you can perhaps secure clients with client side certificates or you have a very clean environment then I strongly recommend you just avoid the implicit grant.