Skip to content

Instantly share code, notes, and snippets.

@danschultzer
Created February 7, 2018 06:14
Show Gist options
  • Save danschultzer/99c21ba403fd7f49a26cc40571ff5cce to your computer and use it in GitHub Desktop.
Save danschultzer/99c21ba403fd7f49a26cc40571ff5cce to your computer and use it in GitHub Desktop.
Random alphanumeric id generator in elixir
defmodule Generator
def gen_reference() do
min = String.to_integer("100000", 36)
max = String.to_integer("ZZZZZZ", 36)
max
|> Kernel.-(min)
|> :rand.uniform()
|> Kernel.+(min)
|> Integer.to_string(36)
end
end
@dimawalaadormeo
Copy link

dimawalaadormeo commented Mar 2, 2020

Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment