Skip to content

Instantly share code, notes, and snippets.

View krestenkrab's full-sized avatar

Kresten Krab Thorup krestenkrab

View GitHub Profile
@krestenkrab
krestenkrab / gist:6435896
Last active December 22, 2015 07:08
Erjang/NIF interop First time ever calling a real NIF from Erjang. The nif .so is not recompiled specifically for Erjang.
krab$ ../ej
** Erjang R15B03 ** [root:/usr/local/lib/erlang] [erts:5.9.3.1] [unicode]
Eshell V5.9.3.1 (abort with ^G)
1> erlang:load_nif("/Users/krab/Projects/riak/deps/bitcask/priv/bitcask.so", any).
ok
2> {ok,KeyDir} = bitcask_nifs:keydir_new().
{ok,<<>>}
3> bitcask_nifs:keydir_put_int(KeyDir, <<"key">>, 2, 100, <<123:64>>, 2222, 3333, 3, <<123:64>>).
already_exists
4> bitcask_nifs:keydir_put_int(KeyDir, <<"key">>, 2, 100, <<123:64>>, 2222, 3333, 0, <<123:64>>).
@krestenkrab
krestenkrab / BEAM, R15B03
Last active December 22, 2015 03:48
Running the nbody problem, Erjang vs. HiPE: 412% speedup
krab$ erl
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.3.1 (abort with ^G)
1> nbody:module_info().
[{exports,[{main,1},{module_info,0},{module_info,1}]},
{imports,[]},
{attributes,[{vsn,[219858955424611931400228266183821808428]}]},
{compile,[{options,[{outdir,"/Users/krab/Projects/erjang/test_server"}]},
{version,"4.8.2"},
@krestenkrab
krestenkrab / beam estones
Last active June 25, 2016 00:53
Running the estone test suite for Erjang vs BEAM.
EStone test completed
**** CPU speed UNKNOWN MHz ****
**** Total time 1.740884613333333 seconds ****
**** ESTONES = 260159.54 ****
{'ESTONES',2.601595e+05}
Title Millis Estone % Loops
list manipulation 52.07 29171.60 7 6400
small messages 391.62 7915.86 10 1515
@krestenkrab
krestenkrab / erjang-status-aug15.md
Last active December 22, 2017 18:46
Notes on the current status of Erjang

Elixir on Erjang

The last few weeks I've spent some night hacking time to get Erjang to be able to run Elixir. Here's a short note on the current status for those interested.

The bottom line is that we can now boot the Elixir REPL, it looks like this:

krab$ ./bin/iex 
Warning: could not run smart terminal, falling back to dumb one
Aug 26, 2013 11:11:14 AM erjang.EModuleManager$FunctionInfo$1 invoke
@krestenkrab
krestenkrab / gist:6273690
Created August 19, 2013 20:26
Sample run of Elixir on Erjang.
krab$ ./bin/iex
ej -env ERL_LIBS :/Users/krab/Projects/elixir/bin/../lib -noshell -user Elixir-IEx-CLI -extra --no-halt --erl -user Elixir-IEx-CLI
Warning: could not run smart terminal, falling back to dumb one
Interactive Elixir (0.8.2.dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 1/0
** (ArithmeticError) bad argument in arithmetic expression
:erlang./(1, 0)
:erlang.apply/2
erl_eval.erl:572: :erl_eval.do_apply/6
elixir.erl:133: :elixir.eval_forms/3
@krestenkrab
krestenkrab / iopattern.ksh
Created April 26, 2012 20:13 — forked from gburd/iopattern.ksh
iopattern - print disk I/O pattern.
#!/usr/bin/ksh
#
# iopattern - print disk I/O pattern.
# Written using DTrace (Solaris 10 3/05).
#
# This prints details on the I/O access pattern for the disks, such as
# percentage of events that were of a random or sequential nature.
# By default totals for all disks are printed.
#
# $Id: iopattern 65 2007-10-04 11:09:40Z brendan $
@krestenkrab
krestenkrab / hindent.el
Created December 22, 2011 14:14
hindent.el: Highlight indentation of current line
;;;
;;; Copyright (C) Kresten Krab Thorup
;;; Available under Apache License, Version 2.
;;;
;;;
;;; This minor mode will highlight the indentation of the current line
;;; as a vertical bar (grey background color) aligned with the column of the
;;; first character of the current line.
;;;
@krestenkrab
krestenkrab / gist:1373280
Created November 17, 2011 14:37
Parse a HTTP token-list
%%
%% Parse a comma-separated tokenlist
%%
%% the string: a, b , "c\" ", , d
%% gives : {ok, [<<"a">>, <<"b">>, <<"c\" >>, <<>>, <<"d">>]}
%%
-spec parse_tokenlist(string()) -> malformed | {ok, [binary()]}.
parse_tokenlist(String) ->
@krestenkrab
krestenkrab / gist:1275132
Created October 10, 2011 11:52
Thanks WebFaction
Dear customer,
Today the load on Web218 (the server hosting your account "dartinside") was very high mostly due to a huge number of requests to the /wp-admin/admin-ajax.php URL in your website. We had to disable this URL by changing the permissions for the file to 000. We're not sure what caused this number of requests - but they seem to be coming from a lot of different IPs. Please investigate this - if you need any further information, please let us know.
Regards,
Todor K.
WebFaction Support
--
WebFaction - Smarter web hosting
@krestenkrab
krestenkrab / config_protobuf_iphonesimulator.sh
Created September 23, 2011 14:40
Configure protobuf library for iphone
export ARCH=i686-apple-darwin11
export ARCH_PREFIX=${ARCH}-
export PLATFORM=iPhoneSimulator
export SDKVER=4.3
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT="$DEVROOT/SDKs/${PLATFORM}$SDKVER.sdk"
export PKG_CONFIG_PATH="$SDKROOT/usr/lib/pkgconfig:$DEVROOT/usr/lib/pkgconfig"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"