Skip to content

Instantly share code, notes, and snippets.

View nzjrs's full-sized avatar

John nzjrs

View GitHub Profile
@nzjrs
nzjrs / fix-update-copyright-headers.py
Created October 13, 2009 11:36
Update or add copyright headers to source files.
@nzjrs
nzjrs / .gitmodules
Created March 29, 2012 05:00
University of Canterbury Thesis Template
[submodule "documents/latex-makefile"]
path = documents/latex-makefile
url = git://gist.github.com/503886.git
def dict_diff1(first, second, NO_KEY='<KEYNOTFOUND>'):
""" Return a dict of keys that differ with another config object. If a value is
not found in one fo the configs, it will be represented by NO_KEY.
@param first: Fist dictionary to diff.
@param second: Second dicationary to diff.
@return diff: Dict of Key => (first.val, second.val)
"""
diff = {}
# Check all keys in first dict
for key in first.keys():
@nzjrs
nzjrs / caironumpy.py
Last active October 10, 2016 04:04
Mixing Cairo, Gtk, and numpy
# http://stackoverflow.com/a/10031877
import numpy
import cairo
import math
from gi.repository import Gtk,Gdk
data = numpy.zeros((200, 200, 4), dtype=numpy.uint8)
surface = cairo.ImageSurface.create_for_data(
@nzjrs
nzjrs / animated-status-icon.py
Created June 27, 2009 04:55
Animated Gtk+ StatusIcon
#!/usr/bin/env python
"""
Animated Gtk+ StatusIcon
Given an icon name or path, animates the icon in a number of ways, rotating,
shrinking, saturating it, etc.
Inspiration from:
http://groups.google.com/group/sage-devel/browse_thread/thread/f9aeba22ac171082
"""
@nzjrs
nzjrs / lcd_chars.txt
Created May 28, 2010 12:26
PyGtk LCD Widget
# Character set for the Squeezebox display
00
00000
00000
00000
00000
00000
00000
00000
@nzjrs
nzjrs / mem_usage.py
Created February 5, 2009 11:07
Prints the memory usage (including private and dirty) for a given PID
#!/usr/bin/env python
# Prints the memory usage (including private and dirty) for a given PID
#
import sys
import re
def permute(args):
ret = []
if args:
@nzjrs
nzjrs / timestamp.py
Last active December 26, 2015 00:59 — forked from ju-popov/timestamp.py
##
## http://emilics.com/blog/article/python_time.html
## http://www.saltycrane.com/blog/2008/11/python-datetime-time-conversions/
######################################################################
# CURRENT AWARE LOCAL DATETIME
######################################################################
from datetime import datetime
@nzjrs
nzjrs / changer.py
Created October 5, 2013 19:19
Timed background changer for gnome
import argparse
import random
import glob
import os.path
import time
from gi.repository import Gio
class Changer:
def __init__(self, directory, interval):
self._pics = glob.glob(os.path.join(directory,"*.jpg"))
@nzjrs
nzjrs / env.sh
Last active December 21, 2015 07:08
Lame virtualenv / jhbuild clone
#get the current directory. from
#http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
pushd . > /dev/null
DIR="${BASH_SOURCE[0]}";
if ([ -h "${DIR}" ]) then
while([ -h "${DIR}" ]) do cd `dirname "$DIR"`; DIR=`readlink "${DIR}"`; done
fi
cd `dirname ${DIR}` > /dev/null
DIR=`pwd`;
popd > /dev/null