Skip to content

Instantly share code, notes, and snippets.

defmodule App do
use Plug
# I use power_strip as a collection of plugs... could use stack
# I use spark to actually fire a connection
# alternatives source,
use Authentication.Appliance
power_strip Request #defaults to :request
# Plug
## Plugs are wrappers around functions
```elixir
defmodule HelloWorld
use Plug
plug :hello

Plug

A connection is a common record across all functions

Functions are a series of transformations on the connection. A connection will have some convenience areas for a problem domain (initially, web servers), and a dictionary for user data. There will also be an API for conveniently transforming the connection.

def recv(%{"type" => "start", "room" => room_name, "email" => email}, conn, s) do
# ...
end
receive :start, %{room: room_name, email: email} do
# ...
end
@batate
batate / coveralls_mix.exs
Last active October 11, 2019 20:00
coveralls elixir setup
defmodule Chat.Mixfile do
defp deps do
[{:excoveralls, only: :test}]
end
defp test(args) do
...
Mix.Task.run("test")
Mix.shell.info("")
@batate
batate / controller_test.exs
Created March 6, 2015 15:01
ExUnit and Duplication
setup do
# universal setup
end
test "a get" do
...
end
test "logged in get" do
login_user
@batate
batate / wtihout_should_test.exs
Created March 6, 2015 16:20
Language Matters
test "chat" do
chat = Chat.create(...)
assert chat != nil
end
@batate
batate / mm.exs
Created March 6, 2015 16:51
one experiment, multiple measurements
test "chat" do
bucket = create_bucket
assert %{__struct__: "Bucket"} = bucket
assert Bucket.empty?(bucket)
Bucket.add(bucket, 1)
assert bucket.contents == [1]
end
# instead
@batate
batate / lies-and-comments-freebsd.c
Created October 14, 2018 19:17
Lies Damned Lies and Statistics1 Gig City Elixir
/* caller must hold instance lock */
static int reset_hardware(...) {...}
static_int_in2000_bus_reset(...) {
...
reset_hardware( … );
...
}