This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function( key , values ){ | |
var confidence_threshold = 0.0 | |
var total = 0 | |
var sc = 0.0 | |
var cats = [] | |
var links = [] | |
for ( var i=0; i<values.length; i++ ) { | |
total += values[i].count | |
sc += (values[i].score || 0) | |
links.push({hash:values[i].hash,title:values[i].title, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.events.mapReduce( | |
function(){ | |
emit({category:this.category, uid:this.uid}, null); | |
}, | |
function(key, values){ | |
return null; | |
}, | |
{query: {type: "pageview"}} | |
).map_reduce( | |
function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "test.h" | |
#include "mongo.h" | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(){ | |
mongo_connection conn[1]; | |
mongo_connection_options opts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ MONGO_INCLUDE_PATH=/usr/include/mongo/ scons . | |
scons: Reading SConscript files ... | |
scons: done reading SConscript files. | |
scons: Building targets ... | |
g++ -o gridfs_c_helpers.o -c -I/usr/include/mongo -INone gridfs_c_helpers.cpp | |
scons: done building targets. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.test.find({loc:{$near:[0,0]}}) | |
{ "_id" : ObjectId("4ba7e616b8c125a527c38708"), "name" : "a", "loc" : [ 0, 0 ] } | |
{ "_id" : ObjectId("4ba7e61ab8c125a527c38709"), "name" : "b", "loc" : [ 0, 0 ] } | |
{ "_id" : ObjectId("4ba7e620b8c125a527c3870a"), "name" : "c", "loc" : [ 1, 1 ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* test.c */ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#ifndef _WIN32 | |
#include <sys/time.h> | |
#endif | |
static char hexbyte1(char hex){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.foo.ensureIndex({a:1}) | |
> db.foo.ensureIndex({b:1}) | |
> db.foo.insert({a:1}) | |
> db.foo.insert({b:1}) | |
> db.foo.insert({a:1, b:1}) | |
> db.foo.find({$or:[{a:1}, {b:1}]}).explain() | |
{ | |
"clauses" : [ | |
{ | |
"cursor" : "BtreeCursor a_1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from pymongo import Connection | |
import subprocess | |
import sys | |
def advance(cur) | |
try: | |
return cur.next() | |
except StopIteration: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm | |
function map() { | |
emit(1, // Or put a GROUP BY key here | |
{sum: this.value, // the field you want stats for | |
min: this.value, | |
max: this.value, | |
count:1, | |
diff: 0, // M2,n: sum((val-mean)^2) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ convert - /tmp/o.png << EOF | |
P1 | |
# This is an example bitmap of the letter "J" | |
6 10 | |
0 0 0 0 1 0 | |
0 0 0 0 1 0 | |
0 0 0 0 1 0 | |
0 0 0 0 1 0 | |
0 0 0 0 1 0 | |
0 0 0 0 1 0 |
OlderNewer