Skip to content

Instantly share code, notes, and snippets.

View robertoaloi's full-sized avatar
:octocat:
Erlang Developer Experience @ WhatsApp

Roberto Aloi robertoaloi

:octocat:
Erlang Developer Experience @ WhatsApp
View GitHub Profile
````
(<0.80.0>) call ct_logs:tc_print(info,50,"...")
(<0.80.0>) call ct_util:get_testdata({verbosity,info})
(<0.80.0>) call ct_util:call({get_testdata,{verbosity,info}})
(<0.80.0>) call ct_util:call({get_testdata,{verbosity,info}},infinity)
(<0.80.0>) call erlang:whereis(ct_util_server)
HANGS
````
@robertoaloi
robertoaloi / R15B01 Output
Last active December 19, 2015 02:38
Potential issue with Erlang Common Test when ct:pal/X is called from a config callback module.
$ erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> test:do().
Common Test starting (cwd is /.../ct-bug)
----------------------------------------------------
2013-06-28 13:43:17.525
@robertoaloi
robertoaloi / hardwork.sh
Last active December 15, 2015 05:29
Count the number of lines of an Erlang application (excluding comments, type specs, empty lines).
find . -type f \( -name *.erl -or -name *.hrl -or -name *.app.src \) -exec cat {} \; | sed '/^\s*$/d;/^\s*\%\%/d;/^\-spec*/d' | wc -l
@robertoaloi
robertoaloi / efind.sh
Created December 12, 2012 14:51
Find the application for your favourite Erlang module
#!/bin/sh
ROOTDIR=`which erl | sed -ne '/^ROOTDIR=/s///p'`
find $ROOTDIR -name $1.erl | awk -F / '{print $(NF-2)}' | awk -F - '{print $1}'
%% Recursively copy directories
-spec recursive_copy(list(), list()) -> ok.
recursive_copy(From, To) ->
{ok, Files} = file:list_dir(From),
[ok = rec_copy(From, To, X) || X <- Files],
ok.
-spec rec_copy(list(), list(), list()) -> ok.
rec_copy(_From, _To, [$. | _T]) -> %% Ignore Hidden
ok;
@robertoaloi
robertoaloi / erlang-after-arrow.el
Created November 21, 2012 12:17
Improvement to the Erlang Mode for Emacs: Do not jump to a new line after -> when writing specs.
(defun erlang-after-arrow ()
"Return true if point is immediately after a function arrow (`->').
Make a special case when in a spec line."
(and
(save-excursion
(beginning-of-line)
(not (save-match-data (looking-at "-\\(spec\\|type\\)"))))
(and (>= (point) 2)
(and
(save-excursion
@robertoaloi
robertoaloi / README
Created July 27, 2012 13:20
Highlighting lines in code listings
Compiling it with:
latexmk -pdf main.tex
@robertoaloi
robertoaloi / display.sh
Created August 31, 2011 17:36
Weird behaviour when calling Erlang from a Makefile on Mac
#!/bin/sh
CMD="erl -noinput -eval 'erlang:display({foo, bar}).' -s init stop"
echo "Exec: $CMD"
exec $CMD
@robertoaloi
robertoaloi / rebar_compiledeps_plugin.erl
Created August 15, 2011 09:55
Rebar plugin to compile dependencies
-module(rebar_compiledeps_plugin).
-export([pre_compile/2]).
pre_compile(_, _) ->
Cwd = rebar_utils:get_cwd(),
case lists:suffix("my_dep", Cwd) of
true ->
Opts = [{cd, Cwd}],
case filelib:is_regular(filename:join([Cwd, "Makefile"])) of
true ->
[Wed, 25 May 2011 08:54:58 -0700] INFO: Starting Chef Run (Version 0.9.12)
: stdout
[default] /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/rest/auth_credentials.rb:62:in `load_signing_key': stderr
[default] : : stderr
[default] I cannot read /etc/chef/client.pem, which you told me to use to sign requests!: stderr
[default] (: stderr
[default] Chef::Exceptions::PrivateKeyMissing: stderr
[default] )
: stderr
[default] from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/rest/auth_credentials.rb:33:in `initialize'