Skip to content

Instantly share code, notes, and snippets.

@nolanamy
Created April 21, 2015 19:05
Show Gist options
  • Save nolanamy/5b40a5a236be2c0157cd to your computer and use it in GitHub Desktop.
Save nolanamy/5b40a5a236be2c0157cd to your computer and use it in GitHub Desktop.
Check for hat() collisions
var hat = require('hat');
var _ = require('lodash');
var rack = {};
for(var i = 0; i < 1000000; i++) {
var id = hat();
rack[id] = rack[id] ? rack[id] + 1 : 1;
}
var dupes = _.filter(rack, function(a) { return a > 1 });
console.log(dupes);
@nolanamy
Copy link
Author

Consistently 0 collisions. Collisions only seem to happen after server reboots or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment