Skip to content

Instantly share code, notes, and snippets.

@aal89
Created July 18, 2019 08:52
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 aal89/d458d78e21bcef942ab66934b1438693 to your computer and use it in GitHub Desktop.
Save aal89/d458d78e21bcef942ab66934b1438693 to your computer and use it in GitHub Desktop.
Generates text files with random numbers of a particular size. Size is given in kb's as first parameter, defaults to 100.
const fs = require("fs");
const lineLength = 126;
const sizeInKb = process.argv[2] || 100;
let data = "";
for(var i = 0; i < sizeInKb * 1024; i++) {
if (i && i % lineLength === 0) {
data += "\n";
} else {
data += Math.floor(Math.random() * 10);
}
}
fs.writeFileSync(`./${sizeInKb}kb.txt`, data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment