Skip to content

Instantly share code, notes, and snippets.

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},
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"}
# 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"
# 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
def some_fun(a, b, c) do
IO.inspect binding()
...
end
iex> some_fun(:foo, "bar", :baz)
[a: :foo, b: "bar", c: :baz]
def some_fun(a, b, c) do
require IEx; IEx.pry
...
end
my_list = [1, 2, 3]
IO.inspect(my_list)
# Outputs
[1, 2, 3]
@leandrocp
leandrocp / io_inspect_3_label.ex
Last active May 17, 2018 10:46
io_inspect_3_label.ex
[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]
{
"type": "object",
"properties": {
"nome": { "type": "string" },
"idade": { "type": "number" },
"data_nascimento": {
"type": "string",
"format": "date-time"
},
"falecido": { "type": "boolean"}