Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created December 30, 2015 16:27
Show Gist options
  • Save jerodsanto/90c03f52fb0691356a24 to your computer and use it in GitHub Desktop.
Save jerodsanto/90c03f52fb0691356a24 to your computer and use it in GitHub Desktop.
Elixir's pipeline operator makes FP joyous. Here it is transforming an email address for Gravatar'ing
def gravatar_url(email, size) do
hash = email
|> String.strip
|> String.downcase
|> :erlang.md5
|> Base.encode16(case: :lower)
"https://secure.gravatar.com/avatar/#{hash}.jpg?s=#{size}&d=mm"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment