Skip to content

Instantly share code, notes, and snippets.

View arekinath's full-sized avatar

Alex Wilson arekinath

View GitHub Profile
@arekinath
arekinath / keybase.md
Created December 3, 2015 18:28
keybase.md

Keybase proof

I hereby claim:

  • I am arekinath on github.
  • I am arekinath (https://keybase.io/arekinath) on keybase.
  • I have a public key ASAubR_gdy_KMD7AeX0QIRU0b19hpI0XE_fn5W053dLq7Qo

To claim this, I am signing this object:

diff --git a/c_src/nif.c b/c_src/nif.c
index 7ec1fca..93f111e 100644
--- a/c_src/nif.c
+++ b/c_src/nif.c
@@ -96,10 +96,12 @@ struct cache_queue {
ErlNifUInt64 size; /* sum of node->size for all nodes in the queue */
};
-#define FL_DYING 1
+#define FL_DYING 1
-module(ip_tools).
-export([next/1, first/2, last/2, from_str/1, to_str/1, range/2]).
next({A,B,C,D}) when D < 255 -> {A,B,C,D+1};
next({A,B,C,_D}) when C < 255 -> {A,B,C+1,0};
next({A,B,_C,_D}) when B < 255 -> {A,B+1,0,0};
next({A,_B,_C,_D}) when A < 255 -> {A+1,0,0,0}.
first(Tuple, Bits) when is_tuple(Tuple) ->
# mdb -kw
> 0x0::zid2zone | ::walk zsd z | ::print 'struct zsd_entry' zsd_create | ::grep .==evch_zoneinit | ::eval "<z::print 'struct zsd_entry' zsd_data | ::print 'struct evch_globals'"
{
evch_list = {
dh_head = {
dl_next = 0xffffff21d16b0f10
dl_prev = 0xffffff21ff76a320
}
dh_count = 0x7
# cat zdop.d
pid$target::zdoor_open:entry
{
printf("zdoor_open(%s, %s)\n",
copyinstr(arg1), copyinstr(arg2));
}
# dtrace -p $(pgrep beam.smp) -s zdop.d
dtrace: script 'zdop.d' matched 1 probe
CPU ID FUNCTION:NAME
6 73992 zdoor_open:entry zdoor_open(gs516-2743-builder, _joyent_sshd_key_is_authorized)
#!/usr/bin/env escript
%%! -smp enable -pa ebin/ +S 1
do_door() ->
receive
{zdoor, Req, Bin} ->
Line = binary:part(Bin, {0, byte_size(Bin)-1}),
Info = zdoor:req_info(Req),
io:format("line = ~p\ndoor = ~p\n", [Line, Info]),
ok = zdoor:reply(Req, <<"0\n">>),
@arekinath
arekinath / wiggle.patch
Created October 16, 2013 23:52
potential sec-websocket-protocol fix
diff --git a/apps/wiggle/src/wiggle_wsproxy.erl b/apps/wiggle/src/wiggle_wsproxy.erl
index 86da16d..0049aad 100644
--- a/apps/wiggle/src/wiggle_wsproxy.erl
+++ b/apps/wiggle/src/wiggle_wsproxy.erl
@@ -24,13 +24,24 @@ terminate(_Req, _State) ->
ok.
websocket_init(_Any, Req, []) ->
+ Req1 = case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req) of
+ {undefined, _, ReqR} -> ReqR;
@arekinath
arekinath / chunter.diff
Created October 9, 2013 04:41
internal_metadata for *_pw things
diff --git a/apps/chunter/src/chunter_spec.erl b/apps/chunter/src/chunter_spec.erl
index f0463fa..2d243d1 100644
--- a/apps/chunter/src/chunter_spec.erl
+++ b/apps/chunter/src/chunter_spec.erl
@@ -52,7 +52,15 @@ generate_sniffle(In, _Type) ->
<<"hostname">>, <<"autoboot">>, <<"created_at">>, <<"dns_domain">>,
<<"resolvers">>, <<"ram">>, <<"uuid">>, <<"cpu_shares">>],
jsxd:fold(fun (<<"internal_metadata">>, Int, Obj) ->
- jsxd:merge(Int, Obj);
+ jsxd:fold(fun(K = <<"package">>, V1, Obj1) ->
diff --git a/src/riak_cs_get_fsm.erl b/src/riak_cs_get_fsm.erl
index 0b953c8..63c84c7 100644
--- a/src/riak_cs_get_fsm.erl
+++ b/src/riak_cs_get_fsm.erl
@@ -239,7 +239,7 @@ waiting_chunks(get_next_chunk, From, State) ->
GotSize = orddict:size(Got),
MaxGotSize = riak_cs_lfs_utils:get_fsm_buffer_size_factor(),
if GotSize < MaxGotSize ->
- {next_state, waiting_chunks, UpdState, 0};
+ {next_state, waiting_chunks, read_blocks(UpdState)};
@arekinath
arekinath / randomhyp.patch
Last active December 16, 2015 10:19
Choose a random hypervisor for sniffle
diff --git a/apps/sniffle/src/sniffle_create_fsm.erl b/apps/sniffle/src/sniffle_create_fsm.erl
index f72ce59..2e94fb9 100644
--- a/apps/sniffle/src/sniffle_create_fsm.erl
+++ b/apps/sniffle/src/sniffle_create_fsm.erl
@@ -99,6 +99,7 @@ create(UUID, Package, Dataset, Config) ->
%%--------------------------------------------------------------------
init([UUID, Package, Dataset, Config]) ->
process_flag(trap_exit, true),
+ random:seed(now()),
Config1 = jsxd:from_list(Config),