rimmer333
5/4/2012 - 1:04 PM

UUID generator in 8 lines of CoffeeScript

UUID generator in 8 lines of CoffeeScript

  UUID: ->
    hex = "0123456789ABCDEF"
    s = (Math.floor(Math.random() * 0x10) for [0..35])
    s[14] = 4
    s[19] = (s[19] & 0x3) | 0x8
    s = (hex[num] for num in s)    
    s[8] = s[13] = s[18] = s[23] = "-"
    s.join ""