Skip to content

Instantly share code, notes, and snippets.

View elbrujohalcon's full-sized avatar
🇪🇸
Working from Catalunya

Brujo Benavides elbrujohalcon

🇪🇸
Working from Catalunya
View GitHub Profile
@elbrujohalcon
elbrujohalcon / what.erl
Created March 5, 2015 19:27
What's going on here?
Bad = [67,108,111,110,105,110,103,32,105,110,116,111,32,39,47,112,114,105,118,97,116,101,47,116,109,112,47,103,97,100,103,101,116,47,103,97,100,103,101,116,45,116,101,115,116,47,111,114,103,45,114,101,112,111,47,48,48,48,49,52,50,53,45,48,53,56,51,51,51,56,45,48,52,48,48,55,49,53,47,100,101,112,115,47,101,112,101,114,39,46,46,46,10,67,108,111,110,105,110,103,32,105,110,116,111,32,39,47,112,114,105,118,97,116,101,47,116,109,112,47,103,97,100,103,101,116,47,103,97,100,103,101,116,45,116,101,115,116,47,111,114,103,45,114,101,112,111,47,48,48,48,49,52,50,53,45,48,53,56,51,51,51,56,45,48,52,48,48,55,49,53,47,100,101,112,115,47,115,121,110,99,39,46,46,46,10,67,108,111,110,105,110,103,32,105,110,116,111,32,39,47,112,114,105,118,97,116,101,47,116,109,112,47,103,97,100,103,101,116,47,103,97,100,103,101,116,45,116,101,115,116,47,111,114,103,45,114,101,112,111,47,48,48,48,49,52,50,53,45,48,53,56,51,51,51,56,45,48,52,48,48,55,49,53,47,100,101,112,115,47,107,97,116,97,110,97,39,46,46,46,10,67,108,111,110,105,110,103,32,10

Keybase proof

I hereby claim:

  • I am elbrujohalcon on github.
  • I am elbrujohalcon (https://keybase.io/elbrujohalcon) on keybase.
  • I have a public key whose fingerprint is CD9E 3C5B 5E58 3B30 5B30 6345 0550 3C28 3EA2 012F

To claim this, I am signing this object:

@elbrujohalcon
elbrujohalcon / pattern-match-funs.erl
Created October 2, 2015 17:57
One does not simply pattern match funs
3> Fun = fun() -> ok end,
3> Fun = fun() -> ok end.
** exception error: no match of right hand side value #Fun<erl_eval.20.54118792>
4> Fun = fun() -> ok end.
#Fun<erl_eval.20.54118792>
5> Fun = fun() -> ok end.
#Fun<erl_eval.20.54118792>
@elbrujohalcon
elbrujohalcon / dumb_math.erl
Last active May 18, 2016 15:40
For my post on Medium
-module(dumb_math).
-export([dup/1, init/1]).
dup(X) ->
{ok, Pid} = gen_server:start_link(dumb_math, X, []),
sys:get_state(Pid).
init(X) -> {ok, X * 2}.
@elbrujohalcon
elbrujohalcon / dumb_math.erl
Created May 18, 2016 16:07
For my post @ Medium
-module(dumb_math).
-export([dup/1, init/1]).
dup(X) ->
case gen_server:start_link(dumb_math, X, []) of
{ok, Pid} -> sys:get_state(Pid);
{error, Reason} -> Reason
end.
init(X) when is_number(X) -> {ok, X * 2};
@elbrujohalcon
elbrujohalcon / hello.erl
Created June 10, 2016 16:41
Convoluted Hello World for my blog post
-module(hello).
-export([world/0]).
world() ->
F = fun() -> "Hello, world!" end,
F = fun() -> "Hello, world!" end,
io:format("~s~n", [F()]).
@elbrujohalcon
elbrujohalcon / hello.erl
Created June 10, 2016 16:55
Hello module with exported fun
-module(hello).
-export([world/0, f/0]).
world() ->
F = f(),
F = f(),
io:format("~s~n", [F()]).
f() -> fun() -> "Hello, world!" end.
@elbrujohalcon
elbrujohalcon / hello.erl
Created June 10, 2016 17:55
Compiler-crashing Hello World
-module(hello).
-export([world/0, f/0, '-f/0-fun-0-'/0]).
world() ->
F = f(),
F = f(),
io:format("~s~n", [F()]).
f() -> fun() -> "Hello, world!" end.
@elbrujohalcon
elbrujohalcon / people.erl
Created June 21, 2016 03:26
people module for my blog post
-module(people).
-export([count/2]).
-export([test/0]).
-type user() :: binary().
-type country() :: atom().
-type group() :: #{ country => country()
, members => [user()]
}.
@elbrujohalcon
elbrujohalcon / bad_people.erl
Created June 21, 2016 03:36
people:count/2 for my blog post
-spec count(country(), [group()]) -> non_neg_integer().
count(Country, Groups) ->
lists:sum(
lists:map(
fun (#{country := Country, members := Members}) ->
length(Members);
(_) ->
0
end, Groups)).