Last active
March 15, 2017 16:30
-
-
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
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 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