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(x). | |
-export([lxor/2]). | |
%%% see http://stackoverflow.com/a/40098595/409228 for context | |
lxor(L1,L2) when is_list(L1), is_list(L2) -> | |
%% convert the input lists to binaries, then call lxor/2 on the results | |
lxor(list2bin(L1),list2bin(L2)); | |
lxor(B1,B2) when is_binary(B1), is_binary(B2) -> | |
%% decode unsigned integers from the input binaries, then call lxor/2 |
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(gs). | |
-behaviour(gen_server). | |
-export([start/0, stop/0]). | |
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, | |
terminate/2, code_change/3]). | |
-record(state, {count}). | |
start() -> |
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
diff --git a/include/riak_core_handoff.hrl b/include/riak_core_handoff.hrl | |
index 9956205..e34c4c8 100644 | |
--- a/include/riak_core_handoff.hrl | |
+++ b/include/riak_core_handoff.hrl | |
@@ -30,7 +30,7 @@ | |
transport_mon :: reference(), | |
timestamp :: tuple(), | |
status :: any(), | |
- stats :: dict(), | |
+ stats :: dict:dict(), |
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
export MYKERLVSN='' | |
no_kerl() | |
{ | |
kerl_deactivate | |
unset _KERL_SAVED_AGNER_BIN _KERL_SAVED_AGNER_EXACT_PREFIX _KERL_SAVED_REBAR_PLT_DIR AGNER_BIN AGNER_EXACT_PREFIX | |
MYKERLVSN='' | |
} | |
kerl_gen() |
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
%% Simple web server. | |
-module(sws). | |
-author('Steve Vinoski <vinoski@ieee.org>'). | |
-export([start/1, start/2]). | |
%% start/1 takes a handler function and starts the web server on port 8000. | |
%% start/2 takes a handler function and a port number. The handler function | |
%% takes two arguments: a TCP socket and request data. The request data is | |
%% a property list indicating the invoked HTTP method, the target URI, the |
When you build Erlang/OTP on OS X, it unfortunately defaults to handling a maximum of 1024 file descriptors. You can get around this limitation with the right combination of configuration options and manual changes to a generated config file.
First, go into your unpacked Erlang/OTP source directory and run the following command, replacing the value 10000 with whatever value you want for max file descriptors:
perl -i -pe 's/(define\s+FD_SETSIZE\s+)\d+/\1 10000/' erts/config.h.in
Next, when you run configure
in your Erlang/OTP source directory, be sure to include the right CFLAGS
setting, as shown below:
CFLAGS='-DREDEFINE_FD_SETSIZE -DFD_SETSIZE=15000 -D_DARWIN_UNLIMITED_SELECT' ./configure --enable-kernel-poll <other options>
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(get_all_bindings2). | |
-export([parse_transform/2]). | |
-author('Steve Vinoski <vinoski@ieee.org>'). | |
%% This parse transform looks for a plain call to get_all_bindings/1 within | |
%% each function body within the module being processed and if found | |
%% replaces its argument with a list of {variable name, value} tuples, one | |
%% for each variable used in the function body up to the call point. The | |
%% module must contain its own suitable definition for the | |
%% get_all_bindings/1 function. |
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(get_all_bindings). | |
-export([parse_transform/2]). | |
-author('Steve Vinoski <vinoski@ieee.org>'). | |
%% This parse transform looks for a plain call to get_all_bindings/1 within | |
%% each function body within the module being processed and if found | |
%% replaces its argument with a list of {variable name, value} tuples, one | |
%% for each variable used in the function body up to the call point. The | |
%% module must contain its own suitable definition for the | |
%% get_all_bindings/1 function. |
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(pt_async). | |
-export([parse_transform/2]). | |
parse_transform(AST, _Options) -> | |
asyncify_funs(AST, []). | |
%% Search for functions whose bodies simply return the atom "async" (minus | |
%% the quotes of course). Replace that body with a call to the async | |
%% version of the called function, passing a ref as well. The async function | |
%% (assuming it succeeds) passes the result back as a message, which the |
NewerOlder