scratchpad

zfsdiff.py - show the size difference between replicated pools
PostgreSQL View and Triggers for One-to-One Tables
Mouse binding in debian

I've recently started migrating from OS X to Debian testing branch with gnome3 for development work. The zoom and show-all-windows buttons on my Logitech Performance MX mouse aren't bound to anything by default, and Logitech doesn't provide drivers, so I had to figure out how to do it myself. Packages used:

sudo apt-get install xbindkeys wmctrl xautomation terminator

xbindkeys was used to bind these commands, and blocks of code go in ~/.xbindkeysrc. Sidenote for xbindkeys: the daemon that runs doesn't refresh the source file by itself, so killall xbindkeys; xbindkeys when you make changes.

Switch to or open new terminal

This binds the zoom button (b:13) to open the terminal, and requires the wmctrl package:

#logitech performance mx "zoom" -> terminal
#this switches to the first terminator instance, or spawns a new one
"/usr/local/bin/terminator"
  b:13

/usr/loca/bin/terminator will switch to a running instance of terminator, my new terminal emulator of choice, or launch a new instance if it can't find it:

Show all windows

This one was bound to the show all windows button (b:10), and requires xte, found in the xautomation package. It's a tad cludgey, actually emulating the super key, which in gnome3 brings up an exposé-esque view of all open windows like in OS X. Because of how xte doesn't unbind the normal click of the key, and gnome3 won't bring up the activities view while clicking, it must be bound to the release of the button rather than just the button.

#logtech performance mx "windows" -> Super
"xte 'key Super_L'"
  release + b:10
Secure Storage in Django

This isn't a huge amount of code but I spent quite a bit of time trying to get nginx to behave.


Makes Django storage URLs expire after a set amount of time. Built to be used with nginx's secure_link module, essentially emulating Amazon's S3's similar functionality. Because it's a mixin, you can theoretically use it with any Django storage method, but it will only limit access if there's a properly configured nginx server actually serving the files. SecureFileSystemStorage is included, but again, you can use any base Storage class you want.

Required modules:

  • Django (this was built for 1.6)
  • secret_hash.py (https://gist.github.com/wizpig64/7314191)
Secret Hash

I wrote this for one of my work projects and decided to throw it up here. It might not be notable for more experienced developers, but this blog is really meant to chronicle my experiences so I can look back on them later. So, expect more stuff like this.

Battlefield 4

There goes my entire month of productivity D:

Scratchpad Source Available on GitHub

Woo!

Download on GitHub

From the readme:

Scratchpad

Scratchpad is a very simple blog app I wrote in 5 hours or so to get back into the groove of programming with Django. Nothing fancy like comments or file uploading are that planned at the moment. You can see it in action at http://blog.wizpig64.com/

Used Django 1.5, django-bootstrap3, django-endless-pagination, and django-markdown-deux.

If you plan on deploying this for some reason, remember to:

  • python manage.py collectstatic - the static folder is included in the repo but git will ignore its contents.
  • Remove the sample DB and python manage.py syncdb to create your own.
  • More details are given specifically for Heroku users at the end of settings.py.
test post please ignore

Don't tell me what to do!