Alex Troush - IEx Cheat Sheet

29
IEx Cheat Sheet @troush69 | github.com/Troush Presentation.Supervisor.start_link(self(), {:slide, 1})

Transcript of Alex Troush - IEx Cheat Sheet

Page 1: Alex Troush - IEx Cheat Sheet

IEx Cheat Sheet

@troush69 | github.com/Troush

Presentation.Supervisor.start_link(self(), {:slide, 1})

Page 2: Alex Troush - IEx Cheat Sheet

Alex

~8 Commits to Elixir Core

~1 Commit to Phoenix.HTML

~2 Commits to Ecto

10 month of production Phoenix

~ 2 year of Elixir lurking

Page 3: Alex Troush - IEx Cheat Sheet

Starting IEx

Page 4: Alex Troush - IEx Cheat Sheet

IEx.Server.start

Page 5: Alex Troush - IEx Cheat Sheet

“ctrl+c”

Page 6: Alex Troush - IEx Cheat Sheet

Ctrl + c menu actually `erl` shell menu● (a)bort - abort interactive mode. Eg: Exit● (c)ontinue - continue interactive mode● (p)roc info - get processes information ● (i)nfo - get Erlang runtime information● (l)oaded – list of loaded modules to current shell● (v)ersion – version of `erl`● (k)ill – kill process menu● (D)b-tables - get info about d/ets avaible in current

shell● (d)istribution - distribution info

Page 7: Alex Troush - IEx Cheat Sheet

Ctrl + g

Page 8: Alex Troush - IEx Cheat Sheet

Ctrl-\

What I didn’t know is that you can exit the shell by sending Ctrl-\. The shell will exit immediately. As far as I know, it has the same effect as aborting the shell in the Break command, it doesn’t affect remote nodes and it also works outside of iex (for example, you can use to terminate your tests)

Page 9: Alex Troush - IEx Cheat Sheet

.iex.exs

Every time IEx starts it will look for a .iex.exs configuration file. If it’s not present in the current directory, then the user’s home directory (~/.iex.exs) will be used as the fallback.

Page 10: Alex Troush - IEx Cheat Sheet

.iex.exs

1 IO.puts "Hello, World"

$ iex

Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.4.0) - press Ctrl+C to exit (type h() ENTER for help)

Hello, World

iex(1)>

Page 11: Alex Troush - IEx Cheat Sheet

Configuring the shell

Page 12: Alex Troush - IEx Cheat Sheet
Page 13: Alex Troush - IEx Cheat Sheet

No limit on IO.inspect

IEx.configure [inspect: [limit: :infinity]]

Page 14: Alex Troush - IEx Cheat Sheet

IEx Helpers

Page 15: Alex Troush - IEx Cheat Sheet

h Module

Page 16: Alex Troush - IEx Cheat Sheet

h Module.fn/arity

Page 17: Alex Troush - IEx Cheat Sheet

I “Hello”

Page 18: Alex Troush - IEx Cheat Sheet

v(n \\ -1)Returns the value of the nth expression in the history.

Page 19: Alex Troush - IEx Cheat Sheet

e Module

Page 20: Alex Troush - IEx Cheat Sheet

IEx.pry()

Page 21: Alex Troush - IEx Cheat Sheet

r(module)Recompiles and reloads the given module.

Please note that all the modules defined in the same file as module are recompiled and reloaded.

Page 22: Alex Troush - IEx Cheat Sheet

respawnRespawns the current shell by starting a new shell process.

Returns true if it worked.

Page 23: Alex Troush - IEx Cheat Sheet

Debugging Phoenix

Views

Page 24: Alex Troush - IEx Cheat Sheet

Debugging Phoenix

Templates

Page 25: Alex Troush - IEx Cheat Sheet

Debugging Phoenix

Tests

Don’t forget to run your test suite with:

iex -S mix test --trace

Page 26: Alex Troush - IEx Cheat Sheet

remsh

Page 27: Alex Troush - IEx Cheat Sheet

Remsh ctrl+G

Page 28: Alex Troush - IEx Cheat Sheet

epmdErlang Port Mapper Daemon

Page 29: Alex Troush - IEx Cheat Sheet

Questions?