- https://confreaks.tv/videos/railsconf2012-keynote-simplicity-matters
- https://confreaks.tv/videos/jaxconf2012-keynote-the-value-of-values
This file contains hidden or 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
| iex> :sys.get_status pid | |
| {:status, #PID<0.134.0>, {:module, :gen_server}, | |
| [ | |
| [ | |
| "$initial_call": {Sequence.Server, :init, 1}, | |
| "$ancestors": [#PID<0.118.0>, #PID<0.57.0>] | |
| ], | |
| :running, | |
| #PID<0.118.0>, | |
| [statistics: {{{2017, 12, 23}, {14, 11, 13}}, {:reductions, 14}, 3, 0}, |
This file contains hidden or 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
| iex(1)> defmodule Example, do: use GenServer | |
| iex(2)> {:ok, pid} = GenServer.start_link(Example, %{ping: "pong"}) | |
| iex(3)> :sys.get_state(pid) | |
| %{ping: "pong"} |
This file contains hidden or 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
| # import apex adef macro | |
| import Apex.AwesomeDef | |
| # change def to adef | |
| adef test(data, options \\ []) do | |
| data | |
| end | |
| # when you call your function, you'll receive detailed information about its execution | |
| iex(1)> Apex.test "foo" |
This file contains hidden or 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
| # given that you have this module | |
| defmodule MyApp.Example do | |
| def sum(x, y) do | |
| x + y | |
| end | |
| end | |
| # start a new iex session | |
| $ iex -S mix |
This file contains hidden or 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
| def some_fun(a, b, c) do | |
| IO.inspect binding() | |
| ... | |
| end | |
| iex> some_fun(:foo, "bar", :baz) | |
| [a: :foo, b: "bar", c: :baz] |
This file contains hidden or 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
| def some_fun(a, b, c) do | |
| require IEx; IEx.pry | |
| ... | |
| end |
This file contains hidden or 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
| my_list = [1, 2, 3] | |
| IO.inspect(my_list) | |
| # Outputs | |
| [1, 2, 3] |
This file contains hidden or 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
| [1, 2, 3] | |
| |> IO.inspect(label: "before") | |
| |> Enum.map(&(&1 * 2)) | |
| |> IO.inspect(label: "after") | |
| |> Enum.sum | |
| # Outputs | |
| before: [1, 2, 3] | |
| after: [2, 4, 6] |
This file contains hidden or 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
| { | |
| "type": "object", | |
| "properties": { | |
| "nome": { "type": "string" }, | |
| "idade": { "type": "number" }, | |
| "data_nascimento": { | |
| "type": "string", | |
| "format": "date-time" | |
| }, | |
| "falecido": { "type": "boolean"} |