Skip to content

Instantly share code, notes, and snippets.

View leopd's full-sized avatar

Leo Dirac leopd

View GitHub Profile
function add_rand_field(collection) {
collection.find().forEach(function(data) {
collection.update({_id:data._id}, {
$set:{rand:Math.random()}
});
});
collection.ensureIndex({rand:1},{background:true})
}
@leopd
leopd / .gitconfig
Created August 28, 2013 15:37 — forked from srleo/.gitconfig
[alias]
lgb = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches
@leopd
leopd / groupby.js
Created August 28, 2013 15:37 — forked from srleo/groupby.js
count_by = function(collection,field) {
return collection.aggregate({
$group: {
_id: "$" + field,
count: { $sum: 1 }
}
})
}
 
count_by(db.vid10,'char');