Skip to content

Instantly share code, notes, and snippets.

View nzjrs's full-sized avatar

John nzjrs

View GitHub Profile
@nzjrs
nzjrs / test_crc.py
Created October 28, 2014 10:48
Non-table based implementations of crc16 and crc8-maxim
import crcmod.predefined
def _crc16(crc, c):
crc ^= ord(c)
for i in range(8):
if crc & 0x1:
crc = (crc >> 1) ^ 0xA001
else:
crc = (crc >> 1)
return crc
@nzjrs
nzjrs / gtk-theme-swatch.py
Created January 21, 2009 01:25
PyGtk widget that displays color swatches according you your Gtk theme
#!/usr/bin/env python
# gtk-theme-swatch: A PyGtk widget that displays the color swatches of all
# gtk.Styles, in all states. Useful for designing themes
# author: John Stowers <john.stowers@gmail.com>
import gtk
class ThemeSwatch(gtk.DrawingArea):
SWATCH_SIZE = 50 #swatch size
@nzjrs
nzjrs / emit.py
Created February 2, 2009 04:05
Python example demonstrating when callbacks are run in a threaded environment
#!/usr/bin/env python
# Python example demonstrating when callbacks are run in a threaded environment
# John Stowers
import threading
import thread
import time
import gobject
import gtk
@nzjrs
nzjrs / gtk-curve-test.py
Created June 30, 2009 22:25
Demo for testing gtk.Curve
#!/usr/bin/env python
# Demo for testing gtk.Curve
# John Stowers 2009
import random
import gtk
class UI:
TYPES = (gtk.CURVE_TYPE_LINEAR, gtk.CURVE_TYPE_SPLINE, gtk.CURVE_TYPE_FREE)
@nzjrs
nzjrs / test-rtgraph.py
Created July 12, 2009 11:11
python rtgraph demo
#!/usr/bin/env python
# A simple example of using multiple rtgraph HScrollLineGraph widgets
# Micah Dowty <micah@picogui.org>, John Stowers
#
import gtk
import time, math, re
import gs.ui.rtgraph as rtgraph
windows = []
@nzjrs
nzjrs / mirror.py
Created January 19, 2010 00:08
PyGtk client side windows demo
#!/usr/bin/env python
# Gtk+ client-side-windows demo in python
# John Stowers
import gobject
import cairo
import gtk
import gtk.gdk as gdk
#hacks for using functions not exposed in this pygtk version
@nzjrs
nzjrs / build-pygtk-windows-installers.sh
Created October 16, 2010 06:27
Script for building the Py{GObject,GTK} installers using MinGW
#!/bin/sh
# Script for building the Py{GObject,GTK} installers using MinGW
# via wine on ubuntu 10.04
#Install the deps, MinGW and MSYS. GCC 4.5.0
#wine mingw-get.exe install gcc
#wine mingw-get.exe install msys-base
PYVERSIONS="6 7"
BDIST_TARGETS="wininst msi"
@nzjrs
nzjrs / oo-eps.bas
Created November 1, 2010 11:24
Exporting openoffice charts for LaTeX
' Export all charts from a Calc spreadsheet to EPS
' (c) Jose Fonseca
' Taken from http://www.oooforum.org/forum/viewtopic.phtml?t=60155
Sub Main
Dim oDoc, oDocCtrl, oDocFrame, oDispatchHelper
oDoc = ThisComponent
oDocCtrl = oDoc.getCurrentController()
oDocFrame = oDocCtrl.getFrame()
oDispatchHelper = createUnoService( "com.sun.star.frame.DispatchHelper" )
@nzjrs
nzjrs / gtkview.c
Created November 18, 2010 12:03
GTK+ Viewer for Microsoft Kinect (uses libfreeconect)
/*
* Gtk example to show depth map from Micrsoft Kinect
* Copyright (c) 2010 John Stowers
*
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
* for details.
*
* This code is licensed to you under the terms of the Apache License, version
* 2.0, or, at your option, the terms of the GNU General Public License,
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
@nzjrs
nzjrs / gen-git-stats.sh
Created April 3, 2011 01:39
Generate development history statistics for PyGTK
#!/bin/sh
OUT="./"
PROJ="/home/john/Programming/pygtk.git/"
pepper activity --datemin=1998-12-01 --output=${OUT}/activity.png --size=800x600 ${PROJ}
pepper activity --split=authors --n=10 --datemin=1998-12-01 --output=${OUT}/activity-auth.png --size=800x600 ${PROJ}
pepper activity --split=directories --datemin=1998-12-01 --output=${OUT}/activity-directories.png --size=800x600 ${PROJ}
pepper loc --output=${OUT}/loc.png --size=800x600 ${PROJ}
pepper loc --tags --output=${OUT}/loc-tags.png --size=3200x600 ${PROJ}