Skip to content

Instantly share code, notes, and snippets.

package main
import "flag"
import "runtime"
import "sync/atomic"
import "time"
import "gopkg.in/mgo.v2"
import "gopkg.in/mgo.v2/bson"
@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:
@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 / README.md
Last active January 23, 2018 11:33
sample aggregation stage module - inject

This is a sample aggregation stage that insert a field into every document.

Steps:

  1. Git clone the mongodb source code.
  2. Create a directory called 'modules' in src/mongo/db/modules.
  3. Git clone this repo as src/mongo/db/modules/inject
  4. Build MongoDB
  5. Now try the new aggregation stage:
@erh
erh / histogram.py
Last active July 31, 2021 06:46
This is a very simple python program that reads your email inbox and generates a histogram of how much email is unread in your inbox.
#/usr/bin/env python
###
### This generates a very simple histogram of unread e-mail in your INBOX.
### This is meant as a toy, and your are free to do whatever you want with the code.
###
# core python libraries
import datetime
@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>
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 } )
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",
t = db.blah;
t.drop();
t.save( { screenshots : 1 } )
t.save( { screenshots : [ 1 ] } )
printjson( t.find( { "$where" : "this.screenshots instanceof Array" } ).toArray() )
// 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. */