Skip to content

Instantly share code, notes, and snippets.

Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/ong/.virtualenvs/spatiallab/lib/python2.6/site-packages/django/db/models/query.py", line 334, in count
return self.query.get_count(using=self.db)
File "/Users/ong/.virtualenvs/spatiallab/lib/python2.6/site-packages/django/db/models/sql/query.py", line 401, in get_count
number = obj.get_aggregation(using=using)[None]
File "/Users/ong/.virtualenvs/spatiallab/lib/python2.6/site-packages/django/contrib/gis/db/models/sql/query.py", line 85, in get_aggregation
return super(GeoQuery, self).get_aggregation(using)
File "/Users/ong/.virtualenvs/spatiallab/lib/python2.6/site-packages/django/db/models/sql/query.py", line 367, in get_aggregation
result = query.get_compiler(using).execute_sql(SINGLE)
@ejel
ejel / gist:1077064
Created July 11, 2011 23:41
Eject connected external devices
#!/usr/bin/env zsh
for d in /Volumes/*
do
if diskutil info $d | grep -P "\bEjectable:\s+Yes" > /dev/null
then
diskutil eject $d
fi
done
growlnotify -m "External devices ejected."
@ejel
ejel / gist:1065129
Created July 5, 2011 16:06
Profiler data
320034 function calls (302666 primitive calls) in 46.917 CPU seconds
Ordered by: internal time, call count
List reduced from 290 to 100 due to restriction <100>
ncalls tottime percall cumtime percall filename:lineno(function)
18386/17385 39.135 0.002 39.158 0.002 threadsafe.py:42(__call__)
2228 4.522 0.002 11.127 0.005 geometry.py:42(__init__)
1 1.528 1.528 1.528 1.528 base.py:42(execute)
11 0.164 0.015 0.167 0.015 compiler.py:749(<lambda>)
@ejel
ejel / rpi.py
Created May 21, 2011 21:13
RPI Code Jam
from __future__ import division
"""
Code Jam 2011
Round1B: Problem A
"""
import sys
def compute(gamelist):
num_teams = len(gamelist)
opponents = [None] * num_teams
@ejel
ejel / bottrust.py
Created May 8, 2011 22:38
Code Jam 2011: Bot Trust
import sys
def min_time(directive):
"""directive -- the button pushing sequence e.g.
[('O',2),('B',1),('B',2),('O',4)]
"""
bot = { 'O': (0, 1), # (time, position)
'B': (0, 1) }
time = 0
for b, loc in directive: