Kerry Buckley

What’s the simplest thing that could possibly go wrong?

Archive for the ‘Uncategorized’ Category

The value of spiking: a cautionary tale

leave a comment

A while ago I built a little web app using the Strava API, that tells you how far you’ve run so far this year, and how many miles you’re projected to do my the end of the year if you keep up the same average.

As Strava lets you see your friends’ year-to-date mileage on their profile pages, I thought it would be a nice addition to generate a leaderboard to show where you stood against your running friends. The URI to query an athlete’s stats is https://www.strava.com/api/v3/athletes/:id/stats, which I’m already using to get the stats for the person using my app, so all I have to do is query that person’s friends list and map over all the IDs calling the same API with their IDs, right?

First things first, mock up the UI for the new page. After a bit of wrestling with Bootstrap I had some navigation elements I was happy with, so moved onto the core app. It turned out that the Strava library I’m using didn’t have a wrapper for the friends/followers API, but it was pretty easy to add one, so I made the required changes and submitted a pull request. Then a nice test-driven feature from the outside of the app, stubbing the boundary to the function that retrieved the stats for each friend, as that was already there for the current user and didn’t need to be changed. A data structure specifically to hold the friend’s name, profile URL and mileage to display in the table, and a public function to return a list of those structs, and the core was all done.

Finally I put it all together, wired the controller in the web app up to the core function to make the required query, and modified the view to display each friend’s details in a row in the leaderboard. Tests all green! Finally! Let’s try it out!

500 internal server error

Wait, that’s not supposed to happen. Lets look at the logs. Hmm, the call to the Strava API seems to be failing. Unauthorised. That’s odd.

Better take another look at the API documentation.

Totals and stats

Returns recent (last 4 weeks), year to date and all time stats for a given athlete. Only available for the authenticated athlete. This is the recommended endpoint when polling for athlete upload events.

Wait, what’s that bit in the middle again? “Only available for the authenticated athlete”. Oh. Realisation dawns. No leaderboard then, and a couple of days’ work wasted on a branch that’s never going to make it into master.

So what’s the moral of the story? If you’re building a feature that relies on something outside your control, don’t make assumptions about what works and what doesn’t. Build a spike first, to test your assumptions before ploughing your time into building the real thing.

Oh, and read the documentation.

Written by Kerry

August 2nd, 2017 at 7:31 pm

TDD example with Rails, Cucumber and RSpec

one comment

In the unlikely event that anyone wants to scroll through the whole history of the TDD demo Rails app I did the other day, I wrote a little script to munge it all into one page. And here it is.

Read the rest of this entry »

Written by Kerry

March 27th, 2015 at 11:22 pm

Posted in Uncategorized

Commenting broken

one comment

Commenting seems to be broken on this blog since I upgraded WordPress. Not sure why yet, but I’m working on it.

[Update] It’s working again now.

Written by Kerry

August 15th, 2009 at 7:48 am

Posted in Uncategorized

Tagged with

Comments aren’t always evil

4 comments

I tend to agree that comments are, in most cases, evil (or at least mildly malevolent), but I did come across one of the exceptions to the rule today.

While doing a bit of drive-by refactoring while fixing a bug, I reflexively changed this line:

unless instance_response.nil?

to this:

if instance_response

Then reading the comment above the line, expecting to delete it, it all came flooding back:

# Use instance_response.nil? to check if the HTTParty
# response's inner hash is empty.
# If you use 'if instance_response', it is always true.

Now you could maybe argue that this unexpected behaviour is because httparty uses just a little too much of that old method missing proxy magic (which of course isn’t really magic at all), but that’s not the point of this post.

In the end I pulled it out into a private method to make it clearer what was going on, but decided to leave the comment in.

def self.instance_returned? instance_response
  # Use instance_response.nil? to check if the HTTParty
  # response's inner hash is empty.
  # If you use 'if instance_response', it is always true.
  !instance_response.nil?
end

Written by Kerry

August 14th, 2009 at 9:21 pm

Domain Problems

leave a comment

As you may have noticed, kerrybuckley.com has been down for a few weeks now. This was mainly due to incompetence and laziness on my part causing the registration to expire (the hosting’s still fine), but so far the registrar has yet to respond to e-mails and messages on their 75p/min voicemail service.

For now (as you’ve obviously discovered) you can find me at kerry.ontoa.st instead (temporary feed links over on the right, assuming you’re not reading this in an RSS reader, in which case I guess you’d already figured them out). Please pass the word to anyone who might have noticed I was off-air.

Written by Kerry

February 20th, 2008 at 10:15 pm

Posted in Uncategorized

Chocolate Type

2 comments

Mmm…

Written by Kerry

December 9th, 2007 at 10:04 pm

Posted in Uncategorized

[BarcampLondon3] How to Animate a Silly Walk (Cathy Jones)

leave a comment

This was a hands-on session playing with lo-fi flip-book animation, based on the techniques on Cathy’s blog. Here’s my very poor effort:

Technorati Tags: , ,

Written by Kerry

November 24th, 2007 at 6:40 pm

Posted in Uncategorized

[BarcampLondon3] Creating a Lifestream with Yahoo Pipes (CristianoBetta)

2 comments

It’s all here!

Technorati Tags: , ,

Written by Kerry

November 24th, 2007 at 3:37 pm

Posted in Uncategorized

Sponsorship Request

leave a comment

Jane as SantaJane‘s been talked into running round Christchurch Park dressed in an oversized Santa suit in aid of East Anglia’s Children’s Hospices. If anyone feels like sponsoring her a few quid it would be greatly appreciated, and is dead easy to do online. Thanks!

Written by Kerry

November 23rd, 2007 at 9:38 am

Posted in Uncategorized

Barcamp Brighton

6 comments

I was lucky enough to attend BarcampBrighton at the weekend, thanks to a tip-off from psd and the fact that I had to be down the road in Eastbourne today anyway for our release planning.

For those unfamiliar with the Barcamp concept (which until recently included me), no schedule is set in advance, but attendees turn up with either a prepared talk or some ideas of subjects they think people might be interested in. On Saturday morning after the introduction we each scribbled a quick description of our session on a slip of paper, and stuck it in a free slot on the agenda grids, creating an instant [un]conference with five half-hour talks happening at once for the two days.

I’m not going to try to describe everything, or I’d be here forever (after all, I still haven’t finished writing up Agile2007), but highlights included being taught how to do this card trick by nicepaul, an audience discussion (neatly driven from a tiddywiki) on whether someone should buy a Wii, and talks about subjects ranging from web site accessibility and internationalisation to geocaching. Oh, and of course the obligatory (and my first) games of Werewolf. I did a demo of Selenium, which seemed to go down well, albeit with an audience of four (it was the last session on Sunday, and I was competing with Powerpoint Karaoke).

All in all, one of the best conferences I’ve been to. Which isn’t bad for free (with food and beer thrown in)!

In some ways the event almost seemed to run itself, but obviously that was largely down to the incredible efforts of all the organisers and helpers (especially the hosts, Madgex, who gave up their offices to nearly a hundred messy geeks for the weekend). A huge thank-you to them, and to the various companies who provided mountains of food and drink during the weekend.

Technorati Tags:

Written by Kerry

September 10th, 2007 at 5:57 pm

Posted in Uncategorized