Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@stuaxo
stuaxo / get_orig_prefix.py
Created July 11, 2015 16:22
Get orig prefx in virtualenv
def get_orig_prefix():
"""
read orig-prefix.txt and return it
"""
orig_prefix_txt = normpath(abspath(join(get_python_lib(), '..', 'orig-prefix.txt')))
print orig_prefix_txt
try:
with open(orig_prefix_txt) as f:
path = f.readline().strip()
return path
@stuaxo
stuaxo / csgthing.py
Created July 25, 2015 11:55
What happens if we csg in the draw loop ?
import sys
import os
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
sys.path.insert(0, os.getcwd())
from csg.core import CSG
@stuaxo
stuaxo / cairocffi_example.py
Created August 8, 2015 13:37
Draw a yellow rectangle in cairocffi
# coding: utf-8
# In[12]:
# draw a yellow rectangle with cairocffi
import cairocffi as cairo
im = cairo.ImageSurface(cairo.FORMAT_ARGB32, 512, 512)
@stuaxo
stuaxo / extract_images.sh
Created August 18, 2015 14:21
Extract MSDOS disk images to a directory.
#!/bin/bash
function extract_images() {
# Disk images have a string like this
#
# DISK-1.IMA: , MS or PC-DOS bootloader IO.SYS+MSDOS.SYS
#
#
dest=$1
file *.IMA | grep 'PC-DOS' | awk -F '[/:]' '{print $1}' |
@stuaxo
stuaxo / webgl_sample5-pyopengl-port-notworking.py
Created August 29, 2015 17:31
Port of mozilla webgl sample5 to pyopengl - not working
"""
This is a port of the mozilla webgl-sample5 to pyopengl
I made this from scratch to more closely follow the original and includes all the comments... except it
just has a black screen :/
The working, but more dirty version is here:
https://gist.github.com/stuaxo/ed0b5bd691f766098faf
Instead of webgl uses pyopengl
@stuaxo
stuaxo / webgl_sample5-pyopengl-port.py
Last active August 29, 2015 17:31
Port of mozilla sample5 to pyopengl.py
"""
Well ... this isn't the nicest port, I tried a second time with all the comments, but it didn't seem to work
- the 2nd version is here https://gist.github.com/stuaxo/5c641637f65a53cc8020
Instead of webgl uses pyopengl
Instead of glm uses pyrr
Install Dependencies
pip install numpy pyopengl pyrr
@stuaxo
stuaxo / kivy_resize_window_right.log
Created September 9, 2015 08:12
Resizing windows is pretty borked
$ python test_resize.py
[INFO ] [Logger ] Record log in /home/stu/.kivy/logs/kivy_15-09-09_19.txt
INFO:kivy:[Logger ] Record log in /home/stu/.kivy/logs/kivy_15-09-09_19.txt
[INFO ] [Kivy ] v1.9.1-dev
INFO:kivy:[Kivy ] v1.9.1-dev
[INFO ] [Python ] v2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2]
INFO:kivy:[Python ] v2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2]
[INFO ] [Factory ] 177 symbols loaded
@stuaxo
stuaxo / apc_mini.py
Created September 10, 2015 12:16
APC mini test
#!/bin/python
# -*- coding: utf-8 -*-
"""
get input from a real APC mini and display it on.
usage
-----
$ python apc_mini.py "APC MINI MIDI 1"
@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: