Created
March 9, 2013 19:05
-
-
Save RyanScottLewis/5125310 to your computer and use it in GitHub Desktop.
Not my code, just converted it into CoffeeScript with human variable names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.UUID = | |
generate: -> | |
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (character) -> | |
random_number = Math.random()*16 | 0 # Random number between (and including) 0 and 15 | |
value = if character == 'x' then random_number else (random_number&0x3|0x8) | |
value.toString(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment