Skip to content

Instantly share code, notes, and snippets.

View ferd's full-sized avatar
☢️
This place is not a place of honor… no highly esteemed deed is commemorated here

Fred Hebert ferd

☢️
This place is not a place of honor… no highly esteemed deed is commemorated here
View GitHub Profile
@ferd
ferd / day12.erl
Last active December 12, 2021 16:26
-module(day12).
-export([main/1]).
-mode(compile).
main([File]) ->
{ok, Bin} = file:read_file(File),
Lines = [binary:split(Line, <<"-">>)
|| Line <- binary:split(Bin, <<"\n">>, [global, trim])],
G = lists:foldl(fun([A,B], G) -> add(A,B,add(B,A,G)) end, #{}, Lines),
io:format("part 1: ~p~npart 2: ~p~n",
-module(day10).
-export([main/1]).
-mode(compile).
main([File]) ->
{ok, Bin} = file:read_file(File),
Lines = re:split(Bin, "\n", [multiline, trim, {return, list}]),
io:format("~p~n", [run(Lines)]).
run(Lines) ->
@ferd
ferd / adtech.md
Created June 10, 2019 13:46
AdTech in a non-linear timeline nutshell

Essentially, there's a publisher side (the website displaying the ads), a supply side (the advertisers wanting to display ads), and the client (you). The advertisers might be individual corporations, but they could also be agencies that represent various advertisers or corporations as well.

Traditional advertising was either the publisher or supply side contacting each other to set up a campaign. They could strike a deal like "display my ads on your site for a week for $x" and off you'd go. A contract was signed, you added a banner, and things were fine. You could compare that format to what would be magazines and TV ads: the website was part of a target demographic and you could just buy time as-is. Eventually it evolved when sites got more general (say, news websites or dating websites) where a wide swath of the population could be on the same site. The idea became to target even tighter. The dating websites I used to work on had things like: age, gender, sexual orientation, interests, and so on. We could

Rebar3 experience

  • Common test issues
    • Couldn't get the ct setup working as we needed. Our ct command is: ct_run -pa ./_build/default/lib/*/ebin -logdir logs -suite test/${SUITE} -cover test/antidote.coverspec
    • Option -pa is not supported for rebar3 ct
    • Because of this we needed a Makefile which called ct_run manually. Makefiles were problematic for Windows users.
  • Problems when switching branches
  • If the branch has different dependencies, the _build folder is not updated and rebar3 does not update it automatically on the next build
binmiscctl add arm64 --interpreter "/usr/local/bin/qemu-aarch64-static" --magic "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00" --mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" --size 20 --set-enabled
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must
1> application:set_env(tools, file_util_search_methods, bacon).
ok
2> application:ensure_all_started(tools).
{ok,[tools]}
3> application:get_all_env(tools).
[{file_util_search_methods,[{[],[]},
{"ebin","esrc"},
{"ebin","src"}]},
{included_applications,[]}]
import sys
sys.path.append("./enum/enum")
from enum import Enum
import time
import datetime
import socket
import Crypto.Cipher
import signal
from binascii import hexlify
import base64
1> merklet_bench:main([10000, 30]).
x build-old
+ build-new
+--------------------------------------------------------------------------+
|+++++++++ x x x x xxxxxxx x xx x xx x|
|+++++ x xxxx x x x |
|+++++ x x |
|++++ x |
|++ + x |
|++ |
-module(pension2).
-export([totalBalance/1]).
%% memoization uses a process dictionary. While hackish and not portable
%% through processes, a PD of this kind has the advantage of being
%% garbage collected and being returned in a stack trace. There is also no
%% copying (see: comments over the macros) or locking needed.
-define(memoize(E), lazy_memoize(fun()-> E end)).
lazy_memoize(F) when is_function(F) ->