Skip to content

Instantly share code, notes, and snippets.

@betacar
Created July 20, 2014 04:32
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 betacar/ba018d817d413b703f3a to your computer and use it in GitHub Desktop.
Save betacar/ba018d817d413b703f3a to your computer and use it in GitHub Desktop.
// 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