Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@stuaxo
stuaxo / Fix for makefile
Created February 1, 2012 17:31
sparql-query patch
diff --git a/Makefile b/Makefile
index 14c89d8..ab6cd16 100644
--- a/Makefile
+++ b/Makefile
@@ -25,4 +25,4 @@ scan-test: scan-test.o scan-sparql.o
$(CC) $(LDFLAGS) -o $@ $^
sparql-query: sparql-query.o result-parse.o scan-sparql.o
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) -o $@ $^ $(LDFLAGS)
@stuaxo
stuaxo / django polymorphic traceback
Created June 21, 2012 16:28
Traceback from django polypmorphic
AttributeError at /dashboard/booking/new/
type object 'Region' has no attribute 'base_objects'
Request Method: GET
Request URL: http://localhost:8000/dashboard/booking/new/
Django Version: 1.4
Exception Type: AttributeError
Exception Value:
@stuaxo
stuaxo / update_virtualbox_hard_disk_uuids.py
Last active August 26, 2022 01:20
Update virtualbox hard disk uuids
def update_virtualbox_hd_uuids(vbox_conf):
'''
After using clonevm (ie VBoxManage clonevm "my-virtual-machine" --name "new_vm")
pass in name of VirtualBox configuration xml '''
from xml.dom.minidom import parse, parseString
vbox = parse(vbox_conf).documentElement
for hardDisk in vbox.getElementsByTagName('HardDisk'):
location = hardDisk.getAttribute('location')
@stuaxo
stuaxo / cackinstaller.py
Created November 8, 2012 15:10
Work around low bandwith connection with PIP to install a requirements file in jenkins.
# Terrible hack to get around pip bailing on flaky internet connection.
#
# Usage:
# python cackinstaller.py requirements.txt
#
import os
import sys
@stuaxo
stuaxo / cairo_pyglet.py
Last active March 14, 2023 15:07
Render cairo on pyglet... modified from http://ethanmiller.name/
# Draw cairo in a pyglet window - without an intermediate image file.
import ctypes
#import cairocffi as cairo # example will work with cairocffi instead too
import cairo
import time
from pyglet import app, clock, font, gl, image, window
WIDTH, HEIGHT = 400, 400
# Shoebot Sketch - Pleasing blue animated blue rectangle [stuaxo]
from math import cos, sin
def setup():
speed(100)
def draw():
transform(mode=CENTER)
translate(MOUSEX, MOUSEY)
@stuaxo
stuaxo / arrow_particles.bot.py
Last active December 15, 2015 02:49
Arrow-splosion .. simple particle system in shoebot.
#
# (Very) Simple particle system implementation in shoebot
#
# to run, install shoebot and planar.py, then run
#
# sbot -w arrow_particles.bot
from random import random
from planar.py import Vec2, Affine
@stuaxo
stuaxo / minisheet.py
Created May 10, 2013 14:41
Access a spreadsheet in the same style as django models. Only gives access to X, Y Avis and 'Fields' - everything else. Allows named access to these and can easily be extended to munge the data on the way in. Used originally for writing importers from spreadsheets, can easily use with csvreader or xlwt. Wrote this quite a while ago, keep finding…
import csv
'''
Very minimal class for reading cells from 2d structures (e.g. those
returned by the csv reader.
reader classes extend GridModel and contain a Field and optional XAxis and
YAxis
class Customers(GridModel):
@stuaxo
stuaxo / window_pos.py
Created June 3, 2013 14:35
Gtk - report window position
#!/usr/bin/python
import gtk
class app(gtk.Window):
def __init__(self):
super(app, self).__init__()
#self.set_position(gtk.WIN_POS_CENTER)
import cairocffi as cairo
s = cairo.ImageSurface(cairo.constants.FORMAT_ARGB32, 600, 400)
img = cairo.ImageSurface.create_from_png("/usr/share/icons/gnome/48x48/devices/joystick.png")
w, h = img.get_width(), img.get_height()
cr = cairo.Context(s)
def before():
cr.save()