Skip to content

Instantly share code, notes, and snippets.

View tobych's full-sized avatar

Toby Champion tobych

View GitHub Profile
@tobych
tobych / checke2e.py
Last active December 21, 2015 21:59
Monkey patch to work around Django #13843
# https://gist.github.com/tobych/6372218
# Monkey patch to work around https://code.djangoproject.com/ticket/13843
import django
from functools import wraps
def discard_exceptions(f):
@wraps(f)
def wrapper(*args, **kwds):
try:
@tobych
tobych / checke2e.py
Created August 28, 2013 21:55
Towards monkey patching my way around https://code.djangoproject.com/ticket/13843
def patched__del__(self):
if self.ptr: lgeos.finishGEOS_r(self.ptr)
import django
django.contrib.gis.geos.prototypes.threadsafe.GEOSContextHandle.__del__ = patched__del__
@tobych
tobych / crew.html
Last active December 20, 2015 16:19
Applying Bootstrap label class based on custom attribute
<span class="statusLabel" data-status="{{ status.name }}">{{ status.name }}</span>
...
<script type="text/javascript">
$('.statusLabel').addClass(function() {
var classes = {
"Never seen": 'label',
"OK": "label label-success",
"Relocated": "label label-warning",
"Missing": "label label-danger"
}
class TruckResource(ModelResource):
class Meta:
queryset = Truck.objects.all()
list_allowed_methods = ['get']
detail_allowed_methods = ['get']
filtering = {'owner': ALL_WITH_RELATIONS, 'truck_number': ALL}