Skip to content

Instantly share code, notes, and snippets.

@rafops
Last active June 26, 2016 21:27
Show Gist options
  • Save rafops/d4ea9fdc5fe15f9256c1748f7cdd8b92 to your computer and use it in GitHub Desktop.
Save rafops/d4ea9fdc5fe15f9256c1748f7cdd8b92 to your computer and use it in GitHub Desktop.
def uuid_to_urlsafe_base64(uuid)
s = [[uuid.delete('-')].pack('H*')].pack('m')
s.delete!("\n")
s.tr!('+/', '-_')
s.delete!('=')
s
end
uuid_to_urlsafe_base64(SecureRandom.uuid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment