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 / kill-erlang-node.sh
Created Feb 8, 2014
Kill an Erlang process by node name
View kill-erlang-node.sh
#!/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-after-arrow.el
Created Nov 21, 2012
Improvement to the Erlang Mode for Emacs: Do not jump to a new line after -> when writing specs.
View erlang-after-arrow.el
(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
View atom_table.erl
-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 =/= <<>>],
@robertoaloi
robertoaloi / ekill
Created Nov 26, 2013
Kill an Erlang process by node name
View ekill
#!/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 Dec 28, 2015
Demo session used for "Introduction to Erlang" talks and courses.
View demo.md

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 Aug 27, 2013
Unescriptize Erlang files
View unescriptize
#!/bin/sh
tail -n +2 $1 > $1.tmp
unzip -d $1.unescriptized $1.tmp
rm $1.tmp
View this_is_fun.erl
-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, [])).
View debugging-notes
````
(<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 Dec 19, 2015
Potential issue with Erlang Common Test when ct:pal/X is called from a config callback module.
View R15B01 Output
$ 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 Dec 15, 2015
Count the number of lines of an Erlang application (excluding comments, type specs, empty lines).
View hardwork.sh
find . -type f \( -name *.erl -or -name *.hrl -or -name *.app.src \) -exec cat {} \; | sed '/^\s*$/d;/^\s*\%\%/d;/^\-spec*/d' | wc -l