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 / gist:af97c28569ef10049cb98aa76a93616d
Created January 25, 2024 16:40
`rebar3 manifest` for Erlang LS
#{deps =>
[#{name => <<"getopt">>,
src_dirs => ["src"],
out_mappings =>
[#{path =>
"/Users/robertoaloi/git/github/erlang-ls/erlang_ls/_build/default/lib/getopt/ebin",
extension => ".beam"}],
include_dirs =>
["/Users/robertoaloi/git/github/erlang-ls/erlang_ls/_build/default/lib/getopt/include",
"/Users/robertoaloi/git/github/erlang-ls/erlang_ls/_build/default/lib/getopt/src",
-module(atom_table).
-export([count/0]).
count() ->
Info = erlang:system_info(info),
Chunks = binary:split(Info, <<"=">>, [global]),
[TabInfo] = [X || <<"index_table:atom_tab", X/binary>> <- Chunks],
Lines = binary:split(TabInfo, <<"\n">>, [global]),
Chunks2 = [binary:split(L, <<": ">>) || L <- Lines, L =/= <<>>],
FROM centos:centos6
RUN yum update -y && yum install -y https://www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm

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 / kill-erlang-node.sh
Created February 8, 2014 13:55
Kill an Erlang process by node name
#!/usr/bin/env bash
# Kill an Erlang process by node name
#
# e.g.: kill-erlang-node kred
# Check usage
if [ -z "$1" ]; then
echo "Usage: `basename $0` NODE_NAME"
exit 1
@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},
@robertoaloi
robertoaloi / ekill
Created November 26, 2013 11:59
Kill an Erlang process by node name
#!/bin/sh
# Kill an Erlang process by node name
#
# e.g.: ekill my_node
# Check usage
if [ -z "$1" ]; then
echo "Usage: `basename $0` NODE_NAME"
exit 1
@robertoaloi
robertoaloi / demo.md
Last active December 28, 2015 21:09
Demo session used for "Introduction to Erlang" talks and courses.

Start an instance of the Erlang run-time system

$ erl

Show information about processes

> i().

Spawn a new process which sleeps for 10 seconds

@robertoaloi
robertoaloi / unescriptize
Created August 27, 2013 11:02
Unescriptize Erlang files
#!/bin/sh
tail -n +2 $1 > $1.tmp
unzip -d $1.unescriptized $1.tmp
rm $1.tmp
-module(this_is_fun).
-export([have_fun/0]).
-export([loop/0]).
have_fun() ->
table = ets:new(table, [named_table]),
F = fun(X) -> X + 1 end,
ets:insert(table, {function, F}),
register(funny, spawn(?MODULE, loop, [])).