Skip to content

Instantly share code, notes, and snippets.

View Laymer's full-sized avatar
:shipit:
Looking for cool C, TCL & Erlang things to test

Igor K Laymer

:shipit:
Looking for cool C, TCL & Erlang things to test
View GitHub Profile
@Laymer
Laymer / gen_server_template.erl
Last active May 29, 2018 09:17
A template file for Erlang gen_server modules
%%%-------------------------------------------------------------------
%% @author Igor Kopestenski <i.kopest@gmail.com>
%% [https://github.com/Laymer/GrispLasp/]
%% @doc This is a <em>gen_server</em> template module.
%% @end
%%%-------------------------------------------------------------------
-module(gen_server_template).
-behaviour(gen_server).
@Laymer
Laymer / ErlangSupChildSpec.erl
Created May 30, 2018 19:35
Erlang Supervisor Child Specs
child_spec() = #{id => child_id(), % mandatory
start => mfargs(), % mandatory
restart => restart(), % optional
shutdown => shutdown(), % optional
type => worker(), % optional
modules => modules()} % optional
child_id() = term()
mfargs() = {M :: module(), F :: atom(), A :: [term()]}
modules() = [module()] | dynamic
restart() = permanent | transient | temporary
@Laymer
Laymer / ErlangSupChildSpec.erl
Created May 30, 2018 19:35
Erlang Supervisor Child Specs
child_spec() = #{id => child_id(), % mandatory
start => mfargs(), % mandatory
restart => restart(), % optional
shutdown => shutdown(), % optional
type => worker(), % optional
modules => modules()} % optional
child_id() = term()
mfargs() = {M :: module(), F :: atom(), A :: [term()]}
modules() = [module()] | dynamic
restart() = permanent | transient | temporary
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
%% This is a sample rebar.conf file that shows examples of some of rebar's
%% options.
%% Credits : Erlang team & lrascao
%% == Artifacts ==
%% Artifacts are files generated by other tools (or plugins) and whose
%% presence is necessary for a build to be considered successful
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
%% This is a sample rebar.conf file that shows examples of some of rebar's
%% options.
%% == Artifacts ==
%% Artifacts are files generated by other tools (or plugins) and whose
%% presence is necessary for a build to be considered successful
{artifacts, ["priv/mycode.so"]}.
@Laymer
Laymer / gist:23905df49f787533aebb4a57fc3080a4
Created August 10, 2018 01:53 — forked from chrissimpkins/gist:5bf5686bae86b8129bee
Atom Editor Cheat Sheet (Sweetmeat)

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@Laymer
Laymer / refc_leak.erl
Created August 16, 2018 17:30 — forked from ferd/refc_leak.erl
Find Erlang processes that may be leaking refc binaries
f(MostLeaky).
MostLeaky = fun(N) ->
lists:sublist(
lists:usort(
fun({K1,V1},{K2,V2}) -> {V1,K1} =< {V2,K2} end,
[try
{_,Pre} = erlang:process_info(Pid, binary),
erlang:garbage_collect(Pid),
{_,Post} = erlang:process_info(Pid, binary),
{Pid, length(Post)-length(Pre)}
%%%-------------------------------------------------------------------
%% @author Igor Kopestenski <i.kopest@gmail.com>
%% [https://github.com/Laymer/GrispLasp/]
%% @doc This is a <em>gen_server</em> template module.
%% @end
%%%-------------------------------------------------------------------
-module(gen_server_template).
-behaviour(gen_server).
%%%-------------------------------------------------------------------
%% @author Igor Kopestenski <i.kopest@gmail.com>
%% [https://github.com/Laymer/]
%% @doc This is a <em>supervisor</em> template module.
%% @end
%%%-------------------------------------------------------------------
-module(supervisor_skeleton).
-behaviour(supervisor).
@Laymer
Laymer / gist:af1e3bcf4dcc0e81cb456c2bb5d86091
Created November 20, 2018 13:08 — forked from toraritte/gist:2eddbbddddc4841d403c
net_kernel:connect/1 VS net_kernel:connect_node/1

=== CALL TRACE OF net_kernel:connect\1

% otp/lib/kernel/src/net_kernel.erl
connect(node_name@machine) -> do_connect(node_name@machine, normal, false). ->
  %          Node,              Type,   WaitForBarred
  do_connect(node_name@machine, normal, false           ) -> %% Type = normal | hidden
    case catch ets:lookup(sys_dist, Node) of
        % [{connection, ...}] if node is in sys_dist
        % []                  if not
	{'EXIT', _} ->