Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Created March 9, 2013 19:05
Show Gist options
  • Save RyanScottLewis/5125310 to your computer and use it in GitHub Desktop.
Save RyanScottLewis/5125310 to your computer and use it in GitHub Desktop.
Not my code, just converted it into CoffeeScript with human variable names.
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