Skip to content

Instantly share code, notes, and snippets.

View mikeyk's full-sized avatar

Mike Krieger mikeyk

  • San Francisco, CA
View GitHub Profile
@mikeyk
mikeyk / reconnect.diff
Created June 30, 2011 21:05
Automatically retry on AutoReconnect exception in pymongo
diff --git a/pymongo/connection.py b/pymongo/connection.py
index b444f50..7635c78 100644
--- a/pymongo/connection.py
+++ b/pymongo/connection.py
@@ -46,6 +46,7 @@ from pymongo import (database,
helpers,
message)
from pymongo.cursor_manager import CursorManager
+from pymongo.decorators import reconnect
from pymongo.errors import (AutoReconnect,
==> Downloading http://download.osgeo.org/geos/geos-3.3.0.tar.bz2
File already downloaded in /Users/mkrieger/Library/Caches/Homebrew
/usr/bin/tar xf /Users/mkrieger/Library/Caches/Homebrew/geos-3.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/geos/3.3.0 --disable-debug --disable-dependency-tracking
./configure --prefix=/usr/local/Cellar/geos/3.3.0 --disable-debug --disable-dependency-tracking
configure: WARNING: unrecognized options: --disable-debug
checking build system type... i386-apple-darwin11.0.0
checking host system type... i386-apple-darwin11.0.0
checking target system type... i386-apple-darwin11.0.0
set nocompatible
set autoindent
set si
set smartindent
set esckeys
" set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws
set magic
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
/home/ubuntu/src/redis/redis/client.py in _execute_command
return self.parse_response(command_name, **options) ...
▼ Local vars
Variable Value
self
u'<redis.client.Redis object at 0xabbb02c>'
// placed in my applicationDidFinishLaunchingWithOptions
if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled"))
NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
// first use the jQuerify plugin here: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
$jq("tbody tr", $("#fs-0")).each(function(index, el){
var nameTD = $jq("td.name", el);
var nameSpan = $jq("span", nameTD);
var name = nameSpan.attr("title") ? nameSpan.attr("title") : nameSpan.text();
var deviceID = $jq("td.id", el).attr("title");
console.log(name + '\t' + deviceID);
})
function Post(){};
Post.prototype = {test : function(){console.log("hello there")}};
p = new Post();
p.test();
/* but I prefer to do two things differently: define my member functions in the 'class' function, and have objects inherit from objects: */
function Post() {
this.test = function(){ console.log("hello there") }
}
/* for query: nearby?lat=37.756988&lon=-122.394458&boxheight=0.001449&boxwidth=0.001449&days=60&apiv=1 */
{"discarded": 0, "num_results": 51, "result_set": [{"category": "Vehicle Theft", "description": "Stolen automobile", "timestamp": 1250335800.0, "lon": -122.394072983, "incident": "090831906", "lat": 37.7576318072}, {"category": "Assault", "description": "Battery", "timestamp": 1249933500.0, "lon": -122.395208449, "incident": "090813346", "lat": 37.7565874457}, {"category": "Assault", "description": "Battery", "timestamp": 1248226200.0, "lon": -122.395383155, "incident": "090742983", "lat": 37.7568374893}, {"category": "Drug\/narcotic", "description": "Possession of base\/rock cocaine for sale", "timestamp": 1252990860.0, "lon": -122.395636483, "incident": "090949060", "lat": 37.7567322847}, {"category": "Assault", "description": "Battery", "timestamp": 1250029800.0, "lon": -122.395685391, "incident": "090817940", "lat": 37.7570410309}, {"category": "Robbery", "description": "Robbery, armed with a knife",