Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Created February 16, 2013 00:02
Show Gist options
  • Save gjohnson/4964657 to your computer and use it in GitHub Desktop.
Save gjohnson/4964657 to your computer and use it in GitHub Desktop.
padding hack
var padding = {
'128': pad(128),
'512': pad(512)
};
collection.insert({
aliases: [ padding['128'] ],
profile: { 'noop': padding['512'] },
}, function(err, doc){
var query = { _id: doc._id };
var update = { $unset: { 'profile.noop': 1 }, $pop: { 'aliases': -1 } };
collection.update(query, update, noop);
});
function pad(bytes){
var buff = new Buffer(bytes);
buff.fill(0);
return buff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment