{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
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
# project_root/.formatter.exs | |
[ | |
# functions to let allow the no parens like def print value | |
locals_without_parens: [hello: 2, get_user: 1, addtion: *], | |
# files to format | |
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"], |
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
defmodule TcpServer do | |
use GenServer | |
def start_link() do | |
ip = Application.get_env :tcp_server, :ip, {127,0,0,1} | |
port = Application.get_env :tcp_server, :port, 6666 | |
GenServer.start_link(__MODULE__,[ip,port],[]) | |
end | |
def init [ip,port] do |
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
defmodule EtsKeys do | |
def keys(table_name) do | |
first_key = :ets.first(table_name) | |
keys(table_name, first_key, [first_key]) | |
end | |
def keys(_table_name, '$end_of_table', ['$end_of_table'|acc]) do | |
acc | |
end | |
def keys(table_name, current_key, acc) do |
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
defmodule MyGuards do | |
defmacro is_kid age do | |
quote do: unquote(age) < 12 | |
end | |
defmacro is_adult age do | |
quote do: unquote(age) > 18 | |
end |
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
defmodule Hello do | |
def hello(name,age) when is_kid(age) do | |
IO.puts "Hello Kid #{name}" | |
end | |
def hello(name,age) when is_adult(age) do | |
IO.puts "Hello Mister #{name}" | |
end | |
def is_kid age do | |
age < 12 | |
end |
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
defmodule Hi do | |
def hi1 do | |
IO.puts "hi1" | |
end | |
def hi2 do | |
IO.puts "hi2" | |
end |
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
defmodule Hello do | |
def hello1 do | |
IO.puts "hello1" | |
end | |
def hello2 do | |
IO.puts "hello2" | |
end |
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
defmodule Mix.Tasks.MyTasks.Functions do | |
use Mix.Task | |
@shortdoc "Returns functions in Module" | |
@moduledoc ~S""" | |
This is used to list out the all available functions in the module. | |
You suppose to pass module_name as parameter to the task. | |
#Usage | |
``` |