Skip to content

Instantly share code, notes, and snippets.

from pymongo.connection import Connection , ConnectionFailure
import datetime
try:
connection = Connection("localhost", 27017)
except ConnectionFailure:
page_content = """<span class = "error">could not connect connect:besure that Mongo is running on localhost:27017</span>"""
except Exception, detail:
page_content = """<span class = "error">could not connect connect:besure that Mongo is running on localhost:27017</span>"""
from pymongo.connection import Connection , ConnectionFailure
import datetime
try:
connection = Connection("localhost", 27017)
except ConnectionFailure:
page_content = """<span class = "error">could not connect connect:besure that Mongo is running on localhost:27017</span>"""
except Exception, detail:
page_content = """<span class = "error">could not connect connect:besure that Mongo is running on localhost:27017</span>"""
// sm.cpp
#define XP_UNIX
#include "mozjs/jsapi.h"
#include <string>
#include <string.h>
#include <assert.h>
#include <malloc.h>
/* The class of the global object. */
t = db.blah;
t.drop();
t.save( { screenshots : 1 } )
t.save( { screenshots : [ 1 ] } )
printjson( t.find( { "$where" : "this.screenshots instanceof Array" } ).toArray() )
db.foo.drop()
o = { "upc" : 1 ,
"related_skus" : [ 1,2, 3, 4, 5, 6 ] ,
"price_special" : 700000,
"short_name" : "sn700000",
"ean" : "ean700000",
"price_promo" :700000,
"long_name" : "ln700000",
"url" : "url700000",
coll = db.foo
coll.drop()
coll.insert( { arr : [ { a : 1 } , { b : 2 } , { c : 3 } ] } )
coll.insert( { arr : [ { a : 2 } , { b : 3 } , { c : 1 } ] } )
coll.insert( { arr : [ { a : 3 } , { b : 1 } , { c : 2 } ] } )
coll.ensureIndex( { arr : -1 } )
@erh
erh / test.cpp
Created April 25, 2011 16:21
boost shared_mutex test
// bm.cpp
// g++ test.cpp -lboost_thread-mt && ./a.out
// the ration of XXX and YYY determines
// if this works or deadlocks
int XXX = 20;
int YYY = 10;
#include <boost/thread.hpp>
@erh
erh / gist:bfc65a3b11555dc1f7c5
Created October 21, 2015 16:17
one name verification
Verifying that +eliothorowitz is my blockchain ID. https://onename.com/eliothorowitz
@erh
erh / gist:908067250006a6067506
Created November 15, 2015 02:22
keybase.md
### Keybase proof
I hereby claim:
* I am erh on github.
* I am eliothorowitz (https://keybase.io/eliothorowitz) on keybase.
* I have a public key whose fingerprint is 7A3D D73A B8EF 0948 E7AE 9DD9 4409 F717 FB48 BD6C
To claim this, I am signing this object:
package main
import "flag"
import "runtime"
import "sync/atomic"
import "time"
import "gopkg.in/mgo.v2"
import "gopkg.in/mgo.v2/bson"