Skip to content

Instantly share code, notes, and snippets.

View dszoboszlay's full-sized avatar

Dániel Szoboszlay dszoboszlay

  • Klarna
  • Stockholm, Sweden
View GitHub Profile
#!/usr/bin/env escript
-mode(compile).
-define(PORT, 2345).
-define(SERVER_TIMEOUT, 1000).
-define(CLIENT_TIMEOUT, 1500).
main(Msg) ->
application:ensure_all_started(ssl),
spawn(fun server/0),
@dszoboszlay
dszoboszlay / perftest.erl
Last active August 30, 2021 10:46
Small utility for comparing the time to execute various Erlang functions
-module(perftest).
-export([test/1, test/2]).
-define(SCHEDULER_REDUCTIONS_LIMIT, 2000).
-define(MIN_INNER_LOOPS, 50).
-define(STOP_OUTER_MSG, stop_outer_loop).
-define(EMPTY_LOOP, "empty loop").
test(Fs) ->
test(Fs, timer:seconds(1)).
@dszoboszlay
dszoboszlay / ets_memory.erl
Last active February 8, 2019 22:42
ETS memory fragmentation demo
-module(ets_memory).
-export([test/1]).
-include_lib("stdlib/include/ms_transform.hrl").
-define(key_count, (1000 * 1000)).
-define(data_size, 512).
test(N) ->
T = ets:new(tab, [set, private]),
@dszoboszlay
dszoboszlay / foo.erl
Last active August 29, 2015 14:24
Erlang indentation issues with try blocks and comma-first coding style
%%% -*- mode: erlang; erlang-indent-level: 2 -*-
-module(foo).
-compile([export_all]).
-record(comma_first, { x
, y :: integer() % good indentation
, z % bad indentation (caused by type spec)
}).
try_blocks() ->
(add-hook 'erlang-mode-hook 'font-lock-mode)
(setq require-final-newline t)
(column-number-mode 1)
(iswitchb-mode t)
(setq visible-bell t)
(global-set-key "\C-x\C-b" 'electric-buffer-list)
(show-paren-mode t)
(setq blink-matching-paren-distance nil)
(require 'package)
(package-initialize)