Skip to content

Instantly share code, notes, and snippets.

Johan Wärlander jwarlander

Block or report user

Report or block jwarlander

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cli.ex
defmodule MyApp.CLI do
def main(_args) do
IO.puts("Hello from MyApp!")
View with_test.exs
with foo <- 5, # foo
bar <- foo*3 # bar
IO.puts bar
jwarlander / lib_demo.exs
Created Dec 19, 2016
Example of dynamic (at compile time) delegation from Erlang-style module to Elixir module
View lib_demo.exs
# Actual Elixir module with all the functions
defmodule LibDemo do
def hello(), do: IO.puts "Hello, World!"
def hello(name), do: IO.puts "Hello, #{name}!"
defmodule LibDemo.Utils do
def make_args(0), do: []
def make_args(n) do, fn n -> {String.to_atom("arg#{n}"), [], Elixir} end)
jwarlander / gist:b9da98b00d80c442a3f5
Created Jun 17, 2015
Start a set of asynchronous tasks, then collect results into a list
View gist:b9da98b00d80c442a3f5
iex(1)> tasks = for n <- 1..100, do: Task.async(fn -> n*n end)
[%Task{pid: #PID<0.61.0>, ref: #Reference<>},
%Task{pid: #PID<0.62.0>, ref: #Reference<>},
%Task{pid: #PID<0.63.0>, ref: #Reference<>},
%Task{pid: #PID<0.64.0>, ref: #Reference<>},
%Task{pid: #PID<0.65.0>, ref: #Reference<>},
%Task{pid: #PID<0.66.0>, ref: #Reference<>},
%Task{pid: #PID<0.67.0>, ref: #Reference<>},
%Task{pid: #PID<0.68.0>, ref: #Reference<>},
%Task{pid: #PID<0.69.0>, ref: #Reference<>},
View Dockerfile
FROM ubuntu
RUN /bin/bash /
EXPOSE 8083 8086
CMD /opt/influxdb/run
View popd_fsm.erl
%% API
%% gen_fsm callbacks
You can’t perform that action at this time.