Skip to content

Instantly share code, notes, and snippets.

@chris-campbell
Created September 11, 2018 01:42
Show Gist options
  • Select an option

  • Save chris-campbell/0e2016c073745ca86fbf29cf0994f8e6 to your computer and use it in GitHub Desktop.

Select an option

Save chris-campbell/0e2016c073745ca86fbf29cf0994f8e6 to your computer and use it in GitHub Desktop.
def uuid
characters = ("a".."f").to_a.concat((1..9).to_a)
uuid = ""
sequence = [8, 4, 4, 8, 12]
sequence.each do |i|
i.times { uuid += characters.sample.to_s }
uuid += "-" unless i == 12
end
uuid
end
uuid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment