Skip to content

Instantly share code, notes, and snippets.

@marcelweder
Last active August 31, 2016 12:56
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 marcelweder/8ad71429a2b9429c5a5d to your computer and use it in GitHub Desktop.
Save marcelweder/8ad71429a2b9429c5a5d to your computer and use it in GitHub Desktop.
Simple JS-Snippet to create random ID
function makeid(length)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for(var i=0; i < length; i++)
{
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
function make_puphpet(prefix)
{
return prefix + '_' + makeid(12);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment