Skip to content

Instantly share code, notes, and snippets.

View lpgauth's full-sized avatar
😄
busy building cool stuff

Louis-Philippe Gauthier lpgauth

😄
busy building cool stuff
View GitHub Profile
@lpgauth
lpgauth / gist:78f81fabbea0f959759d
Last active December 26, 2021 13:54
generating json (erlang)
-module(json_fun).
-export([
test/0
]).
-record(my_api, {
name,
age,
cars
# Segment ETL
https://github.com/adgear/segment-etl
https://github.com/adgear/segvault
https://github.com/adgear/segvault-client
# Identifyd Job
https://github.com/adgear/adgear-identifyd
https://github.com/adgear/identifyd-service
https://github.com/adgear/identifyd-client
-module(bloomfilter).
-export([new/1, insert/2, contains/2]).
-define(PREFIX, [<<"foo">>, <<"bar">>, <<"baz">>]).
new(Size) ->
{bf, Size, atomics:new(Size, [])}.
insert({bf, Size, Ref}, Key) ->
export SSL_PATH="/usr/local/Cellar/openssl@1.1/1.1.1d/"
export KERL_BUILD_BACKEND="git"
export KERL_CONFIGURE_OPTIONS="--without-javac --with-dynamic-trace=dtrace --with-ssl=${SSL_PATH}"
% according to the code this should work
ok = socket:send(Socket, Data, [], nowait)
=ERROR REPORT==== 5-Jul-2019::12:52:06.740284 ===
Error in process <0.76.0> with exit value:
{badarith,[{erlang,'-',[nowait,0],[]},
{socket,next_timeout,2,[]},
{socket,do_send,4,[]},
{hammer2,send,1,[{file,"hammer2.erl"},{line,25}]}]}
@lpgauth
lpgauth / gist:3789152
Created September 26, 2012 16:53
basic auth with Cowboy
-module(auth_handler).
-compile({parse_transform, seqbind}).
-export([init/3, handle/2, terminate/2]).
-define(USERNAME, <<"admin">>).
-define(PASSWORD, <<"password">>).
%% public
init(_Transport, Req, []) ->
#!/usr/bin/env escript
-mode(compile).
%% public
main([]) ->
bert_to_bert2("./priv/bertconfs/*/*.bert");
main(Wildcard) ->
bert_to_bert2(Wildcard).
%% private
lpgauth marina (feature/hex-pm)$ ./bin/rebar3 upgrade
===> Verifying dependencies...
===> Upgrading lz4 ({pkg,<<"lz4">>,<<"0.2.4-a">>,
<<"D46A8AA7BD7AB0A9877F127CEBD95A24B8491066D0D2135D757C1601E87AC53E">>})
===> Downloaded package, caching at /Users/lpgauth/.cache/rebar3/hex/default/packages/lz4-0.2.4-a.tar
===> Upgrading lz4 ({pkg,<<"lz4">>,<<"0.2.4-a">>,
<<"D46A8AA7BD7AB0A9877F127CEBD95A24B8491066D0D2135D757C1601E87AC53E">>})
===> Downloaded package, caching at /Users/lpgauth/.cache/rebar3/hex/default/packages/lz4-0.2.4-a.tar
===> No upgrade needed for shackle
===> No upgrade needed for granderl
Erlang/OTP 20 [erts-9.1.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V9.1.3 (abort with ^G)
1> Tid = fun() ->
1> Tid = ets:new(test, []),
1> Forms = [{attribute, 0, module, load_binary_segfault}, {attribute, 0, export, [{test, 0}]}, {function, 0, test, 0, [{clause, 0, [], [], [{integer, 0, Tid}]}]}],
1> {ok, Module, Bin} = compile:forms(Forms, [debug_info]),
1> code:load_binary(Module, "load_binary_segfault.erl", Bin)
1> end.
#Fun<erl_eval.20.99386804>
Client PoolSize Concurency Requests/s Error %
=================================================
buoy 8 32 119826 0.0
buoy 8 64 186194 0.0
buoy 8 128 331073 0.0
buoy 8 512 341541 0.0
buoy 8 2048 209898 1.0
buoy 8 4096 218127 4.8
buoy 16 32 125243 0.0
buoy 16 64 200209 0.0