An App In Under Five Hours

The other day on my long train ride from my home and college, I had an idea. I was sick of my fear of missing my stop whenever I was in a train (or even worse, on a bus, because Irish towns look identical), and I thought that it would be handy to have an app that would alarm you when you were near your destination. Then, I proceeded to make it (it’s here if you want to skip reading the post – switch off auto-lock on your phone first).


Now, if you read this blog at all, you’ll know that we like HTML5 here at Flax. My Javascript skills had gotten a little rusty recently, so I decided to take a little holiday from C++ and do something fun for a while. Handily, in recent times, browsers have implemented the Geolocation API, allowing a website to see your approximate location (only after asking for your permission, of course). This is done in a variety of ways, ranging from actual GPS hardware in your smartphone to checking your ISP’s location. While these methods can be wildly inaccurate, I figured that (as most smartphones have GPS these days) it was unlikely to have a huge effect on the app. I should mention that geo.js is a godsend, as I sure as hell wasn’t going to code up the different, browser-specific implementations.


Now, I had a way of getting the user’s approximate latitude and longitude. Next, I needed a way to show this to the user. It took me about thirty microseconds before I hit up the Google Maps API page. The Maps API is a real joy to work with. It takes absolutely no effort to get started with it, and the documentation (as all of Google’s documentation) is the stuff of legends. So, now I had my user’s location showing up on a map. I had (well, in reality I only just implemented this ten minutes ago, but it took no time at all) my user inputting his target destination.Next I needed a way to get the distance from my user to his destination. A quick trip to the Google, and by extension to Movable Type got me not only the formula, but the code! It was a matter of plugging in the right numbers in the right places, and presto, distance.


Finally came the actual alarm implementation. This ended up being a whole eleven lines of code – and that’s being generous with my brackets. (However, the sound implementation did take me some time, as I had to invent a new way to get around iPhone Safari’s lack of autoloading sounds, which I detailed in this post)


My biggest problem, and the app’s biggest flaw, is that on the iPhone, Safari won’t run in the background, either while locked or using other apps. This means that in order to use the alarm, you need to switch off auto-locking in the settings – and turn down brightness while you’re here. In my quick-and-dirty test, my battery went down seven percent over thirty minutes, though I left brightness at max and wifi on. Without those, you might be looking at four percent over that time. That’s not heart-stoppingly awful, it’s just not great. So, if you want to use the app, remember to switch off auto-lock.

Wham, bam, thank you ma’am

So there you have it. While the fact remains that it’s uglier than Cthulthu himself, and there’s absolutely no configurability other than moving your destination (the alarm will ring when you’re five kilometres or less away from your destination), the core implementation and virtually all of the code was written in under five hours, in two nights, fuelled by several hundred cups of tea.

The moral of the story

The moral of the story is this: stop thinking that “someone should make this” and just make it yourself. I did this in two nights in between an exam and a project deadline. It took virtually no time and does exactly what I need it to do. Most importantly, I stopped thinking about design patterns and heap memory and went completely nuts with my code. Nobody’s going to grade me on this, nor am I going to get fired. When I thought “Damn, I need a global variable here” I didn’t spend hours re-architecting the code to get around it. I just (hold on to your hats) made one. A piano didn’t drop from the heavens and the sky didn’t fall.

It’s alive!

If you want to use this app, go for it! It’s live right here. It’s a long link, I’ll move it sooner or later, but I’ll also redirect from that one so feel free to bookmark it.

I offer absolutely nothing in the way of guarantees that it’ll work, but it should. Tap on your destination, leave the page open (and as explained above, switch off auto-lock on your iPhone), and fall asleep at will.

About the Author

Carl Lange

I'm currently a Computer Games Development student at Carlow IT. I love programming and all things technical, and I'll learn anything if it's interesting. I'm passionate about technical education, and naturally about games. Check out my resume, and follow me on Twitter!

Visit Website


  1. Mixhael April 24, 2011

    impressive. Besides that the app already existed 🙂

  2. Nice “abstract” reference to Lovecraft there, really raises the whole tone of the article. Really helped me understand how one goes about creating a poorly refined app, and passing it off as some great feat.

    Next time you have a “good” idea, don’t be a lazy bollix and put some effort in, mate.

    • Author

      Oh, ouch. 😉

      I didn’t say that it was a good idea (just that it would be handy), nor did I say it was in any way refined (or, in fact, a great feat – I was merely pleased that I got away with so little effort). Why does everything need to be the pinnacle of programming? This does what I wanted it to, and it took very little time and effort. I’m pleased with that. Had I spent a month working on it, I wouldn’t have been nearly as happy – even if it had been a fully-featured, beautifully programmed diamond of an app. This got me 60% of the way in 5% of the time, and that’s more ore less why I wrote the article.

  3. Nice app.. that’s what programming is about.. doing stuff just for the fun.. it doesn’t matter if it was already done. Keep the pace, keep moving forward, envy is always there.. so don’t pay attention!.

    • Author

      Thank you! Haha, I wouldn’t call it envy – valid points were made. That’s exactly what I thought, though – program for fun. If I didn’t do something like this every once in a while, I’d fall out of love with the entire field.

  4. Carl, this is great … and pointed me the right direction.

    Thank you …

  5. I wish I had this app when I was using trains and buses! Good job!
    And I learned about Cthulthu 😀

  6. Cool stuff…
    But the page dont show when made as a webapp in ios 6…