Created
June 30, 2016 07:28
-
-
Save ijunaid8989/c59e4ae43bbc4166ec0db55a12a84bba to your computer and use it in GitHub Desktop.
This file contains hidden or 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
defp generate_exid(title) do | |
clip_exid = | |
title | |
|> String.replace_trailing(" ", "") | |
|> String.downcase | |
|> String.slice(0..5) | |
chars = (?a..?z |> Enum.into([]) |> Enum.map(&to_string([&1]))) ++ (1..9 |> Enum.to_list) | |
random_string = Enum.map(0..3, fn(_) -> Enum.random(chars) end) |> Enum.join("") | |
"#{clip_exid}-#{random_string}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment