Skip to content

Instantly share code, notes, and snippets.

View ferd's full-sized avatar
☢️
This place is not a place of honor… no highly esteemed deed is commemorated here

Fred Hebert ferd

☢️
This place is not a place of honor… no highly esteemed deed is commemorated here
View GitHub Profile
<<Start:60, _Version:4, Mid:6, _Variant:2, End:56>> = crypto:rand_bytes(16),
<<Start:60, 4:4, Mid:6, 2:2, End:56>>.
@ferd
ferd / paths.erl
Created June 11, 2011 22:58
Demo PropEr suite for rabbitMQ paths
-module(paths).
-include_lib("proper/include/proper.hrl").
%% Just to see a bunch of results without gen_symbolics
%prop_test_output() ->
% numtests(2, ?FORALL(X, expanded_paths(),
% collect(fun print/1,
% X,
% true))).
%
diff group.erl ~/.kerl/builds/r14b04_64/otp_src_R14B04/lib/kernel/src/group.erl
35c35
< put(line_buffer, proplists:get_value(line_buffer, Options, history:load())),
---
> put(line_buffer, proplists:get_value(line_buffer, Options, [])),
647d646
< history:add(Line),
λ lfe → master* → ./lfe
{"init terminating in do_boot",{undef,[{lfe_boot,start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
λ lfe → master* → ./lfe -pa ebin
Erlang R15B (erts-5.9) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
LFE Shell V5.9 (abort with ^G)
> (defun (a x y) (+ x y))
9> gen_udp:open(8789, [binary, {active,true}]).
{ok,#Port<0.665>}
10> inet:i(udp).
Port Module Recv Sent Owner Local Address Foreign Address State Type
665 inet_udp 0 0 <0.49.0> *:8789 *:* BOUND DGRAM
ok
24> proper:quickcheck(dispcount_prop:prop_parallel_nocrash(), [{numtests, 5000}]).
.................................................................................................................................................................................................................!
Failed: After 210 test(s).
{[{init,{state,[],undefined}}],[[{set,{var,1},{call,dispcount,checkout,[{call,erlang,element,[2,{call,dispcount,dispatcher_info,[prop_dispatch]}]}]}}],[{set,{var,2},{call,dispcount,checkout,[{call,erlang,element,[2,{call,dispcount,dispatcher_info,[prop_dispatch]}]}]}},{set,{var,3},{call,dispcount,checkout,[{call,erlang,element,[2,{call,dispcount,dispatcher_info,[prop_dispatch]}]}]}}]]}
History: {{[{init,{state,[],undefined}}],
[[{set,{var,1},
{call,dispcount,checkout,
[{call,erlang,element,
[2,
{call,dispcount,dispatcher_info,
58> [timer:tc(dispcount,checkout,[Info]) || _ <- lists:seq(1,100)].
[{34,{ok,{<0.62.0>,#Ref<0.0.0.470>},#Ref<0.0.0.398>}},
{22,{ok,{<0.64.0>,#Ref<0.0.0.472>},#Ref<0.0.0.399>}},
{3,{error,busy}},
{26,{ok,{<0.59.0>,#Ref<0.0.0.474>},#Ref<0.0.0.328>}},
{21,{ok,{<0.61.0>,#Ref<0.0.0.476>},#Ref<0.0.0.458>}},
{20,{ok,{<0.63.0>,#Ref<0.0.0.478>},#Ref<0.0.0.402>}},
{38,{ok,{<0.57.0>,#Ref<0.0.0.480>},#Ref<0.0.0.326>}},
{20,{ok,{<0.66.0>,#Ref<0.0.0.482>},#Ref<0.0.0.457>}},
{3,{error,busy}},
@ferd
ferd / tend_gist_load.erl
Created July 7, 2012 22:52
Test Module for The Erl Next Door
-module(tend_gist_load).
-export([run/0]).
run() -> ':)'.
-module(lazy).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
%% A lazy list is build from cells containing the value of their current
%% computation and a function that will return the next one.
%% Once a lazy list is over, the atom 'done' is returned.
-define(lcell(Term, Fun), {Term, Fun}).
-type lcell() :: {term(), fun(() -> tuple() | 'done' )}
| 'done'.
#lang racket
(require racket/match)
(require racket/string)
(define (to-roman x)
(define (digit digits)
(match digits
[(list 1 x _ _) (list x)]
[(list 2 x _ _) (list x x)]
[(list 3 x _ _) (list x x x)]