Skip to content

Instantly share code, notes, and snippets.

View garazdawi's full-sized avatar

Lukas Larsson garazdawi

  • Erlang Solutions
  • Stockholm
View GitHub Profile
@garazdawi
garazdawi / tlsv1.3.sh
Created May 10, 2019 13:07
How to compile openssl and Erlang/OTP with TLSv1.3
#!/bin/bash
git clone https://github.com/openssl/openssl
cd openssl
git checkout OpenSSL_1_1_1b
./Configure shared --prefix=$HOME/apps/openssl/1.1.1b --openssldir=$HOME/apps/openssl/1.1.1b linux-x86_64
make
make install
cd ..
@garazdawi
garazdawi / gcount.erl
Created September 6, 2019 14:20
Global Counters in Erlang
-module(gcount).
-export([bench/0,bench/1]).
-export([ets_init/0,ets_new/1,ets_incr/1,ets_read/1]).
-export([cnt_init/0,cnt_new/1,cnt_incr/1,cnt_read/1]).
-export([cnt_pt_init/0,cnt_pt_new/1,cnt_pt_incr/1,cnt_pt_read/1]).
ets_init() ->
ets:new(?MODULE, [{write_concurrency,true},named_table,public]).
ets_new(Counter) ->
@garazdawi
garazdawi / bit_vector.erl
Last active June 9, 2023 17:42
A shared mutable bit-vector in Erlang
-module(bit_vector).
-export([new/1, get/2, set/2, clear/2, flip/2, print/1]).
new(Size) ->
Words = (Size + 63) div 64,
{?MODULE, Size, atomics:new(Words, [{signed, false}])}.
get({?MODULE, _Size, Aref}, Bix) ->