Created
May 29, 2018 23:13
-
-
Save rsgrafx/74f20093acf28c767c171c13fddca395 to your computer and use it in GitHub Desktop.
Elixir Atom Snippets
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
'.source.elixir': | |
'Iex Pry': | |
'prefix':'pry' | |
'body': """ | |
require IEx | |
IEx.pry() | |
""" | |
'New GenServer': | |
'prefix':'genmod' | |
'body': """ | |
defmodule $1 do | |
use GenServer | |
def start_link(_) do | |
GenServer.start_link(__MODULE__, %{}) | |
end | |
def init(opts) do | |
{:ok, opts} | |
end | |
end | |
""" | |
'New Struct Module': | |
'prefix':'defms' | |
'body':""" | |
defmodule $1 do | |
defstruct [] | |
end | |
""" | |
'Enum.map': | |
'prefix':'map' | |
'body':""" | |
Enum.map($1, fn($2) -> end) | |
""" | |
'GenServer handle call': | |
'prefix':'hcall' | |
'body': """ | |
def handle_call($1, from, state) do | |
{:reply, state, state} | |
end | |
""" | |
'GenServer Handle Call': | |
'prefix':'defcall' | |
'body': """ | |
def handle_call($1, from, state) do | |
{:reply, state, state} | |
end | |
""" | |
'GenServer handle Cast': | |
'prefix':'hcast' | |
'body': """ | |
def handle_cast($1, state) do | |
{:noreply, state} | |
end | |
""" | |
'GenServer Handle Cast': | |
'prefix':'defcast' | |
'body': """ | |
def handle_cast($1, state) do | |
{:noreply, state} | |
end | |
""" | |
'GenServer Handle Info': | |
'prefix':'definfo' | |
'body': """ | |
def handle_info($1, state) do | |
{:noreply, state} | |
end | |
""" | |
'Supervisor': | |
'prefix':'ovisor' | |
'body':""" | |
defmodule $1 do | |
use Supervisor | |
def start_link(arg) do | |
Supervisor.start_link(__MODULE__, arg) | |
end | |
def init(arg) do | |
children = [ | |
worker(${1:.Worker}, [$3], restart: :temporary) | |
] | |
supervise(children, strategy: :simple_one_for_one) | |
end | |
end | |
""" | |
'IO Inspect': | |
'prefix':'io' | |
'body':""" | |
IO.inspect($1, label: "VALUE: \#{$1\} ->") | |
""" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment