View server.ex
defmodule Todo.Manager do
use GenServer
## Client API
@doc """
Starts the `Todo.Manager`.
def start_link(table, sup, event, opts \\ []) do
{:ok, pid} = GenServer.start_link(__MODULE__, {table, sup, event}, opts)
View rotor.exs
defmodule Rotor do
@doc """
Starts a new rotor as part of a supervision tree.
## Options
* `:name` - the registered name of the rotor
def start_link(paths, opts) do
View config.exs
# config/config.exs
use Mix.Config
config :lager,
handlers: [
lager_console_backend: [:info, {:lager_default_formatter, [:time, ' [', :severity, '] ', :message, '\n']}]
crash_log: :undefined,
error_logger_hwm: 150
View fib_with_agents.exs
defmodule FibAgent do
def start_link do
cache = Enum.into([{0, 0}, {1, 1}],
Agent.start_link(fn -> cache end)
def fib(pid, n) when n >= 0 do
Agent.get_and_update(pid, &do_fib(&1, n))
View foo.exs
defmodule Foo do
@menu [foo: 1, bar: 3, baz: 2]
@filtered_menu @menu |> Enum.filter(...)
def filtered_menu do
View user_drv.diff
diff --git a/lib/kernel/src/user_drv.erl b/lib/kernel/src/user_drv.erl
index 7b4ffb0..745fe46 100644
--- a/lib/kernel/src/user_drv.erl
+++ b/lib/kernel/src/user_drv.erl
@@ -172,17 +172,17 @@ server_loop(Iport, Oport, Curr, User, Gr) ->
{Iport,eof} ->
Curr ! {self(),eof},
server_loop(Iport, Oport, Curr, User, Gr);
- {User,Req} -> % never block from user!
- io_request(Req, Iport, Oport),
View poolboy_mix.exs
defmodule Poolboy.Mixfile do
use Mix.Project
@version!("VERSION") |> String.strip
def project do
[app: :poolboy,
version: @version,
description: "A hunky Erlang worker pool factory",
package: package]
View gist:11173516


A map pattern will match any map that has the given keys and values. For example, %{"hello" => world} will match any map that has the key "hello". An empty map therefore matches all maps.


A map pattern will match any map that has all the keys specified in the pattern. The values for the matching keys must also match. For example, %{"hello" => world} will match any map that has the key "hello" and assign the value to world, while %{"hello" => "world"} will match any map that has the key"hello"with value equals to"world". An empty map pattern (%{}`) will match all maps.

View pdict.diff
diff --git a/lib/task/sup.ex b/lib/task/sup.ex
index 3070aa2..4cc4968 100644
--- a/lib/task/sup.ex
+++ b/lib/task/sup.ex
@@ -66,10 +66,14 @@ defmodule Task.Sup do
@spec async(Supervisor.supervisor, module, atom, [term]) :: Task.t
def async(supervisor, module, fun, args) do
- { :ok, pid } = Supervisor.start_child(supervisor, [self(), { module, fun, args }])
+ lock = make_ref()
View 1_gen_server.ex
defmodule Mix.TasksServer do
@moduledoc false
use GenServer.Behaviour
def start_link() do
:gen_server.start_link({ :local, __MODULE__ }, __MODULE__, :ok, [])
def clear_tasks() do
call :clear_tasks