Skip to content

Instantly share code, notes, and snippets.

View kellymclaughlin's full-sized avatar
🏠
Working from home

Kelly McLaughlin kellymclaughlin

🏠
Working from home
View GitHub Profile
diff --git a/rebar.config b/rebar.config
index dc5bd68..b475012 100644
--- a/rebar.config
+++ b/rebar.config
@@ -4,6 +4,6 @@
{edoc_opts, [{preprocess, true}]}.
{deps, [
- {mochiweb, "1.5.1", {git, "git://github.com/basho/mochiweb",
- {tag, "1.5.1-riak-1.0.x-fixes"}}}
@kellymclaughlin
kellymclaughlin / httpraw.config
Created December 4, 2012 04:46
Webmachine benchmark results
{mode, max}.
{duration, 120}.
{concurrent, 30}.
{driver, basho_bench_driver_http_raw}.
{code_paths, ["deps/ibrowse"]}.
@kellymclaughlin
kellymclaughlin / gist:4043845
Created November 9, 2012 05:16
riakc PUT with 2I
Indexes = [{<<"index1_bin">>, <<"val">>},
{<<"index2_int">>, 1}],
Meta = dict:store(<<"index">>, Indexes, dict:new()),
Obj = riakc_obj:new(<<"mybucket">>, <<"mykey">>, <<"myval">>),
Obj1 = riakc_obj:update_metadata(Obj, Meta),
riakc_pb_socket:put(RiakPid, Obj1).
@kellymclaughlin
kellymclaughlin / node1-after.txt
Created November 3, 2012 22:07
Stuck Schedulers: Before and after changing online schedulers from 64 to 1 and back to 64
(riak@node1)1> schedstat:run().
<0.3422.460>
=== in scheduler count===
[{1,65},
{2,5},
{3,0},
{4,0},
{5,14},
{6,73},
{7,0},
@kellymclaughlin
kellymclaughlin / gist:3834437
Created October 4, 2012 15:32
Change # of schedulers online
%% Get current number of online schedulers
Schedulers = erlang:system_info(schedulers_online).
%% Reduce number online to 1
erlang:system_flag(schedulers_online, 1).
%% Restore to original number of online schedulers
erlang:system_flag(schedulers_online, Schedulers).
@kellymclaughlin
kellymclaughlin / pb_status_anon.txt
Created September 28, 2012 21:18
How to get poolboy status for each Riak Vnode
PBStatusFun = fun() ->
VnodePids = [Pid || {_, Pid} <- riak_core_vnode_manager:all_index_pid(riak_kv_vnode)],
Links = [process_info(Pid, [links]) || Pid <- VnodePids],
WorkerPoolPids = [WPPid || [{links,[_, WPPid]}] <- Links],
WorkerPoolLinks = [process_info(Pid, [links]) || Pid <- WorkerPoolPids],
PoolboyPids = [PoolboyPid || [{links,[_, PoolboyPid]}] <- WorkerPoolLinks],
[poolboy:status(Pid) || Pid <- PoolboyPids]
end.
PBStatusFun = fun(Index) ->

Setting up the Emacs daemon on OS X

Warning: I only use terminal emacs so I have no idea how well this will work otherwise.

Install emacs 23 or later.

Here's what I use to get the very latest emacs goodies:

sudo brew install emacs --cocoa --use-git-head --HEAD
@kellymclaughlin
kellymclaughlin / luwak_file_iterate.erl
Created November 29, 2011 16:50
Luwak inspection
Fun = fun(C, File) ->
{ok, TLObj} = C:get(<<"luwak_tld">>, File, 2),
{_, TLVal} = hd(riak_object:get_contents(TLObj)),
FileRoot = proplists:get_value(root, TLVal),
{ok, RootObj} = C:get(<<"luwak_node">>, FileRoot),
{_, RootVal} = hd(riak_object:get_contents(RootObj)),
{_, _, ChunkKeys} = RootVal,
[begin
case C:get(<<"luwak_node">>, K) of
{ok, _} ->
@kellymclaughlin
kellymclaughlin / gist:1304771
Created October 21, 2011 19:50
Erlang R15 line numbers
13:49:27:~ $ erl
Erlang R15A (erts-5.9) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
1> test:bad().
** exception error: bad argument
in function test:bad/0 (test.erl, line 44)
2>
-ifdef(TEST).
test_test() ->
%% Start erlang node
application:start(sasl),
TestNode = list_to_atom("testnode" ++ integer_to_list(element(3, now())) ++
"@localhost"),
net_kernel:start([TestNode, longnames]),
application:start(riakc),
application:start(inets),
application:start(mochiweb),