Skip to content

Instantly share code, notes, and snippets.

View bohde's full-sized avatar

Rowan Bohde bohde

View GitHub Profile
@bohde
bohde / gis_errors
Created March 26, 2012 17:05
Tastypie GIS errors
Failed to install index for gis.GeoNote model: AddGeometryColumns() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5)"
PL/pgSQL function "addgeometrycolumn" line 5 at SQL statement
Problem installing fixture '/home/joshbohde/code/django-tastypie/tests/gis/fixtures/initial_data.json': Traceback (most recent call last):
File "/home/joshbohde/.virtualenvs/tastypie/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 174, in handle
obj.save(using=using)
File "/home/joshbohde/.virtualenvs/tastypie/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/home/joshbohde/.virtualenvs/tastypie/local/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
@bohde
bohde / gist:2198123
Created March 25, 2012 16:34 — forked from shaneog/gist:1198248
elasticsearch ubuntu 11.04
cd ~
# Install the required JDK
sudo apt-get install openjdk-6-jre-headless
# Download, extract and move ElasticSearch
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
(tastypie)joshbohde@mu:~/code/django-tastypie/tests $ which django-admin.py branch: (patch_related_resource)
/home/joshbohde/.virtualenvs/tastypie/bin/django-admin.py
class CustomDepthField(ToOneField):
def should_be_full(bundle):
if not bundle.request:
return self.full
if bundle.request.GET.get('with_entities', self.full) in (True, 'true', 'True', '1'):
return True
return False
def dehydrate_related(self, bundle, related_resource):
@bohde
bohde / send-money.in
Created March 2, 2012 06:33
The send more money constraint problem in Prover 9
op(490, infix_right, "+").
op(470, infix_right, "*").
op(460, infix, "/").
op(460, infix, "mod").
op(390, prefix, "-").
assign(domain_size, 10). % domain is {0,1,2,3,4,5,6,7,8,9}.
% S E N D
class TestResource(ModelResource):
def is_authorized(self, *args, **kwarg):
super(TestResource, self).is_authorized(*args, **kwargs)
print 'is_authorized passed'
def is_authenticated(self, *args, **kwarg):
super(TestResource, self).is_authenticated(*args, **kwargs)
print 'is_authenticated passed'
class MyResource(ModelResource):
def dehydrate(self, bundle):
try:
del bundle.data['text_to_subscribe']
except KeyError:
pass
return bundle
_SUPPORTED_TRANSFORMS = set(['PUT', 'DELETE', 'PATCH'])
_MIDDLEWARE_KEY = 'real_method'
class HttpMethodsMiddleware(object):
def process_request(self, request):
if request.GET and request.GET.has_key(_MIDDLEWARE_KEY):
new_method = request.GET[_MIDDLEWARE_KEY].upper()
if new_method in _SUPPORTED_TRANSFORMS:
request.method = new_method
return None
(match n
0 1
_ (* n (factorial (- n 1))))
;;expands to
(try
(cond (= n 0) 1 :else (throw backtrack))
(catch
java.lang.Exception
e__7660__auto__
class MyResource(ModelResource):
# Normal stuff here...
def build_filters(self, filters=None):
print filters
ret = super(MyResource, self).build_filters(filters=filters)
print ret
return ret