Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Fighting software entropy

Roberto Aloi robertoaloi

:octocat:
Fighting software entropy
View GitHub Profile
@robertoaloi
robertoaloi / efind.sh
Created Dec 12, 2012
Find the application for your favourite Erlang module
View efind.sh
#!/bin/sh
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],
ok.
-spec rec_copy(list(), list(), list()) -> ok.
rec_copy(_From, _To, [$. | _T]) -> %% Ignore Hidden
ok;
@robertoaloi
robertoaloi / README
Created Jul 27, 2012
Highlighting lines in code listings
View README
Compiling it with:
latexmk -pdf main.tex
@robertoaloi
robertoaloi / display.sh
Created Aug 31, 2011
Weird behaviour when calling Erlang from a Makefile on Mac
View display.sh
#!/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 Aug 15, 2011
Rebar plugin to compile dependencies
View rebar_compiledeps_plugin.erl
-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 ->
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 https://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm
View README.md

README

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
robertoaloi / erlang-ssh-and-ssh-sftp-bugs-and-misleading-error-messages.md
Last active Aug 29, 2015
[Erlang] - ssh and ssh_sftp bugs and misleading messages
View erlang-ssh-and-ssh-sftp-bugs-and-misleading-error-messages.md

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,
                                       [<0.53.0>,
                                        {{timeout,infinity},
                                         wait_for_version_negotiation},