This file contains hidden or 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
| From d98e6c32d44e00f954c3912b08c6ebf48d55729c Mon Sep 17 00:00:00 2001 | |
| From: Fred Hebert <mononcqc@ferd.ca> | |
| Date: Thu, 20 Dec 2012 08:41:33 -0500 | |
| Subject: [PATCH] Add search to Erlang shell's history | |
| Search mode can be entered by pressing ctrl-r. Enter terms and press | |
| ctrl-r again to search backwards, or ctrl-s to then search forward (if | |
| you terminal doesn't eat up that one). Press enter to execute the line, | |
| or use tab, arrow keys, or other control sequences (^D, ^K, etc.) to | |
| exit search mode while remaining on the last found line. |
This file contains hidden or 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
| %%% Run with 'escript app_deps.erl' | |
| %%% Change the path in filelib:wildcard/1 as required to capture all | |
| %%% your dependencies. | |
| %%% | |
| %%% Rectangular nodes will represent library apps (no processes involved) | |
| %%% and the circular nodes will represent regular apps. An arrow going from | |
| %%% 'A -> B' means 'A depends on B'. | |
| %%% | |
| %%% This script depends on graphviz being present on the system. | |
| -module(app_deps). |
This file contains hidden or 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
| %%% Macro definitions for lazy (or rather delayed) evaluation. | |
| %% Force and delay are used in combination to delay evaluation to only | |
| %% when strictly needed: | |
| %% Promise = ?delay(expensive_computation(A,B,C)), | |
| %% Value = ?force(Promise). | |
| %% | |
| %% These macros should be used with extreme precaution when sending a | |
| %% function to another process as it relies on closures and the sharing of | |
| %% information is lost when copying. So is memoization. Therefore, lazy |
This file contains hidden or 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
| F = fun() -> [{Pid, {Reds, Curr, Init}} || Pid <- processes(), | |
| {_, Reds} <- [process_info(Pid, reductions)], | |
| {_, Curr} <- [process_info(Pid, current_function)], | |
| {_, Init} <- [process_info(Pid, initial_call)]] end. | |
| Fetch = fun(T) -> A = F(), timer:sleep(T), B= F(), {A,B} end. | |
| Build = fun({A,B}) -> | |
| D = dict:from_list(A), | |
| lists:foldl(fun({Pid,{Red,Cur,Init}}, Dict) -> |
This file contains hidden or 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
| #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)] |
This file contains hidden or 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(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'. |
This file contains hidden or 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(tend_gist_load). | |
| -export([run/0]). | |
| run() -> ':)'. |
This file contains hidden or 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
| 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}}, |
This file contains hidden or 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
| 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, |
This file contains hidden or 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
| 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 |