How much can be done in four hours

Today I had an awesome day at the first OpenDataBC hackathon which took place at Mozilla Labs Vancouver.

Tara Gibbs pitched this wonderful idea of consolidating shelter availability data and displaying it on a few window displays, so the homeless people living DTES would not waste their time going from one shelter to another just to find a free spot.

This doesn't solve all the problems of course, but it does solve a little yet very annoying one.

So... At 11:30 we had nothing but an idea. We discussed possible approaches for a while, then came David Eaves and suggested using Twitter as a message queue service.

At approximately 12:00 we still had nothing but a piece of paper covered with boxes and arrows, then we started coding. Tara did the frontend, I was busy hacking the backend and the Twitter stuff.

Four hours later we had a fully functional, production ready system - https://github.com/mikeivanov/vanshelter

How it is supposed to work:

  1. Shelters tweet their availability data (they all have internet access)
  2. VanShelter monitors -- each of them independently -- receive Twitter updates and
  3. Refresh their displays when something changes.

For displays we can use cheap LCD monitors, probably even donated. The software will run on those amazing Raspberry thingies - http://www.raspberrypi.org/, $25 each. This brings the full cost of installing 10 displays down to $250+.

Thank you Tara and David. Also, thank you Jeff and all the people who made this hackathon possible.

Pure Python Paillier Homomorphic Cryptosystem Implementation

What

This is a very basic Paillier Homomorphic Cryptosystem implemented in pure Python.

The idea is, in short, to encrypt two numbers, perform an "add" operation on cyphertexts, decrypt the result and find it to be the sum of the original plaintext numbers.

How

The code is loosely based on the thep project and a few ActiveState recipes. The code is pure Python and all objects are serializable.

Where

Here: https://github.com/mikeivanov/paillier

Why

I was bored.

 

Why Tk matters

Tk probably is one of the most underlooked GUI toolkits. It is a nice small toolkit which is really, I mean REALLY simple to use.

Tk by the way, has something common with Vi. Oh no, it's not that it beeps all the time as possessed; I meant it works everywhere. I bet you can find Tk ported to any single platform having a GUI and it will work consistently on all of them.

Tk is ubiquitous. Guess what? Almost certainly you have Tk already installed on your computer. Got Python? Go look into /usr/lib/python2.5/lib-tk, it's right there!

How to use it? It's very easy. Look, here is a 'Hello, world' program in Python (using a Tk binding called Tkinter):

from Tkinter import *
Label(text='Hi there').pack()

The program apparently pops up a window with some text inside. Yes, it's that trivial. And this is the area where Tk shines: quick, small GUI tools.

Yet Tk is very powerful. People create big sophisticated systems using just this toolkit. The most prominent example is definitely AC3D, a 3D modeling program.

Tk, however, has some issues. I think nobody will argue that Tk looks ugly on the Linux platform. While the Windows and Mac versions have native look, the Linux port looks shokingly disgusting. Some work is being done in this department but it's not quite completed.

Somebody might ask why use Tk if there is wxPython. Well, for the same reason why there are bicycles and airplanes. They are good for different purposes. Tk is way more lightweight and much easier to learn and use than wxPython.

Tk is very well documented. Here is the official Tkinter documentation with links to tutorials and such:

If you're going to learn Tk, it's worth to mention that Tk is actually a part of something called Tcl/Tk. Tcl stands for Tool Command Language, a Shell-like scripting language easy to learn and fun to use. Even though all you want might be just Tkinter, some knowledge of Tcl will be rewarding.