Skip to content

Instantly share code, notes, and snippets.

View jlouis's full-sized avatar

Jesper Louis Andersen jlouis

View GitHub Profile
@jlouis
jlouis / QC_feedback.md
Created October 2, 2014 13:11
Some feedback for Chris Meiklejohn (and others)

Feedback on the QuickCheck model

So, we have a QuickCheck model at

https://github.com/cmeiklejohn/derflow/blob/master/test/derflow_ets_eqc.erl

and Chris is asking for feedback, so here goes the things I've seen in this model. This is just haphazardly written, so don't expect there to be much flow in the thing.

@jlouis
jlouis / foo.erl
Created October 8, 2014 17:49
Different update approaches
update_state(State, []) ->
State;
update_state(State, [{ Id, Val } | T]) ->
case Id of
<<"wood">> -> update_state(State#state.wood = Val, T);
<<"stone">> -> update_state(State#state.stone = Val, T);
<<"iron">> -> update_state(State#state.iron = Val, T)
end,
error.
@jlouis
jlouis / ise.patch
Created October 16, 2014 16:02
Patch for Cowboy. Better error messages upon a 500 status code.
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 981b321..c398e0d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -1306,7 +1306,7 @@ status(426) -> <<"426 Upgrade Required">>;
status(428) -> <<"428 Precondition Required">>;
status(429) -> <<"429 Too Many Requests">>;
status(431) -> <<"431 Request Header Fields Too Large">>;
-status(500) -> <<"500 Internal Server Error">>;
+status(500) -> <<"666 Infernal Server Error">>;
@jlouis
jlouis / err
Created October 16, 2014 22:24
EQC Component error
Reason:
{'EXIT',
{function_clause,
[{dht_net,handle_call,
[sync,
{<0.461.0>,#Ref<0.0.0.2064>},
{noreply,
{state,sock_ref,
{0,nil},
{[<<79,179,152,242>>],
@jlouis
jlouis / dynamic_encryption.md
Created October 24, 2014 20:21
How I currently think dynamic encryption works

Current guess at dynamic encryption

This is my current guess at how dynamic encryption works. It has not been verified by anyone, so take everything with a large dose of salt. This is just my guess based on what I've been able to deduce.

Alice wants to send a message to Bob. They have already exchanged a secret key, k.

To send a plaintext message m:

  • Alice generates a random nonce, p. It is deleted after use.
  • Alice uses G(·, ·), a cipher generator, to generate a cipher
****** Process <0.66.0> -- 47.13 % of profiled time ***
FUNCTION CALLS % TIME [uS / CALLS]
-------- ----- --- ---- [----------]
gen_server:decode_msg/8 100000 4.71 7221 [ 0.07]
erlang:setelement/3 99639 5.52 8454 [ 0.08]
gen_server:handle_msg/5 100000 6.85 10490 [ 0.10]
flake_util:curr_time_millis/0 100000 7.77 11905 [ 0.12]
flake_server:get/5 100000 8.20 12566 [ 0.13]
flake_server:handle_call/3 100000 9.17 14040 [ 0.14]
flake_util:gen_id/3 100000 11.44 17524 [ 0.18]
diff --git a/apps/flake/src/flake_harness.erl b/apps/flake/src/flake_harness.erl
index 0657f03..6980cb3 100644
--- a/apps/flake/src/flake_harness.erl
+++ b/apps/flake/src/flake_harness.erl
@@ -18,33 +18,35 @@
-author ('Dietrich Featherston <d@boundary.com>').
-export ([
- generate/1,
- generate/2,
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [kernel-poll:false]
Eshell V6.3 (abort with ^G)
1> application:ensure_all_started(curve_tun).
{ok,[enacl,curve_tun]}
2> {ok, S} = t:c().
{ok,{curve_tun_socket,<0.46.0>}}
3> curve_tun_connection:send(S, <<"Hello">>).
ok
4> curve_tun_connection:recv(S).
@jlouis
jlouis / pheap.ml
Created December 25, 2014 13:43
Untested pairing heap.
type 'a heap =
| Tree of 'a * ('a heap) list
| Empty
let empty = Empty
let is_empty = function
| Empty -> true
| (Tree _) -> false
jlouis@lady-of-pain:~/go/src/github.com/jlouis/rank$ GOMAXPROCS=8 ./rank -passwd='AAAAAAAAAaaaaaaaaaaaaaaaaaaaand OPEN!' -optimize=true -tourneys=149 | tee run.out
2014/12/30 12:42:19 === INITIALIZE
2014/12/30 12:42:19 Reading tournaments
2014/12/30 12:42:19 Reading players
2014/12/30 12:42:21 Populating player structure with 164761 players
Getting matches for tournament: 1
Getting matches for tournament: 2
Getting matches for tournament: 3
Getting matches for tournament: 4
Getting matches for tournament: 5