Gist: df38fb7798b2e2a0746f

Unless otherwise specified, all code here is licensed GPLv2