Skip to content

Instantly share code, notes, and snippets.

@okeuday
okeuday / wlan-scan.sh
Created February 23, 2017 02:00
Linux /etc/network/interfaces script for wifi
#!/bin/sh
if [ $# -ne 1 ]; then
echo "usage: $0 wlan_interface"
exit 1
fi
DIRECTORY=`dirname $0`
IFACE=$1
ifconfig $IFACE hw ether `$DIRECTORY/mac_address_reset`
@okeuday
okeuday / quine0
Created April 5, 2019 06:25
A quine in Erlang
#!/usr/bin/env escript
%%!
%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et:
-mode(compile).
main(["-i" | _]) ->
MagicNumber = 0,
GenerationName = filename:basename(escript:script_name()),
@okeuday
okeuday / immediate_gc.erl
Created September 23, 2014 05:08
Immediate Garbage Collection in Erlang (as harsh as possible)
%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et:
%%%
%%%------------------------------------------------------------------------
%%% @doc
%%% ==Enforce immediate garbage collection on a function==
%%% @end
%%%
%%% BSD LICENSE
%%%
@okeuday
okeuday / http_req_erlang.xml
Last active July 10, 2017 16:05
CloudI Erlang http_req integration test Tsung loadtest configuration
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<!-- Client side setup -->
<clients>
<client host="load00" maxusers="30000" use_controller_vm="false">
<ip value="192.168.2.10"/>
</client>
<client host="load01" maxusers="30000">
@okeuday
okeuday / mac_address_reset
Created February 23, 2017 01:55
Automatically generate a valid MAC address
#!/bin/sh
# wget http://standards.ieee.org/develop/regauth/oui/oui.txt
DIRECTORY=`dirname $0`
PREFIX=`shuf $DIRECTORY/oui.txt | grep '(base 16)' | head -n 1 | cut -c '3-8'`
SUFFIX=`openssl rand -hex 3 | sed 's/.*/\U&/'`
echo "$PREFIX$SUFFIX"
@okeuday
okeuday / output.txt
Last active November 4, 2016 00:41
erlbench string_key results with no optimizations on https://github.com/CloudI/CloudI/tree/develop/src/tests/http_req#machine-1--122
erl +C multi_time_warp -noshell -pz ebin -s run test -s init stop
TEST string_key
N == 10 (10 runs)
aadict get: 2.1 us ( 1.1), set: 7.8 us ( 1.8)
btrie (binaries) get: 5.0 us ( 2.5), set: 19.8 us ( 4.5)
dict get: 5.4 us ( 2.7), set: 15.2 us ( 3.5)
ets (ordered_set) get: 5.1 us ( 2.6), set: 8.6 us ( 2.0)
ets (set) get: 5.5 us ( 2.8), set: 11.1 us ( 2.5)
ets x10 read (ordere get: 10.1 us ( 5.1)
ets x10 read (set) get: 12.1 us ( 6.1)
@okeuday
okeuday / keybase.md
Created September 13, 2016 01:09
keybase.io github verification

Keybase proof

I hereby claim:

  • I am okeuday on github.
  • I am okeuday (https://keybase.io/okeuday) on keybase.
  • I have a public key whose fingerprint is 1280 8D2D FFAE 0B0A F4DE B11A 4BE6 AE02 12FE BBB1

To claim this, I am signing this object:

@okeuday
okeuday / gist:7e4549cb030077db5fa4
Created February 19, 2016 03:00
integer_key, binary_key, string_key (https://github.com/okeuday/erlbench)
Core i7 2670QM 2.2GHz 1 cpu, 4 cores/cpu, 2 hts/core
L2:4×256KB L3:6MB RAM:8GB:DDR3-1333MHz
Sandy Bridge-HE-4 (Socket G2)
TEST integer_key
N == 10 (10 runs)
aadict get: 2.5 us ( 25.0), set: 9.6 us ( 8.0)
array (dynamic) get: 1.0 us ( 10.0), set: 3.7 us ( 3.1)
array (fixed) get: 1.2 us ( 12.0), set: 2.7 us ( 2.3)
btree7 get: 2.6 us ( 26.0), set: 5.2 us ( 4.3)
@okeuday
okeuday / decompile.erl
Created January 21, 2014 20:19
decompile.erl
-module(decompile).
-export([file/1]).
file(ModuleName) when is_atom(ModuleName) ->
case code:which(ModuleName) of
BeamFilePath when is_list(BeamFilePath) ->
file(BeamFilePath);
Error when is_atom(Error) ->
Error
end;
@okeuday
okeuday / gist:6832394
Created October 4, 2013 20:42
uuid run
TEST uuid_creation
N == 100000 (10 runs)
erlang:make_ref/0 get: 7161.7 us ( 1.0)
v1 erlang get: 79289.2 us ( 11.1)
v1 os get: 72063.8 us ( 10.1)
v3 get: 78722.5 us ( 11.0)
v3 compat get: 73597.6 us ( 10.3)
v4 crypto strong get: 218098.7 us ( 30.5)
v4 crypto weak get: 219091.8 us ( 30.6)
v4 random bigint get: 197156.6 us ( 27.5)