Skip to content

Instantly share code, notes, and snippets.

@myobie myobie/uuids.ex

Created Apr 27, 2020
Embed
What would you like to do?
Save 14 characters for UUIDs
def generate_id do
result =
Ecto.UUID.generate()
|> String.replace(~r/-+/, "")
|> Base.decode16(case: :lower)
case result do
:error ->
throw("Something went wrong generating a uuid")
{:ok, value} ->
Base.encode64(value)
|> String.replace(~r/=+$/, "")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.