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
@robertoaloi
robertoaloi / erlang-ssh-and-ssh-sftp-bugs-and-misleading-error-messages.md
Last active August 29, 2015 13:56
[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,
                                       [<0.53.0>,
                                        {{timeout,infinity},
 wait_for_version_negotiation},

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,

FROM centos:centos6
RUN yum update -y && yum install -y https://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm
[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'
@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 ->
@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 / README
Created July 27, 2012 13:20
Highlighting lines in code listings
Compiling it with:
latexmk -pdf main.tex
%% 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 / 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}'
@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