Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// generates a character range collection from a to z
JSON.stringify(Array.apply(null, {length: 26}).map(function (x,i) { return {userId: String.fromCharCode(97 + i) }}));
// generates a collection of from and to
JSON.stringify(Array.apply(null, {length: 26}).map(function (x,i) { from = String.fromCharCode(97 + (Math.random() * (26 - i) + i)); to = String.fromCharCode(97 + (Math.random() * (26 - 0) + 0)); return {from: from, to:to} }));
// generates a collection of user and music
JSON.stringify(Array.apply(null, {length: 100}).map(function (x,i) { return {musicId: "m" + Math.floor(Math.random() * (10 - i) + i), userId: String.fromCharCode(97 + (Math.random() * (26 - 0) + 0))} }));
// generates a random JSON collection with a musicId and generes attributes
JSON.stringify(Array.apply(null, {length: 100}).map(function (x,i) { return {musicId: "m" + (i + 1), generes: (Math.random() / +new Date()).toString(24).replace(/[^a-z]+/g, '') + "," + (Math.random() / +new Date()).toString(24).replace(/[^a-z]+/g, '')} }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment