Skip to content

Instantly share code, notes, and snippets.

View vinoski's full-sized avatar

Steve Vinoski vinoski

View GitHub Profile
@vinoski
vinoski / riak-core-patch-for-17
Created December 1, 2014 04:26
unofficial riak_core changes for Erlang/OTP 17
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(),
@vinoski
vinoski / gist:1525210
Created December 27, 2011 21:26
yaws issue #75 client output
$ dd if=/dev/zero of=/tmp/bigfile bs=1m count=2048
2048+0 records in
2048+0 records out
2147483648 bytes transferred in 21.450200 secs (100114855 bytes/sec)
$ curl -v -F 'file=@/tmp/bigfile' http://localhost:8000/tmp/upload.yaws
* About to connect() to localhost port 8000 (#0)
* Trying ::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8000 (#0)
> POST /tmp/upload.yaws HTTP/1.1
@vinoski
vinoski / gist:1525225
Created December 27, 2011 21:31
yaws issue #75 server output
$ yaws -i
Erlang R14B04 (erts-5.8.5) [source] [smp:8:8] [rq:8] [async-threads:0] [kernel-poll:true]
Eshell V5.8.5 (abort with ^G)
1>
=INFO REPORT==== 27-Dec-2011::16:19:08 ===
Yaws: Using config file /usr/local/etc/yaws/yaws.conf
yaws:Add path "/usr/local/var/yaws/ebin"
yaws:Add path "/usr/local/lib/yaws/examples/ebin"
yaws:Running with id="default" (localinstall=false)
@vinoski
vinoski / ssl_accept_bug.erl
Created November 28, 2012 18:22
Erlang R15B03 SSL accept timeout bug example
-module(ssl_accept_bug).
-export([start/0]).
-define(PORT, 9999).
start() ->
ssl:start(),
%% You can get the Yaws cert and key files here:
%% https://github.com/klacke/yaws/blob/master/ssl/yaws-cert.pem
%% https://github.com/klacke/yaws/blob/master/ssl/yaws-key.pem
@vinoski
vinoski / pt_async.erl
Created December 11, 2012 20:37
parse transform to make exported functions call internal async versions
-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
@vinoski
vinoski / get_all_bindings.erl
Last active December 11, 2015 18:48
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_bi…
-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.
@vinoski
vinoski / get_all_bindings2.erl
Created January 27, 2013 14:35
Another version of the get_all_bindings parse transform (see https://gist.github.com/4643721), but using erl_syntax and erl_syntax_lib.
-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.
@vinoski
vinoski / gs.erl
Created April 6, 2016 19:00
example gen_server
-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() ->
@vinoski
vinoski / .bashrc-kerl
Last active September 13, 2016 12:52
Auto-generate bash functions for selecting kerl-installed Erlang versions. Functions are named based on the kerl-installed versions; for example, if you have R16B03 installed as r16b03, your shell will have a function named r16b03 for selecting that version. If you install a new version, run kerl_gen in your shell to regenerate the version selec…
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()