This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module(test). | |
-export([get_data/1]). | |
get_data([T|Rest]) -> | |
case T of | |
test -> | |
do_error([T|Rest]); | |
_Else -> | |
do_error([]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Initial assembly | |
lbl_sum0: i_func_info_IaaI 0 sum sum 2 | |
i_is_eq_exact_immed_frc f(lbl_sum1) x(0) 0 | |
move_return_xr x(1) x(0) | |
lbl_sum1: is_tuple_of_arity_fxA f(lbl_sum0) x(1) 2 | |
extract_next_element2_x x(2) | |
i_is_eq_exact_immed_fxc f(lbl_sum0) x(2) s | |
i_fetch_rc x(0) 1 | |
i_minus_jId j(0000000000000000) 4 x(1) | |
i_fetch_xr x(3) x(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmap(F,List) -> | |
nmap(F,erlang:fun_info(F,arity),List). | |
nmap(F,Ar,List) -> | |
{Hd,Tl} = lists:split(Ar,List), | |
[apply(F,Hd)|nmap(Tl)]; | |
nmap(_F,_,[]) -> | |
[]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keyfind(Key,Value,[H|T]) -> | |
case maps:find(Key,H) of | |
{ok, Value} -> | |
H; | |
_ -> | |
keyfind(Key,Value,T) | |
end; | |
keyfind(_,_,[]) -> | |
false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> infocmp xterm | |
# Reconstructed via infocmp from file: /lib/terminfo/x/xterm | |
xterm|xterm-debian|X11 terminal emulator, | |
am, bce, km, mc5i, mir, msgr, npc, xenl, | |
colors#8, cols#80, it#8, lines#24, pairs#64, | |
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, | |
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, | |
clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, | |
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, | |
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Introducing the new `apply` pattern match operand. | |
%% `apply` is used to delegate the handling of a match | |
%% to some other function including the action to be taken | |
%% when a successful match happens. The `apply` statement | |
%% replaces the "-> body" part of a function/case/receive. | |
%% | |
%% Simple example: | |
%% example() -> | |
%% Pat = fun(A) when is_atom(A) -> | |
%% {ok, A} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
%% -*- erlang -*- | |
%%! -smp enable -sname wtf | |
main(_) -> | |
process_flag(trap_exit, true), | |
ToMap = lists:seq(1, 50), | |
MapFun = fun() -> | |
lists:map(fun(N) -> N end, ToMap) | |
end, | |
start_runner(MapFun), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(decode). | |
-export([term/1]). | |
term(<<131,Rest/binary>>) -> | |
element(1,term(Rest)); | |
%% List | |
term(<<108,Sz:32,Rest/binary>>) -> | |
{Lst, R} = lists:foldl( | |
fun(_, {Acc, B}) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(gen_tcp2). | |
-export([listen/2, accept/1, accept/2, | |
connect/3, connect/4, | |
send/2, recv/1, recv/2, recv/3, | |
close/1]). | |
-export([run/0, run/2]). | |
%% Naive gen_tcp shim over the socket API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git clone https://github.com/openssl/openssl | |
cd openssl | |
git checkout OpenSSL_1_1_1b | |
./Configure shared --prefix=$HOME/apps/openssl/1.1.1b --openssldir=$HOME/apps/openssl/1.1.1b linux-x86_64 | |
make | |
make install | |
cd .. |
OlderNewer