These are shortcuts, commands, and notes about using Elixir.
Prefix with MIX_DEBUG=1
recompile()
Remember that anything in .iex.exs
of project root will get loaded when
starting IEx, so useful for test data and the like.
Automatic parallelism, such as with Task.async*
, defaults to the number of
logical cores. See the value with
System.schedulers_online()
or
:erlang.system_info(:logical_processors_available)
Pass an argument to get specific line number. Defaults to -1
, last line.
v()
IEx by default shortens long results. To get around it,
fun() |> IO.inspect(limit: :infinity)
If you have some bad syntax in IEx, like a dangling parenthesis or quote, this will dump the statement.
#iex:break
https://paraxial.io/blog/throttle-requests
To quickly get a sense of how long something is taking, wrap it in
:timer.tc/1
. It returns result in μs (microseconds)
{time, result} = :timer.tc(fn ->
# code to test here
end)
IO.inspect(time, label: :microseconds)
result
Dangerous to use, even for testing.
Ecto.Repo.query("TRUNCATE #{Module.Name.__schema__(:source)}", [])
To output the formatted docs.
h Your.Module.Name
To see the exported functions of a module.
exports Your.Module
IEx.configure(inspect: [limit: :infinity])