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!")
end
end
View with_test.exs
with foo <- 5, # foo
bar <- foo*3 # bar
do
IO.puts bar
end
@jwarlander
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}!"
end
defmodule LibDemo.Utils do
def make_args(0), do: []
def make_args(n) do
Enum.map(1..n, fn n -> {String.to_atom("arg#{n}"), [], Elixir} end)
@jwarlander
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<0.0.0.82>},
%Task{pid: #PID<0.62.0>, ref: #Reference<0.0.0.83>},
%Task{pid: #PID<0.63.0>, ref: #Reference<0.0.0.84>},
%Task{pid: #PID<0.64.0>, ref: #Reference<0.0.0.85>},
%Task{pid: #PID<0.65.0>, ref: #Reference<0.0.0.86>},
%Task{pid: #PID<0.66.0>, ref: #Reference<0.0.0.87>},
%Task{pid: #PID<0.67.0>, ref: #Reference<0.0.0.88>},
%Task{pid: #PID<0.68.0>, ref: #Reference<0.0.0.89>},
%Task{pid: #PID<0.69.0>, ref: #Reference<0.0.0.90>},
View Dockerfile
FROM ubuntu
ADD influxdb-install.sh /influxdb-install.sh
RUN /bin/bash /influxdb-install.sh
EXPOSE 8083 8086
CMD /opt/influxdb/run
View popd_fsm.erl
-module(popd_fsm).
-behaviour(gen_fsm).
%% API
-export([stop/0]).
-export([set_socket/0]).
-export([start_link/3]).
%% gen_fsm callbacks
You can’t perform that action at this time.