Skip to content

Instantly share code, notes, and snippets.

View zsoldosp's full-sized avatar

Peter Zsoldos zsoldosp

View GitHub Profile
@caindy
caindy / uuid.ex
Last active August 29, 2015 13:56
Elixir module to create unique identifiers of specified length, with serialization to and from strings. Put here to solicit feedback on coding style/correctness, as I am new to Elixir.
defmodule Hello.Util.UUID do
def new(byte_count // 16) do
dividend = div(byte_count, 16)
remainder = rem(byte_count, 16)
cnt = case remainder do
r when r === 0 -> dividend
_ -> dividend + remainder
end
make cnt, byte_count, <<>>