Skip to content

Instantly share code, notes, and snippets.

View brianz's full-sized avatar

Brian Zambrano brianz

View GitHub Profile
@cwestin
cwestin / aggregate.js
Created May 26, 2011 18:34
Mongo shell script and sample documents used for my aggregation talk at MongoSF
/* sample aggregate command queries */
// make sure we're using the right db; this is the same as "use mydb;" in shell
db = db.getSisterDB("aggdb");
// just passing through fields
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
@dmpayton
dmpayton / mongoengine_middleware.py
Created January 18, 2011 04:37
Django middleware to ensure that a separate mongoengine connection is made per thread.
import mongoengine
from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed
class MongoEngineConnectionMiddleware(object):
''' Ensure that a separate mongoengine connection is made per thread.
See: http://groups.google.com/group/mongoengine-users/browse_thread/thread/1aa3f9d65627c04
Assumes the following is your Django settings. Tweak as needed.
MONGODB = {
@narfdotpl
narfdotpl / mysqldb.markdown
Created December 4, 2010 16:01
MySQLdb, Python 2.5 and OS X 10.6

MySQLdb, Python 2.5 and OS X 10.6

I wasted too much time trying to make MySQLdb work with Python 2.5 (mysteriously it worked fine with 2.7). I thought I'll share my experience.

I installed MySQLdb normally with pip install MySQL-python (yeah, ingenious name) and there were no problems. But every time I imported it, I got following error: