Just random tips and tricks while working with elixir [& phoenix and other libs/frameworks]
{:my_dep, …, compile: false}
Use @tag :wip
in the test you want to run
defmodule MyTest do
use ExUnit.Case
test "first test" do
assert 1 == 1
end
@tag :wip
test "second test" do
assert 3 != 5
end
end
mix test --only wip
Check the Inquisitor repository if you're looking for building composable queries for Ecto.
- c "somefile.exs" - compile the file
- r SomeModule - reload the module
- h some_func - get help for the function
- v [n] - access session history
conn.body_params # gives params from POST
conn.query_params # query string parameters
MIX_ENV=test mix do deps.get, test
mix deps.update <dep_name>
render conn, "index.html", %{layout: false}
# with plug
plug :put_layout, false
# pipe it
conn |> put_layout(false) |> render(...)
:erlang.system_flag(:backtrace_depth, 20)
# with phoenix
# config/env.exs
config :phoenix, :stacktrace_depth, 20
$ iex --name [email protected] --cookie iam_not_so_awesome -S mix phoenix.server # in api server
# on separate shell
$ iex --name [email protected] --remsh [email protected] --cookie iam_not_so_awesome
iex([email protected])1> :observer.start
You can pass args down to erlang via erl
flag.
Example: --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001"
Based on this, you can specify a keyword list arg build_path
to override the default _build
directory.
Example:
def project do
[app: :my_app,
version: "0.0.1",
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
build_path: "custom_build_dir",
deps: deps]
end
Open your preferences and select keymaps. It should open keymaps.cson. Add the following in that file:
'atom-text-editor[data-grammar="text html elixir"]:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'
The grammar can be obtained for any files by opening console (ctrl+shift+i) and type the following with the appropriate file open in your editor:
document.getElementsByTagName('atom-text-editor')