Skip to content

Instantly share code, notes, and snippets.

@pyengwoei
Created October 14, 2016 05:49
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 pyengwoei/f34848cc5bf1911e19e6b7773a740c41 to your computer and use it in GitHub Desktop.
Save pyengwoei/f34848cc5bf1911e19e6b7773a740c41 to your computer and use it in GitHub Desktop.
var alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),
length = 64,
map = {},
seed = 0,
i = 0,
prev;
function encode(num) {
var encoded = "";
do {
encoded = alphabet[num % length] + encoded;
num = Math.floor(num / length)
} while (num > 0);
return encoded
}
function yeast() {
var now = encode(+new Date);
if (now !== prev) return seed = 0, prev = now;
return now + "." + encode(seed++)
}
aaa =yeast();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment