Skip to content

Instantly share code, notes, and snippets.

@sporkmonger
Created December 2, 2008 05:28
Show Gist options
  • Save sporkmonger/31013 to your computer and use it in GitHub Desktop.
Save sporkmonger/31013 to your computer and use it in GitHub Desktop.
This is NOT how to generate valid UUIDs.
def rand_hex_3(l)
"%0#{l}x" % rand(1 << l*4)
end
def rand_uuid
[8,4,4,4,12].map {|n| rand_hex_3(n)}.join('-')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment