Skip to content

Instantly share code, notes, and snippets.

@niahoo
Last active March 15, 2017 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niahoo/8b9e7ff78ab05b14345bb7d094da0bdb to your computer and use it in GitHub Desktop.
Save niahoo/8b9e7ff78ab05b14345bb7d094da0bdb to your computer and use it in GitHub Desktop.
A simple way to have specific static files in memory at any time in elixir with infinite concurrency
defmodule Images do
def image_content(_, 0),
do: unquote(File.read!("path/to/empty/image.png"))
for lang <- ["en", "de", "fr"], amount <- 1..11 do
binary = File.read!(__DIR__ <> "/images/#{lang}-#{amount}.png")
def image_content(unquote(lang), unquote(amount)),
do: unquote(binary)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment