Skip to content

Instantly share code, notes, and snippets.

View ahankinson's full-sized avatar

Andrew Hankinson ahankinson

View GitHub Profile
@ahankinson
ahankinson / gist:985173
Created May 22, 2011 04:02
Install WxPython 2.9 64-bit with Homebrew Python Framework install
# These instructions work for OS X 10.6 with homebrew pre-installed.
brew install python --framework
brew install gfortran
# install other dependencies through pip:
pip install numpy
# the regular pip build for matplotlib is b0rken, and it can't find the built-in libraries for OSX
export LDFLAGS="-L/usr/X11/lib"
diff --git a/gamera/gui/classifier_display.py b/gamera/gui/classifier_display.py
index e483570..89c83c6 100644
--- a/gamera/gui/classifier_display.py
+++ b/gamera/gui/classifier_display.py
@@ -164,8 +164,8 @@ class ExtendedMultiImageWindow(MultiImageWindow):
font.SetWeight(wx.BOLD)
self.titlebar_text.SetFont(font)
if wx.Platform != '__WXGTK__':
- self.titlebar_text.SetForegroundColour(wx.Color(255,255,255))
- self.titlebar_text.SetBackgroundColour(wx.Color(128,128,128))
@ahankinson
ahankinson / gist:985201
Created May 22, 2011 05:21
A small convenience script for running mei modifications
export MEI_LOCATION="~/Documents/code/svn/mei/tags/MEI_release_2011-05/schemata/mei-2011-05-source.xml"
export TEI_STYLESHEETS="/usr/local/share/xml/tei/stylesheet"
===== /usr/local/bin/mei =====
#!/usr/bin/env sh
/usr/local/bin/roma --localsource=$MEI_LOCATION --xsl=$TEI_STYLESHEETS $*
==============================
Usage:
mei modification-file.xml --options
@ahankinson
ahankinson / gist:1137670
Created August 10, 2011 18:13
comparing pointers
bool MeiElement::hasChild(MeiElement *child) {
for (vector<MeiElement*>::iterator iter = _children.begin(); iter != _children.end(); ++iter) {
if((&child) == &(*iter)) {
return true;
}
}
return false;
}
@ahankinson
ahankinson / gist:1240782
Created September 25, 2011 16:19
Basic AJAX pattern
function doSomethingWhenClicked() {
jQuery.ajax(<parameters>,
success: successFunction(params),
)
}
function successFunction(params) {
...update your div...
}
@ahankinson
ahankinson / gist:1426301
Created December 3, 2011 06:35
Boost Python error "No to_python (by-value) converter found..."
I'm posting this here because I had a maddening search for information about why this error occurs when trying to do certain tasks in a Boost Python binding to a C++ object:
TypeError: No to_python (by-value) converter found for C++ type: Element*
This was when trying to iterate over a vector, defined as:
typedef std::vector<Element*> ElementList;
It turns out that in your `class_<>` definitions you have to be pretty specific. I already had:
@ahankinson
ahankinson / generics.py
Created December 14, 2012 03:57
PATCH support for Django REST Framework. The Django Rest Framework (http://django-rest-framework.org/api-guide/serializers.html) does not provide support for the PATCH HTTP method. These two overridden classes will allow you to mix-in support for PATCH. Place these in your Django webapp and import them as needed. I've kept the same DRF file name…
from rest_framework import mixins
from rest_framework.generics import SingleObjectAPIView
from yourapp.mixins import PartialUpdateModelMixin
class RetrievePartialUpdateDestroyAPIView(PartialUpdateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
SingleObjectAPIView):
@ahankinson
ahankinson / gist:4945722
Created February 13, 2013 16:17
kdu_compress options
Usage:
"kdu_compress ...
-i <file 1>[*<copies>@<size>],... {see also `-fprec' & `-icrop'}
One or more input files. If multiple files are provided, they must be
separated by commas. Any spaces will be treated as part of the file
name. If any filename contains the optional "*<copies>@<size>" suffix,
that file actually contributes <copies> inputs, where the k'th copy
starts (k-1)*<size> bytes into the file; this is most useful for raw
files, allowing a single raw file to contribute multiple image
components.
<mei:measure n="6" xml:id="d6959e2018" width="278">
<mei:staff n="1">
<mei:layer n="1">
<mei:note xml:id="d6959e2020" pname="d" oct="4" dur="2" dur.ges="512" stem.dir="up" instr="P1-I1"></mei:note>
<mei:note xml:id="d6959e2042" pname="d" oct="4" dur="2" dur.ges="512" stem.dir="up" instr="P1-I1"></mei:note>
<mei:note xml:id="d6959e2064" pname="a" oct="4" dur="4" dur.ges="256" stem.dir="up" instr="P1-I1"></mei:note>
<mei:note xml:id="d6959e2087" pname="g" oct="4" dur="4" dur.ges="256" stem.dir="up" instr="P1-I1"></mei:note>
<mei:note xml:id="d6959e2104" pname="a" oct="4" dur="4" dur.ges="256" stem.dir="up" instr="P1-I1"></mei:note>
<mei:note xml:id="d6959e2121" pname="b" oct="4" dur="4" dur.ges="256" stem.dir="down" instr="P1-I1"></mei:note>
</mei:layer>
@ahankinson
ahankinson / gist:7583454
Created November 21, 2013 15:22
Gunicorn Startup Script
#!/bin/bash
NAME="imageserve" # Name of the application
VIRTUAL_ENV=srv_env
DJANGODIR=/data7/srv/webapps/imageserve2 # Django project directory
SOCKFILE=/tmp/imageserve.sock # we will communicte using this unix socket
USER=www-data # the user to run as
GROUP=www-data # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=imageserve.settings # which settings file should Django use