Skip to content

Instantly share code, notes, and snippets.

View nox's full-sized avatar
🥖

Anthony Ramine nox

🥖
View GitHub Profile
@nox
nox / test.erl-sh
Created February 26, 2011 15:23
Let's try pygments' Erlang erl sessions highlighting
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.3 (abort with ^G)
1> 1 + 1.
2
2> erlang:module_info().
[{exports,[{apply,2},
{spawn,2},
{spawn_link,2},
{spawn_monitor,3},
nox@Bellcross:~$ echo "-module('a.b')." >a.b.erl
nox@Bellcross:~$ erl
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.3 (abort with ^G)
1> c(a.b).
a.b.beam: Module name 'a.b' does not match file name 'a.b'
error
2> c('a.b').
a.b.beam: Module name 'a.b' does not match file name 'a.b'
$ ping google.fr
PING google.fr (209.85.147.105): 56 data bytes
64 bytes from 209.85.147.105: icmp_seq=0 ttl=56 time=99.862 ms
64 bytes from 209.85.147.105: icmp_seq=1 ttl=56 time=660.244 ms
Request timeout for icmp_seq 2
64 bytes from 209.85.147.105: icmp_seq=2 ttl=56 time=1335.677 ms
64 bytes from 209.85.147.105: icmp_seq=3 ttl=56 time=1053.693 ms
64 bytes from 209.85.147.105: icmp_seq=4 ttl=56 time=832.985 ms
64 bytes from 209.85.147.105: icmp_seq=5 ttl=56 time=1610.173 ms
64 bytes from 209.85.147.105: icmp_seq=6 ttl=56 time=1273.634 ms
nox@Bellcross:~/src/otp[code-expr]$ git diff
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index bb4b18c..f487e82 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -37,6 +37,7 @@ record_expr record_tuple record_field record_fields
if_expr if_clause if_clauses case_expr cr_clause cr_clauses receive_expr
fun_expr fun_clause fun_clauses
try_expr try_catch try_clause try_clauses query_expr
+code_expr
authenticate(Socket, ClientCaps, User, Password, Database,
#ex_mysql_init{packet_number = PacketNumber,
server_capabilities = ServerCapabilities,
scramble = Message}) ->
ClientCapsInt = ex_mysql_util:capabilities_to_integer(ClientCaps),
Secure = lists:member(secure_connection, ServerCapabilities),
ConnectWithDb = lists:member(connect_with_db, ServerCapabilities) andalso
Database =/= <<>>,
CharsetNr = ex_mysql_charset:collation_id(utf8),
Scramble = case Secure of
%% ...
expr({code, Line, Es}) ->
expr(stage_exprs(Es));
expr({escape, _Line, _E} = Esc) ->
Esc.
%% ...
stage_expr({code, Line, E}) ->
stage_expr(expr(E));
stage_expr((escape, _Line, E}) ->
nox@Bellcross:~/src/otp[code-expr=]$ bin/erl
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.3 (abort with ^G)
1> Pow = fun (_F, 0, _X) -> <| 1 |>; (F, N, X) -> <| `X * `(F(F, N - 1, X)) |> end.
#Fun<erl_eval.18.105910772>
2> Pow3 = <| fun (X) -> `(Pow(Pow, 3, <| X |>)) end |>.
{'fun',1,
{clauses,[{clause,1,
[{var,1,'X'}],
%%% @type context().
-module(ex_mysql_rnd).
-export([new/2,
next/1, next/2]).
%% @spec new(integer(), integer()) -> context()
%% @doc Return a new pseudo-random number generator context.
new(Seed1, Seed2) ->
-module(ex_mime).
-type media_type() :: {mime_type(), parameters()}.
-type mime_type() :: {Type::binary(), Subtype::binary()}.
-type parameters() :: [{Argument::binary(), Value::binary()}].
-type disposition() :: {binary(), parameters()}.
-export_type([media_type/0, mime_type/0, parameters/0]).
-module(ex_formdata).
-type data() :: {Name::binary(), [ex_mime:parameter()],
[ex_multipart:http_header()], Body::binary()}.
-type cont(T) :: fun((folding_result(T), T) -> T).
-type folding_result(T) :: {data, data(), fun((T) -> T)}
| {more, fun((binary()) -> T)}
| {prologue, binary()}.
-export_type([data/0, cont/1, folding_result/1]).