Skip to content

Instantly share code, notes, and snippets.

@dacur
Created November 5, 2014 14:24
Show Gist options
  • Select an option

  • Save dacur/20a1027a8d6d2ef04d6a to your computer and use it in GitHub Desktop.

Select an option

Save dacur/20a1027a8d6d2ef04d6a to your computer and use it in GitHub Desktop.
Creating a random string/GUID. Used it to give a 'group name'/identifier to a set of values.
function CreateGuid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment