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(rpn). | |
-export([eval/1, hypotenuse/2]). | |
-compile({parse_transform,do}). | |
-spec eval([Op]) -> stack_m(ok). | |
%% Interpreter for a simple stack-based language. | |
%% | |
%% Uses a custom stack_m monad, which is a trivial wrapper around state_m[1]. | |
%% It exports: | |
%% -spec pop() -> stack_m(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
%%% @file gen_bserver.erl | |
%%% | |
%%% Шаблон блокирующего сервера-таймера. | |
%%% Используется для долгих функций, которые | |
%%% не могут быть выполнены параллельно, | |
%%% но должны запускаться регулярно. | |
%%% События происходят по истечению | |
%%% GEN_BSERVER_TIMEOUT. | |
%%% timeout сервера и функцию обработки occupate | |
%%% можно менять в процессе выполнения. |
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
%%% @file smr.erl | |
%%% | |
%%% Еще одна простая обобщенная реализация параллельного, но не распределенного | |
%%% mapreduce. | |
%%% | |
%%% При вызове одной из функций mapreduce создается корневой поток. | |
%%% Внутри корневого потока создаются рабочие потоки по одному | |
%%% для каждого элемента данных. Элементы данных обрабатываются | |
%%% функцией отображения заданной в клиентском коде. | |
%%% Результаты обработки пересылается корневому потоку. |
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
{application, psqlcp, [ | |
{description, "Postgresql connection pool with poolboy"}, | |
{vsn, "0.1"}, | |
{applications, [kernel, stdlib]}, | |
{modules, [psqlcp, psqlcp_worker]}, | |
{registered, [psqlcp]}, | |
{mod, {psqlcp, []}}, | |
{env, [ | |
{pools, [ | |
{fk, [ |
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
-compile(export_all). | |
-module(pgConPool). | |
-behaviour(gen_server). | |
%% -------------------------------------------------------------------- | |
%% Include files | |
%% -------------------------------------------------------------------- | |
-include("../include/common.hrl"). |
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
%% | |
%% ... | |
%% | |
start(_StartType, _StartArgs) -> | |
%% until lager is completely started, allow all messages to go through | |
lager_mochiglobal:put(loglevel, {?DEBUG, []}), | |
{ok, Pid} = lager_sup:start_link(), | |
Handlers = case application:get_env(lager, handlers) of | |
undefined -> |
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
-ifndef(__SSQL_SSQL__). | |
-define(__SSQL_SSQL__, true). | |
-define(SVAR, "$"). | |
-define(SDOT, "."). | |
-define(SCOMMA, ","). | |
-define(SWC, " "). | |
-define(SLBR, "("). | |
-define(SRBR, ")"). |
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(handler_jsonapi_test). | |
-behaviour(cowboy_http_handler). | |
-export([init/3, handle/2, terminate/2]). | |
-define(AUTH_COOKIE_NAME, <<"auth_mceed0btegt1xa">>). | |
init(_, Req, _Opts) -> | |
{ok, Req, undefined}. | |
handle(Req, 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
%% | |
%% @file lgps.erl Генератор запоминающихся случайных | |
%% последовательностей символов, например, капчи или паролей | |
%% | |
-module(lgps). | |
-export([ | |
new/0, %% Создает последовательность символов по умолчанию. | |
new/1, %% Создает последовательность символов, по описанию (см ниже). |
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
%% Черная магия parse_transform http://bit.ly/recbird | |
%% | |
%% ---------------------------------------------------------------------------- | |
%% 1> main:main(). | |
%% record_info(fields, pers), = ['__dict__','__fields__',head,body,uid,id,func, | |
%% blog,name,'__extends__'] | |
%% Pers = {pers,[{head,<<"head">>}, | |
%% {body,<<"body">>}, | |
%% {uid,232323}, | |
%% {id,1}, |