One of the most fun projects I worked on at Mozilla was glow.mozilla.org . It was a couple weeks before the launch of Firefox 4 and my frontend buddy @potch and I decided we should make a map to track downloads in real-time. This was back when Firefox releases were a big deal. It turned out to be a really compelling visual. We saw a bunch of tweets about people loving the map, it was featured in…
This week I released https://github-notifications.herokuapp.com/ , a site that demos push notifications in Firefox . It uses Github web hooks to send notifications when there’s a commit to one of your repositories. Push notifications are currently implemented in Firefox as an experimental add-on . This post shows the code I used to send push notifications from the site. Get a Push URL When you…
Push notifications are a way for websites to send small messages to users when the user is not on the site. iOS and Android devices already support their own push notification services, but we want to make notifications available to the whole web. We’re making prototypes and designing the API right now and want to share our progress. How it works The website gets a URL where it can send…
Cache Machine hooks into Django’s ORM to provide easy object caching and invalidation. One of our primary goals with the rewrite of addons.mozilla.org was to improve our cache management. Large sites like AMO rely on layers of caching to stay afloat, and caching database queries in memcached is one of our favorite tools. AMO heavily favors reads over writes, so we have great cache performance; the…
Long (long!) overdue, here’s a bunch of links that point to the good things I learned at djangocon. Restful Ponies Started with a basic REST overview, gets interesting when it shows how you can easily expose resources using Piston django-roa builds on Piston to give models a basic REST API for free remoteobjects is an object-restational mapper that maps objects to REST apis on the web. It’s really…
schematic talks to your database over stdin on the command line. Thus, it supports all DBMSs that have a command line interface and doesn’t care what programming language you worship. Win! It only looks for files in the same directory as itself so you should put this script, settings.py, and all migrations in the same directory. Configuration is done in settings.py , which should look something…
I’d be surprised if poboy is useful to anyone I don’t work with, but I wrote a README, so that should be shared with the internet. Finds all the gettext calls that have an inline fallback and moves that fallback into the messages.po file. Thus, you can use ___('msgid', 'msgstr') when you’re writing new code and use this script to clean up afterwards. poboy won’t edit any code files. Instead, it…
pyquery is a fantastic little library for dealing with XML and HTML documents. It brings the power and ease of jQuery into Python, letting you deal with CSS selectors and functions instead of a clunky DOM. I try to avoid dealing with XML as much as possible, but slinging around pyquery almost makes XML fun. Building lxml The hardest part of working with pyquery is getting it installed. pyquery…
Update: you can now find django-nose on pypi and github with much better documentation. I am not a big fan of Python’s unittest library. The Java-inspired API and the difficulty of running tests are too much for me to deal with. That’s why I love nose : I can use regular assert s (or the Pythonic helpers in nose.tools ) and running all my tests is as simple as calling nosetests from the command…