Verifying myself: I am apboobalan on Keybase.io. 1f56MIWYtg-rhu4f7dU146zx69uTyHkTK-Xf / https://keybase.io/apboobalan/sigs/1f56MIWYtg-rhu4f7dU146zx69uTyHkTK-Xf
I hereby claim: * I am apboobalan on github. * I am apboobalan (https://keybase.io/apboobalan) on keybase. * I have a public key ASB-iyrDuLWjant6ITMdFLdEr3hbQ9NyU2VH_8CsAgOcAwo To claim this, I am signing this object:
{ "body": { "key": { "eldest_kid": "01207e8b2ac3b8b5a36a7b7a21331d14b744af785b43d372536547ffc0ac02039c030a", "host": "keybase.io", "kid": "01207e8b2ac3b8b5a36a7b7a21331d14b744af785b43d372536547ffc0ac02039c030a", "uid": "8f124505ff7c983056f3c82f46119919", "username": "apboobalan" }, "merkle_root": { "ctime": 1580020156, "hash": "e0d8fd66fe3baa0a6c6dcdf2e52e0bfdbdaad42673ebe062fd836a532cbcc2a77d5968d4138a6fc496c4c1c5fe7f6c2d48c55bb8f4e86abbd066a56ab29ab4f5", "hash_meta": "578d3e9036130e30704b79838a10e6417652c9eaf7c7fd0e47479c9ea9773209", "seqno": 14367447 }, "service": { "entropy": "YVu0o+FLVp0GNvREKV2SFT7R", "name": "github", "username": "apboobalan" }, "type":
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 Streamy do | |
def start do | |
start = fn -> 0 end | |
next = fn value -> {[value + 1], value + 1} end | |
stop = fn value -> value end | |
Stream.resource(start, next, stop) | |
end | |
end | |
require Integer |
- Scalability triangle
- Performance, maintenance, cost
- WS lifecycle
- inspect ws inside browser dev tools
- Initial call is made using HTTP and then 101 protocol switch response is received and the connection is upgraded to ws
- Optional heartbeat messages are used in check connection.
- Phoenix pings server every 30 seconds.
- Server will close connection if it doesn't receive ping within 60 seconds.
- use wss:// for security.
- ws doesn't follow CORS policy.
- To define type spec for a functions
@spec function_name(arg_1_type, arg_2_type) :: return_type
- To define new type
@type new_type_name :: existing_type
- To document type place
@typedoc """ description """
above type definition. - We can create product types such as lists, tuples and maps using their own syntax with members being the types.
- Eg. Product types
@type statuses :: [atom]
@type number_with_remark :: {number, String.t}
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
defimpl Enumerable, for: BitString do | |
def count(string), do: {:ok, string |> String.length()} | |
def member?(string, substring), do: {:ok, string |> String.contains?(substring)} | |
def slice(string), | |
do: | |
{:ok, string |> String.length(), | |
fn start_position, end_position -> | |
string |
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 Validator do | |
defmacro having({:in, _, [lhs, rhs]}) when lhs |> is_binary and rhs |> is_binary, | |
do: rhs |> String.contains?(lhs) | |
defmacro having({:in, _, [_lhs, _rhs]}), do: false | |
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 TaskiFirst.Taski do | |
def async(fun) do | |
spawning_process = self() | |
spawn(fn -> spawning_process |> send(fun.()) end) | |
end | |
def await() do | |
receive do | |
result -> result | |
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 Taski.Taski do | |
def async(fun) do | |
spawning_process = self() | |
spawn(fn -> spawning_process |> send({self(), fun.()}) end) | |
end | |
def await(pid) do | |
receive do | |
{^pid, result} -> result | |
end |