Skip to content

Instantly share code, notes, and snippets.

View krestenkrab's full-sized avatar

Kresten Krab Thorup krestenkrab

View GitHub Profile
@krestenkrab
krestenkrab / keybase.md
Created February 5, 2019 15:49
keybase.md

Keybase proof

I hereby claim:

  • I am krestenkrab on github.
  • I am drkrab (https://keybase.io/drkrab) on keybase.
  • I have a public key ASBs-18J2gBlouOQMVkDDMJQ9jmqLyKGC5cnhj673sSfHgo

To claim this, I am signing this object:

@krestenkrab
krestenkrab / hashtree_optimizations.md
Last active August 29, 2015 14:10
hash treee optimizations

hashtree.erl optimization ideas

On-disk format for segment data

The current on-disk format is that each KV is stored in the tree file as

<<$t,TreeId:22/binary,$s,Segment:64/integer,Key/binary>>

TreeId is 22 bytes (20 bytes from the vnode id, and 2 bytes for N value). The implementation in hashtree uses 1M segments, and the Segment is stored in a 64 bit unsiged. Finally, the Key is usually term_to_binary({Bucket,Key}).

message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
repeated Address addresses = 4;
extensions 10 to max;
}
message Address {
#!/bin/bash
echo Building Google Protobuf for Mac OS X / iOS.
echo Use 'tail -f build.log' to monitor progress.
(
PREFIX=`pwd`/protobuf
mkdir ${PREFIX}
mkdir ${PREFIX}/platform
@krestenkrab
krestenkrab / gist:6851763
Created October 6, 2013 09:39
Elixir @ JVM now passing 2287 / 2335 tests (48 failed).
Oct 06, 2013 11:26:10 AM erjang.EModuleManager$FunctionInfo$1 invoke
INFO: MISSING 'Elixir.Foo.Bar.Baz':sum/2
Oct 06, 2013 11:26:10 AM erjang.EModuleManager$FunctionInfo$1 invoke
INFO: MISSING 'Elixir.Foo.Bar.Baz':sum/2
tokenizer_test: chars_test...*failed*
in function tokenizer_test:chars_test/0 (tokenizer_test.erl, line 146)
**error:{badmatch,[{number,1,48350}]}
=======================================================
@krestenkrab
krestenkrab / to_ulf.erl
Created October 2, 2013 09:44
first/next implementations for hanoidb
-module(to_ulf).
-include_lib("hanoidb/include/hanoidb.hrl").
first(Ref) ->
case hanoidb:fold_range(Ref,fun(K,V,Acc) -> [{K,V}|Acc] end,[],
#key_range{from_key= <<>>, limit=1, to_key=undefined})
of
[] -> '$end_of_table';
[{Key,Value}] -> {Key,Value}
@krestenkrab
krestenkrab / changes.md
Last active December 23, 2015 17:39
Making n2o/skyline work on MacOS X / R16B02

In addition to erlang R16B02, you need a more recent bash because the scripts use bash associative arrays; a feature which is not present in the version of bash distributed with MacOS X.

brew install node
brew install bash

## put new bash on path
export PATH=/usr/local/bin:$PATH
@krestenkrab
krestenkrab / gist:6538694
Last active December 22, 2015 22:18
Elixir test suite on Erjang
Krestens-MacBook-Pro:elixir krab$ make test_kernel -f Makefile.e
==> elixir (compile)
==> kernel (exunit)
Elixir.URITest
* decode (0.5ms)
* decode_query (8.1ms)
* decoder (0.5ms)
* default_port (0.7ms)
* downcase_scheme (0.8ms)
@krestenkrab
krestenkrab / output
Created September 12, 2013 12:00
Testing performance for elixir protocol dispatch for is_record
R16B01 @ x86_64-apple-darwin12.4.0, 1000000 iterations
when matching: binary is 55.46651865727732% faster
when not matching: binary is 17.42297571085909% faster
[{214705,'Foo.List'},
{177297,'Foo.Bin'},
{345924,'Elixir.List'},
{154052,'Elixir.Bin'}]
@krestenkrab
krestenkrab / gist:6494775
Last active December 22, 2015 15:49
Current output of running "make test" in elixir (with Erjang)
Krestens-MacBook-Pro:elixir krab$ make test -f Makefile.e
==> elixir (compile)
Compiled src/elixir_compiler.erl
==> kernel (compile)
Compiled lib/elixir/lib/application/behaviour.ex
Compiled lib/elixir/lib/bitwise.ex
Compiled lib/elixir/lib/behaviour.ex
Compiled lib/elixir/lib/access.ex
Compiled lib/elixir/lib/dict/behaviour.ex
Compiled lib/elixir/lib/code.ex