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
% Copyright (c) 2010-2014, Lars Buitinck | |
% May be used, redistributed and modified under the terms of the | |
% GNU Lesser General Public License (LGPL), version 2.1 or later | |
% Heaps/priority queues in Erlang | |
% Heaps are data structures that return the entries inserted into them in | |
% sorted order. This makes them the data structure of choice for implementing | |
% priority queues, a central element of algorithms such as best-first/A* | |
% search and Kruskal's minimum-spanning-tree algorithm. |
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
GetInfoAndStatusByModule = fun (Module) -> | |
IsProcessInModule = fun (Module, ProcessInfo) -> | |
case proc_lib:translate_initial_call(ProcessInfo) of | |
{ICMod, _ICFun, _ICArity} when Module =:= ICMod -> true; | |
_ -> false | |
end | |
end, | |
ProcessTable = erlang:processes(), | |
CurriedPredicate = fun (P) -> IsProcessInModule(Module, P) end, | |
Pids = lists:filter(CurriedPredicate, ProcessTable), |
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(future). | |
-export([async/1, fulfill/2, block/1, test/0]). | |
async(Fun) -> | |
F = mk(), | |
spawn(fun() -> | |
fulfill(F, Fun()) end), | |
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
f(C), | |
C = fun(Id, C2) -> {Id, [case S of | |
{CId, _, worker, _} -> CId; | |
{CId, _, supervisor, _} -> C2(CId, C2) | |
end || S <- supervisor:which_children(Id)]} end. | |
C(riak_core_sup,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
12> F = fun(P, {current_function, {Mod, _, _}}) -> {P, Mod} end, | |
12> C = fun(Mod, Prefixes) -> lists:sum([string:str(Mod, Prefix) || Prefix <- Prefixes]) > 0 end, | |
12> Target = fun(Prefixes) -> Candidates = [F(P, erlang:process_info(P, current_function)) || P <- erlang:processes()], | |
12> [{Pid, Mod} || {Pid, Mod} <- Candidates, | |
12> C(atom_to_list(Mod), Prefixes)] end. | |
#Fun<erl_eval.6.82930912> | |
13> Target(["erl"]). | |
[{<0.3.0>,erl_prim_loader},{<0.33.0>,erl_eval}] | |
14> |
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
(function() { | |
/* == GLOBAL DECLERATIONS == */ | |
TouchMouseEvent = { | |
DOWN: "touchmousedown", | |
UP: "touchmouseup", | |
MOVE: "touchmousemove" | |
} | |
/* == EVENT LISTENERS == */ |
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(keep_state). | |
-author('[email protected]'). | |
-export([test/0]). | |
test() -> | |
keep_state_sup:start_link(), | |
{} = keep_state_server:get_state(), | |
keep_state_server:put_state(foo), | |
foo = keep_state_server:get_state(), |
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
%% Copyright (c) 2008 Nick Gerakines <[email protected]> | |
%% | |
%% Permission is hereby granted, free of charge, to any person | |
%% obtaining a copy of this software and associated documentation | |
%% files (the "Software"), to deal in the Software without | |
%% restriction, including without limitation the rights to use, | |
%% copy, modify, merge, publish, distribute, sublicense, and/or sell | |
%% copies of the Software, and to permit persons to whom the | |
%% Software is furnished to do so, subject to the following | |
%% conditions: |