Created
February 7, 2018 06:14
-
-
Save danschultzer/99c21ba403fd7f49a26cc40571ff5cce to your computer and use it in GitHub Desktop.
Random alphanumeric id generator in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice.