Long polling with Javascript and Python

In this post I’m going to step through an example web chat system implemented in Python (with Bottle and gevent) that uses long polling to implement a simple publish/subscribe mechanism for efficiently updating connected clients. My pubsub_example repository on GitHub has a complete project that implements the ideas discussed in this article. This project can be deployed directly on OpenShift if you want to try things out on your own. You can also try it out online at http://pubsub.
read more →

Interrupts on the PiFace

I recently acquired both a Raspberry Pi and a PiFace IO board. I had a rough time finding examples of how to read the input ports via interrupts (rather than periodically polling for values), especially for the newer versions of the PiFace python libraries. After a little research, here’s some simple code that will print out pin names as you press the input buttons. Button 3 will cause the code to exit:
read more →

Python ctypes module

I just learned about the Python ctypes module, which is a Python module for interfacing with C code. Among other things, ctypes lets you call arbitrary functions in shared libraries. This is, from my perspective, some very cool magic. I thought I would provide a short example here, since it took me a little time to get everything working smoothly. For this example, we’ll write a wrapper for the standard statvfs(2) function:
read more →

Retrieving Blogger posts by post id

I spent some time recently trying to figure out, using Google’s gdata API, how to retrieve a post from a Blogger blog if I know corresponding post id. As far as I can tell there is no obvious way of doing this, at least not using the gdata.blogger.client api, but after much nashing of teeth I came up with the following solution. Given client, a gdata.blogger.client instance, and blog, a gdata.
read more →