Skip to content

Instantly share code, notes, and snippets.

@Nesuarg
Nesuarg / guid.js
Last active July 2, 2019 07:24
globally unique identifier in Javascript
function unique() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
// usage
var guid = (unique() + unique() + "-" + unique() + "-4" + unique().substr(0,3) + "-" + unique() + "-" + unique() + unique() + unique()).toLowerCase();
@Nesuarg
Nesuarg / phoneregex.js
Last active August 23, 2016 06:56
REGEX Phonenumber danish (+45) and max 15 input with whitepace
// Regex for Danish(or 8 digits numbers include '+45' and white spaces) phonenumbers.
^(?!\s*$)[0-9\s \+]{8,15}$