Skip to content

Instantly share code, notes, and snippets.

View erszcz's full-sized avatar

Radek Szymczyszyn erszcz

View GitHub Profile
@erszcz
erszcz / node-name.sh
Last active October 1, 2018 10:00
Sequential Erlang node name based on EPMD entries
#!/usr/bin/env bash
# file: node-name.sh
set -eu
PREFIX=history
MAXNODES=100
DEFAULT=${PREFIX}_$(uuidgen | sed 's/-//g')
@erszcz
erszcz / ct_helper.erl
Last active May 7, 2018 13:38
Erlang Common Test helper defining test-local setup/teardown
-module(ct_helper).
-compile([export_all]).
%% @doc Like ct:get_config/1, but calls error/1 if Key is not found / undefined.
%% This guarantees to fail fast if required config options are missing from
%% the config file, saving trouble with `undefined` value propagation.
%% Use alongside with the CT `require` mechanism.
%% See s2s_SUITE for an example.
-spec get_config(atom()) -> any().
@erszcz
erszcz / agent.erl
Last active March 9, 2018 10:10
Remotely load code into an Erlang node
-module(agent).
-compile([export_all]).
test(CallerPid) ->
CallerPid ! {agent, node(), self()}.
@erszcz
erszcz / docker.fix-network
Created November 9, 2017 16:06
Fix Docker4Mac container routeability (steps needed every host VM restart)
#!/usr/bin/env bash
## Make Docker4Mac containers routable in a private network.
## This is mostly a copy-paste from the original solution.
## IT'S NOT A COMPLETE SOLUTION - this script only does the
## steps necessary every time Docker4Mac is restarted.
## Beforehand, you have to run the steps marked as ONCE yourself.
## See https://github.com/docker/for-mac/issues/155#issuecomment-320509769
set -e
@erszcz
erszcz / kerl-install-docsh.log
Created October 25, 2017 16:25
kerl install-docsh log
Last login: Wed Oct 25 18:19:04 on ttys005
e18:20:30 erszcz @ x4 : ~
$ erl
-bash: erl: command not found
18:20:30 erszcz @ x4 : ~
$ . ~/apps/erlang/19.3.6.2/activate
18:20:41 erszcz @ x4 : ~
$ erl
Erlang/OTP 19 [erts-8.3.5.2] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
@erszcz
erszcz / docs-chunk-design.md
Last active June 24, 2017 01:29
Docs chunk design

Docs chunk format proposal

Let's first look at some elixir_docs_v1 examples (Erlang syntax). The general chunk structure (from GenServer) is:

{elixir_docs_v1,
    [{docs,
         [{{'__using__',1},539,defmacro,[{'',[],'Elixir'}],false},
          {{abcast,3},
@erszcz
erszcz / cVimrc
Last active February 3, 2017 11:28
cVim config file
" d closes a tab
map d closeTab
" C-d/C-u scrolls down/up
map <C-d> scrollPageDown
map <C-u> scrollPageup
" M-§ / A-§ switch to previous active tab / last used tab
map <M-§> lastUsedTab
map <A-§> lastUsedTab
@erszcz
erszcz / graph_fsm.erl
Created March 15, 2016 16:34
Vance Shipley's graph_fsm - a tool for drawing Erlang gen_fsm diagrams (http://www1.erlang.org/pipermail/erlang-questions/2001-October/003716.html)
%% graph_fsm.erl
%%
%% Author: Vance Shipley, Motivity Telecom Inc. <vances@motivity.ca>
%% Date: November, 2000
%%
%%
%% This library is free software; you can redistribute it and/or
%% modify it under the terms of the GNU Lesser General Public
%% License as published by the Free Software Foundation; either
%% version 2 of the License, or (at your option) any later
@erszcz
erszcz / exml_assert.hrl
Last active March 11, 2016 09:53
XML element equality assertion ignoring attribute / subelement ordering (using https://github.com/esl/exml data structures)
%% See assertEqual in $ERLANG/lib/stdlib-2.6/include/assert.hrl for the original.
-define(exmlAssertEqual(Example, Expr),
begin
((fun (__X, __V) ->
case __V of
__X -> ok;
__V -> erlang:error({exmlAssertEqual,
[{module, ?MODULE},
{line, ?LINE},
{expression, (??Expr)},
@erszcz
erszcz / et_helper.erl
Created March 4, 2016 12:12
Erlang et (Event Tracer)
-module(et_helper).
-compile([export_all]).
-include_lib("et/include/et.hrl").
start() ->
start([]).
start(ExtraOptions) ->
Options = [{trace_global, true},