Skip to content

Instantly share code, notes, and snippets.

Fighting software entropy

Roberto Aloi robertoaloi

Fighting software entropy
View GitHub Profile
robertoaloi /
Created Dec 12, 2012
Find the application for your favourite Erlang module
ROOTDIR=`which erl | sed -ne '/^ROOTDIR=/s///p'`
find $ROOTDIR -name $1.erl | awk -F / '{print $(NF-2)}' | awk -F - '{print $1}'
View gist:4130202
%% 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],
-spec rec_copy(list(), list(), list()) -> ok.
rec_copy(_From, _To, [$. | _T]) -> %% Ignore Hidden
robertoaloi / README
Created Jul 27, 2012
Highlighting lines in code listings
Compiling it with:
latexmk -pdf main.tex
robertoaloi /
Created Aug 31, 2011
Weird behaviour when calling Erlang from a Makefile on Mac
CMD="erl -noinput -eval 'erlang:display({foo, bar}).' -s init stop"
echo "Exec: $CMD"
exec $CMD
robertoaloi / rebar_compiledeps_plugin.erl
Created Aug 15, 2011
Rebar plugin to compile dependencies
View rebar_compiledeps_plugin.erl
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 ->
View gist:991452
[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'
View Dockerfile
FROM centos:centos6
RUN yum update -y && yum install -y


Example of OTP deadlock via the application controller.

In OTP, the application environment is handled via a ETS table, which is accessed via the application_controller process. Whilst reading an environment variable is implemented as a mere lookup operation, writes are serialized through the application controller. In other words, it is not possible to set an environment variable from a terminate/1 callback in a gen_server which traps exits,

robertoaloi /
Last active Aug 29, 2015
[Erlang] - ssh and ssh_sftp bugs and misleading messages

Misleading error message on ssh_sftp:start_channel/1 in case user does not have a shell

When starting a SFTP channel towards a system where user does not have a shell (i.e. it has /bin/false or equilvalent assigned in the /etc/passwd a misleading error message is returned to the user:

1> test:go(). 
** exception exit: {normal,{gen_server,call,