1> Bbsl = fun(Bin,Shift) -> <<_:Shift,Rest/bits>> = Bin, <<Rest/bits,0:Shift>> end.
#Fun<erl_eval.12.50752066>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# split windows like vim | |
# vim's definition of a horizontal/vertical split is reversed from tmux's | |
bind s split-window -v -c "#{pane_current_path}" | |
bind v split-window -h -c '#{pane_current_path}' | |
bind ^s split-window -v -c "#{pane_current_path}" | |
bind ^v split-window -h -c "#{pane_current_path}" | |
# move around panes with hjkl, as one would in vim after pressing ctrl-w | |
bind h select-pane -L |
A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."
- Does the design expect failures to happen regularly and handle them gracefully?
- Have we kept things as simple as possible?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KafkaEx.create_worker(:foo, uris: Application.get_env(:kafka_ex, :brokers), consumer_group: "bar") | |
Enum.each(1..1000, fn x -> KafkaEx.produce("foo", 0, "bar#{x}") end) | |
KafkaEx.fetch("foo", 0, worker_name: :foo, max_bytes: 100) | |
# output | |
""" | |
[%KafkaEx.Protocol.Fetch.Response{partitions: [%{error_code: 0, | |
hw_mark_offset: 1002, last_offset: 2, | |
message_set: [%KafkaEx.Protocol.Fetch.Message{attributes: 0, | |
crc: 2491399380, key: "", offset: 0, value: "bar"}, | |
%KafkaEx.Protocol.Fetch.Message{attributes: 0, crc: 702483308, key: "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[general] | |
transport=udp | |
localnet=192.168.29.0/255.2 | |
directmedia=nonat | |
externaddr=x.x.x.x | |
disallow=all | |
bindaddr=192.168.29.184 | |
context=public | |
allowoverlap=no | |
udpbindaddr=192.168.29.184 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VigenereHexXOR = fun(Plain, KeyList) -> G = fun([H|T], [B|R], Q, List, F) -> | |
F(T, R, Q, [H bxor list_to_integer(B, 16)|List], F); | |
(Act, [], Q, List, F) -> | |
F(Act, Q, Q, List, F); | |
([], _, _, List, _) -> [integer_to_list(X, 16) || X <- lists:reverse(List)] | |
end, | |
G(Plain, KeyList, KeyList, [], G) | |
end. | |
VigenereHexXOR("cool!", ["01", "3F"]). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_mix() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
if [[ ! -f /tmp/__mix_completion__ ]]; then | |
opts=$(for i in `mix help | grep -ve "current:" | grep -ve "iex" | awk '{ print $2" " }'`; do echo $i; done); | |
echo $opts > /tmp/__mix_completion__; | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'BEGIN {srand()} !/^$/ { if (rand() <= .01) print $0}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-compile([export_all]). | |
-spec foo(<<_:32, _:_*8>>) -> list. | |
foo(<<X:32, Y/binary>>) -> [X, Y]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(isbn). | |
-export([generate_signed_url/2]). | |
%%http://docs.aws.amazon.com/AWSECommerceService/latest/DG/rest-signature.html | |
generate_signed_url(Secret, Url) -> [H, T] = sort_url_params(append_timestamp(Url)), | |
H ++ "?" ++ T ++ "&Signature=" ++ hash_url_params(Secret, prepend_request_header(T)). | |
encode_url(Url) -> http_uri:encode(Url). |