Skip to content

Instantly share code, notes, and snippets.

View nzjrs's full-sized avatar

John nzjrs

View GitHub Profile
@nzjrs
nzjrs / exp.sh
Created July 19, 2013 11:30
Gstreamer x264 Experiments
gst-launch-0.10 videotestsrc ! video/x-raw-yuv,format=\(fourcc\)I420,width=640,height=480,framerate=25/1 ! x264enc byte-stream=true ! filesink location=foo.mp4
@nzjrs
nzjrs / detect.py
Last active December 16, 2015 19:08
Python Point Detect
import cv2
import numpy as np
import scipy.ndimage.measurements
cv2.startWindowThread()
for iname,t in (("img",45),("img2",230), ("img3",230), ("img4",250)):
i = cv2.imread("%s.png" % iname)
cv2.namedWindow(iname)
@nzjrs
nzjrs / gtkcolorbutton.py
Created February 24, 2013 12:15
A PyGObject / GTK implementation of a solid color GtkButton
import numpy
import cairo
from math import pi
from gi.repository import Gtk,Gdk
def draw_rounded(cr, area, radius):
a,b,c,d=area
cr.arc(a + radius, c + radius, radius, 2*(pi/2), 3*(pi/2))
cr.arc(b - radius, c + radius, radius, 3*(pi/2), 4*(pi/2))
@nzjrs
nzjrs / gtkmodebutton.py
Last active December 11, 2015 20:59
A PyGObject / GTK implementation of a ModeButton / ModeButtonBox
from gi.repository import Gtk
class _ButtonBoxMixin(object):
def add(self, widget):
self.pack_start(widget)
def pack_start(self, widget, *args, **kwargs):
if type(widget) is Gtk.RadioButton:
widget.props.draw_indicator = False
@nzjrs
nzjrs / bomb.py
Created September 28, 2012 09:37
Macgyver Bomb
import threading
import time
import serial
from gi.repository import Gtk, Gdk, GObject
GObject.threads_init()
Gdk.threads_init()
@nzjrs
nzjrs / denumpy.py
Created September 19, 2012 16:48
Recursively convert dicts containg np types into primitive equivs
import numpy as np
def fix(d):
#d = d.copy()
for k,v in d.items():
if type(v) == dict:
d[k] = fix(v)
elif isinstance(v,np.floating):
d[k] = float(v)
elif isinstance(v,np.integer):
@nzjrs
nzjrs / Makefile
Created February 11, 2012 23:12
Testing ORC - The Oil Runtime Compiler
all: testc testorc
clean:
rm -f testc testorc out.c out.h
testc: out.c test.c
$(CC) -DDISABLE_ORC=1 -o $@ $^
testorc: out.c test.c
$(CC) -o $@ $^ `pkg-config --cflags --libs orc-0.4`
@nzjrs
nzjrs / dotdict.py
Created September 7, 2011 03:12
Namespaced foo.bar.baz dict wrapper
import UserDict
class DotDict(UserDict.IterableUserDict):
def __init__(self):
UserDict.IterableUserDict.__init__(self)
def __setitem__(self, key, val):
bits = key.split(".")
if bits[0] not in self.data:
@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}
@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,