April 1st, 2009
Last night I put together a mini app / guide “Mobile Device Detection” hosted at notnotmobile.appspot.com running on Google App Engine. It detects the HTTP User-Agent browsing the page and decides whether it’s a mobile or desktop browser using a basic “Not Device” detection algorithm.
App Engine works great for little one off projects like this. Dropping in Disqus for comments also worked like a charm.
For promotion I tried dropping a link on Twitter, posting to Hacker News and dropping some comments on the top Google results for “Mobile Device Detection”. The result? 310 absolute uniques.
Not too shabby for a night’s worth of hacking!
jb
Posted in googleappengine | 2 Comments »
March 9th, 2009
Every piece of accounting software used to handle payroll in Canada has been absolute crap.
At Mobify the only question we’ve ever really had about payroll was “How much tax do we need to pay?” Everything seems to come with fancy bells and whistles that you almost never need. Fed up with our current system, I spent a few hours this weekend hacking together a Django application around the PDOC - Payroll Deductions Online Calculator scraper I wrote some time ago.
I will call it Canadian Payroll Calculator (CPC).
CPC is a Django web application that let’s you pay payroll without clicking one thousand buttons. Create some employees, enter a salary and press calculate. CPC spits out all the taxes and what you should pay the guy. For bonus points it remembers and aggregates all payroll transactions for each employee so you have a handy little list.
The source is sitting on Github for anyone to fork - take a look!
http://github.com/johnboxall/canadian-payroll-calculator/tree/master
Posted in Uncategorized | No Comments »
March 6th, 2009
Here is a quick little script to pull down your GitHub Repos and display them on a page:
Interesting note - I started off by using the append function inside the $.each loop - but after reading Josh Powell’s post on using append correctly I switched to building the HTML from a concatenated string. The result loads noticeably faster.
Check out the result on GitHub:
http://johnboxall.github.com/
Posted in javascript | 2 Comments »
January 26th, 2009
I dream of the day when others code to my API and I sip scotch.
Until then I started two new projects working on other people’s APIs this week.
First I’ve taken a swing at re-imagining the Device Atlas Python API. The existing Python API does the job but the exposed method calls are ominous (`getTreeFromFile`? `getProperties`?) and the returned dictionary objects leaves a bit to be desired. There is also a rather large chunk of what I would consider cruft for dealing with typed and untyped properties. The new API looks like this:
Check it out under `deviceatlas` on github.
Second I’ve written a Django pluggable app for AdMob ads and analytics. I coded a simple snippet some time ago - this is more of the full meal deal and sets AdMob cookies and other wonderful things. The backend code is based off the Ruby AdMob Gem. Check it out under `django_admob` on github.
Posted in django, mobile, python | 2 Comments »
January 15th, 2009
In one of our Django projects we needed to transfer ownership of an object and all it’s related objects from one user to another. A solution might look something like this:
- Collect all related objects related to the object you want to transfer.
- Update the ownership field on all the related objects.
- Save all the related objects!
django.db.models.query has a class CollectedObjects that makes this a snap. CollectedObjects works with Model._collect_sub_objects to find all related classes and objects of the object you want to transfer. Then you can use the update queryset method on each different class of the related objects to set them to their new owner. Here is a function update_related_field:
And here it is customized to update the owner property of an object:
Posted in django, python | No Comments »
December 30th, 2008
`onbeforeunload` is a black sheep in the JavaScript event family. It’s nonstandard and yet supported all major browsers except Opera. You’ve seen it before in Gmail or Wordpress. When you try to close a draft that hasn’t been saved you are asked to confirm your action - that’s `onbeforeunload` in action.
Using jQuery we can duplicate this effect. The gist of the idea is to use a boolean called `dirty` to track changes to input elements. If `dirty` is set we’ll use the `onbeforeunload` event to confirm that user’s action:
Check out Stackoverflow for an introduction to the `onbeforeunload` event.
Posted in javascript | No Comments »
December 29th, 2008
At Handi we use Lighthouse for issue tracking with weekly milestones. At the end of the week we take all the open issues and bump them to next week so we can pick up where we left off. Currently there is no way to bulk edit tickets in Lighthouse and if there are more than a couple of issues left to move it gets annoying.
Lighthouse provides a Ruby API - apted named lighthouse-api for updating tickets. If your Rails is rusty like mine you’ll need to update a bunch of gems and finally grab the API off github:
The script itself is simple - iterate through the milestones in the project to find the current and next milestone. Then find open tickets in the current milestone and update them to be in the next milestone. activeresource makes this all snap as you can interact with the Lighthouse objects just like any other activerecord objects:
Don’t forget to update the script with your Lighthouse account, token and project id.
Happy hacking!
Posted in ruby | No Comments »
December 26th, 2008
At Handi we use the dotmobi ready test to validate our mobile pages. One criteria used by the test is the HTML DOCTYPE of your page. Getting a perfect score requires setting your DOCTYPE to a mobile compatible type like XHTML Mobile Profile 1.0:
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">

Different DOCTYPEs can effect the rendering of your document in a browser and some DOCTYPES have known quirks that can throw off even a perfect design. In XHTML-MP 1.0 we’ve found that images are 4px bottom margin - even when the margin is set to 0.
You can easily fix this problem by by giving all images this default styling:
img { vertical-align: middle; }
Related Links:
Posted in mobile | No Comments »