Skip to content

Instantly share code, notes, and snippets.

@buddhisthead
buddhisthead / gist:3230974
Created August 1, 2012 21:35
Mac OS X IP firewall for traffic limiting
This snippet uses the IP firewall rules on Mac OS X to limit traffic between two specific machines. Access to other addresses, like the internet is unchanged.
sudo ipfw pipe 1 config delay 30ms
sudo ipfw pipe 2 config delay 30ms
sudo ipfw add pipe 1 ip from 192.168.1.4 to 192.168.1.7
sudo ipfw add pipe 2 ip from 192.168.1.7 to 192.168.1.4
@buddhisthead
buddhisthead / gist:4724918
Last active December 12, 2015 05:49
Wire formatting functions for replication of new/old riak_object formats
-define(MAGIC, 42). %% as opposed to 131 for Erlang term_to_binary or 51 for riak_object
-define(W1_VER, 1). %% first non-just-term-to-binary wire format
-type wire_version() :: w0 | w1.
%% @doc Create a new binary wire formatted replication blob, complete with
%% bucket and key for reconstruction on the other end. BinObj should be
%% in the new format as obtained from riak_object:to_binary(v1, RObj).
new_w1(B, K, BinObj) when is_binary(B), is_binary(K), is_binary(BinObj) ->
KLen = byte_size(K),
BLen = byte_size(B),
First download your otp_15b01 tarrball and untar it.
http://www.erlang.org/download/otp_src_R15B01.tar.gz
Get the patch into a file called "zdss.patch"
https://gist.github.com/slfritchie/5624609
Notes on how to apply a patch, in case you're interested. You probably already know this.
http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/
Put the patch into the top level of your OTP source dir and apply patch.
rpc:multicall(erlang, apply, [fun() -> riak_core_cluster_mgr:register_member_fun( fun({IP, Port}) -> CIDRFun = fun(FunR, <<>>, Acc) -> Acc; (FunR, <<X:1/bits, Rest/bits>>, Acc) -> case X of <<1:1>> -> FunR(FunR, Rest, Acc + 1); _ -> FunR(FunR, Rest, Acc) end end, MaskAddress = fun(Addr={_, _, _, _}, Maskbits) -> B = list_to_binary(tuple_to_list(Addr)), <<Subnet:Maskbits, _Host/bitstring>> = B, Subnet; (_, _) -> undefined end, {ok, MyIPs} = inet:getifaddrs(), {ok, NormIP} = riak_repl_util:normalize_ip(IP), MyMask = lists:foldl( fun({_IF, Attrs}, Acc) -> case lists:member({addr, NormIP}, Attrs) of true -> NetMask = lists:foldl(fun({netmask, NM = {_, _, _, _}}, _) -> NM; (_, Acc2) -> Acc2 end, undefined, Attrs), CIDR = CIDRFun(CIDRFun, list_to_binary(tuple_to_list(NetMask)),0), CIDR; false -> Acc end end, undefined, MyIPs), case MyMask of undefined -> [{IP, Port}]; _ -> AddressMask = MaskAddress(NormIP, MyMask), Nodes = riak_core_node_watcher:nodes(riak_kv), {Results, _BadNodes} = rpc:multicall(Nodes,riak_repl_a
@buddhisthead
buddhisthead / riak_test_random_configs.md
Last active January 2, 2016 13:18
riak_test with random configurations and mixed load workers

The riak_test loaded_upgrade does some cool stuff in that it runs a set of client processes as workers against specified versions of riak while upgrading nodes. We can take this a step further if we also randomly generate configurations, where the configuration includes general riak application settings as well as versions of riak and possibly the worker mix as well. This might be a good candidate for testing the interoperation of new features of riak 2.0 (and existing features too). It lets us keep the existing riak_tests as they are without trying to figure out composable tests, which was also talked about (and might still be a different good idea).

This could be accomplished by using EQC to generate the configurations. We'd need just

Keybase proof

I hereby claim:

  • I am buddhisthead on github.
  • I am buddhisthead (https://keybase.io/buddhisthead) on keybase.
  • I have a public key whose fingerprint is 7A7D 2412 E3DA C0EF E207 7FB5 1D82 C080 633D E562

To claim this, I am signing this object:

@buddhisthead
buddhisthead / Localization key value merging.md
Last active March 20, 2020 22:08
String Localization Merging process

This sort of documents the hopefully one-time process of merging some keys and values for localized strings

There are four things:

  1. a source of truth key/value file from Android (./RWApp/Base.lproj/Localizable.strings) called Master below.
  2. the existing English "base" localization file (./RWApp/en.lproj/Localizable.strings)
  3. non-localized Swift strings (extracted with genstrings)
  4. non-localized ObjC strings (extracted with genstrings)

The source of truth file is generated from a different series of tools documented here: https://github.com/ridewithgps/RWGPS-app-common/blob/develop/translation/README.md