Skip to content

Instantly share code, notes, and snippets.

@volkanozcan2
Created September 6, 2017 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volkanozcan2/9b8a3acdf8207d8fb4c3566b1e7b000d to your computer and use it in GitHub Desktop.
Save volkanozcan2/9b8a3acdf8207d8fb4c3566b1e7b000d to your computer and use it in GitHub Desktop.
createBinaryHuman
let fs = require("fs");
let wr = fs.createWriteStream("./humans");
let stream = require("stream");
Number.prototype.toHex = function(digits = 2) {
let l = this.valueOf().toString(16);
if (digits - l.length <= 0) {
return l
} else {
return Array((digits - l.length) + 1).join("0") + l
}
};
function reBuf(s, a, l, n, sn) {
let str = [s.toHex(1), a.toHex(), l.toHex(), n.toHex(4), sn.toHex(5)].join("");
return Buffer.from(str, "hex");
}
for (var a = 0; a < 1e5; a++) {
wr.write(reBuf(1, ~~(Math.random() * 100), ~~(Math.random() * 195), ~~(Math.random() * 5494), ~~(Math.random() * 88799)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment