Push Notifications on iOS

As with anything new on iOS, getting push notifications working has been a pain. Thankfully, there’s a brilliant write-up of the process here: Apple Push Notification Services in iOS 6 Tutorial: Part 1/2.

Plus the PhoneGap/Cordova plug-in to make it all work here: phonegap-plugin-push.

Posted in PHP, Programming | Leave a comment

Ride London 2015

Last year’s Ride London was a complete wash-out, but still strangely satisfying despite the diminished achievement of “only” cycling 86 miles in the remains of a hurricane. But with a ballot place secured, this year I was confident that I could cover the 100 miles and had my sights set on a better time. Both a slow 2014 time and an upgrade from hybrid to road bike in early spring made that goal achievable, but there’s no doubt that an extra year of riding, and a lot of long rides in the build-up, put me in a much better position than I was last year.

There was no way the weather could be worse than last year. In fact, I can’t think of a single way that conditions could have been better: light winds, strengthening from the south during the day to push us back into London; and the temperature, if a little on the warm side, wasn’t blazingly hot – at least it wasn’t if you kept moving.

The first challenge to overcome was the hour-long wait before the start. Chatting to a couple of other riders, stuffing some more food into me, and finding a portaloo that I figured would buy me another hour on the road all passed the time, though. The organisation at the start line seemed even better this year too and we set off dead on time at 8:15am.

I had resolved to take it easy for the first hour, but riding along with hundreds of other cyclists just seemed so much easier than solo rides that I found I was cruising at close to 20mph without seeming to need much effort. The target time I’d put on my application form was 6 hours 50 minutes, although I was confident in beating that and was hoping for close to 6 hours on the bike, and at this rate I’d be well under that time.

As well as increased speed, hill training was also paying off as Richmond Park felt much flatter than I remembered it being last year. Maybe we took a different route around it. I also felt that, in contrast to the 2014 ride, I didn’t have quite the same stream of riders passing me by and I seemed to be spending more of my time on the right hand side of the road than the left.

From the official times, my easy first 25 miles were covered with an average speed of about 18.5mph – not fast by a good rider’s standards but way above what I would achieve on the road alone, and I hadn’t felt like I was pushing myself hard either.

I stopped to refill my water bottles at mile 38 as I’d already finished the litre and a half I’d taken to the start line. My bladder was feeling the effects of that too, but after taking one look at the queue for the toilets I decided I’d push on to Newlands Corner as I remembered there being much better facilities there. Then a few miles down the road I spotted a few portaloos set up over to the right in the layby of a National Trust property. I checked behind me, moved over to the right hand side of the road and put my hand up as I slowed. Disaster nearly struck as a slower rider on the left hand side of the road spotted the same toilets and took a sudden right turn towards them, cutting right across my path. I think I might have been able to stop even if he hadn’t, but with my back wheel locked up I came very close to ploughing into the side of him.

Still, portaloo navigated with the absolute minimum of surfaces touched along the way, it was time to put something other than Soreen malt loaf and oat bars into my stomach and I broke out the sandwich I’d packed that morning. With a target to beat I wasn’t going to waste any time hanging around in a layby so I ate it on the move and, with a masterstroke of bad planning, I was cramming the last of it down just before hitting the hill up to Newlands.

Billed as one of the big three hills on the ride, Newlands didn’t seem particularly steep nor particularly long. I skipped the hub at the top and was looking forward to Leith Hill in another ten miles. My average speed had dropped slightly due to the stop for water and at the toilets, but at 47 miles I was at 2:41:33, including the two stops, which would put me at close to 5:30 for the full distance – a time I never thought I’d get anywhere near.

Trouble struck just at the beginning of the climb, though, as it was obvious that the gaggle of riders just ahead weren’t cycling slowly up the hill but were either walking or, a bit further up, just standing still. There was no point trying to ride at that speed so I got off and walked like everyone else, but within a few minutes we were at a standstill. Shouts from down the hill had us lining up either side of the road to let two police motorbikes and a support car past and it was obvious there was something happening up ahead. Although, I have to say I was impressed at how everyone cleared the road so quickly to let the emergency vehicles past.

With the summit still over a mile away it seemed possible that an accident on the descent had blocked the road, which would mean an extremely long wait or, more likely, someone had gotten into difficulty on the way up. Twice more we had to clear the road to let both a St Johns Ambulance and a regular ambulance past, and the sound of the air ambulance landing a few hundred yards away made it more likely that it was something that had happened on the climb. That indeed seems to have been what happened and news has emerged today that a 55 year old man died on the lower part of the hill.

Around 40 minutes after we had been brought to a stop a marshal walked down the hill telling us that the police would be opening the road soon and the ride would be resuming. I’ve no idea how many people were behind us by now but when we set off it became clear that the incident had only happened a hundred yards ahead of where I was and there must now be a couple of thousand cyclists backed up down the hill.

Setting off up the hill wasn’t easy, especially as many were either walking or struggling to clip in and get started on the slopes but weren’t getting out of the way for those that were riding. I also discovered that my speedo doesn’t register anything less than 2mph. But within another hundred yards the road started to clear and I had a relatively free run up the steepest parts of Leith Hill. This part of the route had been missed out last year, and rightly so, but I’d ridden up it as part of a sportive a few months later. It had seemed obscenely steep back then, but this year it wasn’t too bad at all.
So, with the biggest test of the day out of the way, it was just a long descent and a few more miles to Box Hill, something I was genuinely looking forward to as I’d ridden it once before and remembered it as relatively gentle with some great views.

Progress was slowed slightly by the reintroduction of slower riders. We had surmised whilst stopped at the bottom of Leith Hill whether the short-cut would be put into use and indeed it had, no-doubt due to the sheer volume of riders that would have been backed up behind the road closure. Now riders who had been sent around Leith Hill to avoid a logjam were filtering back onto the main course, the only problem that they were about an hour ahead of where they would have been and travelling a fair bit slower. It’s hard to remember that last year I was one of those bothersome charity riders when you just want to get moving, but the point of the event, and the relatively flat course profile, is intended to encourage exactly those kinds of riders in the first place. Riders like I was eighteen months ago, or even six months ago. No doubt there were many along the way this year who wished I would just get out of their way too.

As the road turned up Box Hill the number of riders struggling with the distance combined with the climb became apparent. Box Hill isn’t all that steep, although it’s longer than Leith, and although there weren’t many riders walking up there were quite a few moving slowly and in a way that suggested their legs would keep turning but there was no more speed in them. This and the other small hills before the end were the points where the huge volume of riders on the road became apparent as there were times when there was just no way past. Still, I’d had plenty of benefit from sitting in the wheels of other riders or moving between groups so this was only a small price to pay.

Over the top of Box Hill, avoiding riders who had decided it was okay just to stop in the road to take a photo, there was another long and fast descent. Both water bottles were running low again so I stopped at the hub in Leatherhead at mile 75 and had to queue for some even less pleasant portaloos. Before Leith Hill I had my mind on a good event time as well as a good on-the-bike time, but the 45 minute stoppage had put thoughts of that out of my mind. Anyway, it seemed a good time to sort everything out at once and I figured I had enough fluid both on my bike and out of my body to reach the finish. Now it was just a case of judging my energy for the last 25 miles.

And the last 25 miles flew by. According to the stats, miles 75 to 85 were covered at 19.7mph and 85 to 100 at 21.2mph, which is a 20.6mph average for the last quarter of the entire ride. It felt good to be finishing strongly and I found myself riding along with a fairly fast group at the end and having the rare experience of riders wanting to stay on my wheel rather than the other way around.
The Mall was a bit crowded for a sprint finish so I just tried to leave myself a gap in front in case any of the photos looked half-decent. Given my bolt-upright riding position at the best of times I’m sure they won’t, but one can hope.

My legs were tired at the end, but then I’d been burning as much as I could to finish fast. There was just some food and drink to be had before the ride back home. By the end of the day I’d covered 115 miles in total, which is just a touch further than my longest day’s ride back in May.
My official finish time was 6:35:58. Take off the 45 minutes being stationary on Leith Hill and the ride was easily under 6 hours. Knock off another ten minutes for the three stops and that gives me about 5:40 on the bike, a time which I’m both extremely happy with and determined to improve upon, if I get another chance.

Already I’m hoping to get another ballot place next year, although 2015’s event is going to be a tough one to beat.

Posted in Cycling | Leave a comment

A Few Portfolio Links

As part one of the long-term “putting myself out there a bit” plan, I’ve put together a mini portfolio site. It also means that the URL doesn’t give a 403 error too.

There isn’t much there but at least it’s something to point people to, and hopefully it’ll appear in Google at some point.

Posted in Other | Leave a comment

Build an HTML5 Game: Some Reviews

Build an HTML5 Game CoverI’ve found three decent reviews for my book “Build an HTML5 Game“, and especially pleasing is the fact that two of them seem to be from exactly the target audience i.e. developers with existing web skills who didn’t realise how easy it would be to use those skills to build a game.

First up, there’s Matthew Helmke’s review which you can read on his site:

I really enjoyed reading Build an HTML5 Game. The writing is clear and easy to follow, the examples are good, and the concepts provide a solid foundation on which you can build. This is not a comprehensive “everything you will ever need or want to know about game programming” sort of book, but rather a clean and enjoyable entry that helps you over the first hurdle of writing that first game. It then gives you ideas and tips to help you know what else is out there so you have a bit of a roadmap to continue learning as you figure out what sorts of games you want to create.

And then there’s a review on I Programmer:

The descriptions of all of the ideas are clear and easy to follow but only if you already know something about the technologies being used. This is not a book for trying to learn JavaScript or even HTML/CSS. It would make a good second level course on the techologies, but only if you were interested in building a game.

And finally this review by Sandra Henry-Stocker on IT World:

The starting point of Build an HTML5 Game: A Developer’s Guide with CSS and JavaScript is something that completely snuck up on me. In my time as a volunteer webmaster, I’d never considered taking my web skills much further than a church web site with just a tad of moving text and a slide show “walk” along the nature trail. The features of HTML5 that have made it a contender for game development were simply lost on me. With this book, the proverbial lights came on. And while I haven’t yet jumped in and tried to build my own game, I now understand what is required and might just give it a shot.

Fingers crossed that this helps the book sell, of course, but they’re great to see in their own right.

Posted in JavaScript, Programming | 4 Comments

Cycling London to Eastbourne

Board games by the sea!

For the spring London on Board event, and as part of training for the London Revolution ride in (gulp) two weeks, I decided that I’d cycle down to Eastbourne rather than take the train.

The route out

For the outgoing route, I went for this one, which, with the ride from Leyton to get to the start, was something like 85 miles (I think). I wish I had it exactly but unfortunately Strava crashed somewhere around Tower Bridge and I didn’t notice until I was about 30 miles from the end. So on the Strava plot it looks like I teleported.

The route was hilly, and long, but the weather was good. I left home just before 9am and was in Eastbourne by 5pm, and I think I stopped for about an hour total along the way. The route was definitely scenic and mostly quiet, though, although getting over Beachy Head at the end was a challenge I could have done without – more because of the traffic hurtling past than the hill itself.

The route back

For the journey back, I went mostly by a different route. I’m still not sure I shouldn’t have just left it for another day as it was raining when I set off which meant my phone shorted out for about 45 minutes and I was navigating by guesswork and trying to remember the route down, and wondering at what point I might just have to find a station and get on the train.

I also didn’t fancy the traffic around Beachy Head again and relied on Google’s directions to take me out of Eastbourne, which proved to be a mistake as I spent five miles or so bouncing along a muddy bridleway aka National Cycle Route 21. It was not the way I wanted to start an 80 mile ride. I’ve also learnt now that a hotel breakfast is not the way to fuel up for a long ride; I didn’t feel like any useful carbohydrate made it into my system for about the first four hours, so it was quite a slog. It did, however, mean I had some pace left in my legs when I got back into London.

The full journey, apart from the bit where the phone didn’t work, did make it onto Strava though and you can see it here, if you are interested in such things. Particular highlights would be rescuing a lamb that had its head trapped in a fence and having to walk through newly laid tarmac over a level crossing (that was closed as they were still laying the tarmac) with steam from the rain falling on it around me. I hope my cleats didn’t leave too big imprints in their nice new surface…

Other things

– Beachy Head road, as mentioned before, is not pleasant, although the downhill is rather fun
– Pains Hill and Titsey Hill are pains in the titseys. (Or actually legs, but that doesn’t really work.)
– The area around Biggin Hill is rather nice for riding in, if you can face the hills
– I really should have taken some photos
– Hills: why? Just why?

So would I do it again? I’m not sure, but only because I couldn’t take any games with me. The October meetup will likely be when the days are short so I’d have to leave earlier in both directions, so we’ll have to see how much I’m riding next spring.

The links again

Long and mostly quiet London to Eastbourne route
Shorter but still quite quiet Eastbourne to London route
The route I actually took back

Posted in Cycling | Leave a comment

Build An HTML5 Game – Answers To Exercises

My Build An HTML5 Game book is finally on the way, and the website to go with it is live too.

As well as info about the book it serves three main purposes:

  1. A place to see and play the Bubble Shooter game developed in the book
  2. Assets such as images and sounds to make the game
  3. Solutions to the exercises at the end of each chapter in the book

The last are only suggested solutions and there’s a comment form below and I’m hoping others will be able to improve on my coding here.

Posted in JavaScript, Programming | Leave a comment

Build an HTML5 Game – 40% Early Access Discount

Build an HTML5 GameMy book Build an HTML5 Game in going to be out in a couple of months, and until around 4pm on January 31st 2015 you can get 40% off with the discount code BRIGHTANDEARLY if you buy it here: http://www.nostarch.com/html5game

The discount applies to ebooks or the physical copy too, although it’s only if you’re in the United States that I guess the physical version makes sense, until it’s more widely distributed sometime in March.

Build an HTML5 Game

Make your own game without learning any new languages! With just HTML, CSS, and JavaScript in your toolbox, you can create a truly cross-platform game, playable on both desktop and mobile browsers.

In Build an HTML5 Game, author Karl Bunyan shows you how to create browser-based games by walking you through an in-depth tutorial on building a classic favorite, the bubble shooter. Along the way, you’ll learn how to:

  • Send sprites zooming around the screen with JavaScript animations
  • Cause exploding effects with a jQuery plugin
  • Use hitboxes and a bit of geometry to detect collisions
  • Implement game logic to display levels and respond to player input
  • Convey changes in game state through animation and sound
  • Add flair to a game interface with CSS transitions and transformations
  • Gain pixel-level control over the game display with the canvas

Hit the ground running as you start programming the bubble shooter from the very first chapter. Exercises at the end of each chapter test your new skills by challenging you to dig into the bubble shooter’s code and modify the game.

You can create a complete game right now, with skills that you already have. Let Build an HTML5 Game teach you the basics, and then transfer that knowledge to create any game you can imagine.

Get 40% off with the discount code BRIGHTANDEARLY if here: http://www.nostarch.com/html5game

Posted in JavaScript, Programming | Leave a comment