Skip to content

Instantly share code, notes, and snippets.

View lefant's full-sized avatar

Fabian Linzberger lefant

View GitHub Profile
%%% ch2
%%%
%%% consistent hashing of static partitions of keys onto a dynamic
%%% list of members with weights
-module(ch2).
%% api
-export([partition_ring/1,
select/2
]).
@lefant
lefant / pretty_config.erl
Last active June 22, 2020 08:49
a little escript snippet to pretty print erlang config, using the erl_syntax module
#!/usr/bin/env escript
%% -*- erlang -*-
%% * slurp in terms using inlined version of kernels file:consult/1
%% * convert to abstract syntax tree
%% * annotate all tuples
%% * pretty print using a hook to prefix the annotated nodes with newline
main([]) ->
io:format("%% -*-erlang-*-~n"),
-module(ls).
-compile(export_all).
start() ->
code:add_patha(".."),
Params = [{name_split, ["foo", "bar", "baz"]}],
Ctx = prepare_ctx(Params),
Output = mustache:render(ls, "ls.mustache", Ctx),
io:format(Output, []).