Skip to content

Instantly share code, notes, and snippets.

View andytill's full-sized avatar

Andy Till andytill

View GitHub Profile
@andytill
andytill / erlang_record_migrations.md
Last active June 15, 2016 10:54
erlang_record_migrations

Erlang Record Migrations

A proposal for the syntax for migrations. Separate record definitions with the same name. Each definition has a version increment, each definition defines fields which are in addition to the previous versions.

%% the original definition for the project record, defined for an
%% old version of our application
-record(project, {
    version = 1,
    name :: binary()
@andytill
andytill / tracing_process_dump.erl
Created April 17, 2016 11:04
tracing process_dump
DbgFun = fun({trace_ts, _, _event, MFA, Msg, TS}, _Acc) ->
io:format("XXXXXXXXXXXXXXXXXXXXXXXX ~p : ~p~n~s~n", [MFA, TS, Msg]) end.
dbg:tracer(process, {DbgFun, ok}).
dbg:tp({io,format,1}, [{'_', [], [{message,{process_dump}}, {exception_trace}]}]).
dbg:p(all,[c, timestamp]).
io:format("hi").
@andytill
andytill / java gtk module errror fix
Created April 6, 2016 12:57
java gtk module errror fix
sudo apt-get install libssl0.9.8 libcanberra-gtk0 libcanberra-gtk-module
@andytill
andytill / run all TS riak tests
Last active April 18, 2016 16:51
run all TS riak tests
make quickbuild && ./riak_test -c rtdev `sh -c 'for i in tests/ts_*; do echo -t $i; done'`
@andytill
andytill / makecheckk
Created October 1, 2015 08:10
makecheckk
make -C test LEGACY=
make[1]: Entering directory `/home/vagrant/work/erlang.mk/test'
build: Generate a bleeding edge Erlang.mk
core-app-asn1: Bootstrap a new OTP library named core_app_asn1
core-app-asn1: Download .asn1 files from Erlang/OTP
core-app-asn1: Generate .erl files dependent from headers generated by .asn1 files
core-app-asn1: Generate an unrelated .hrl file
core-app-asn1: Build the application
core-app-asn1: Check that all compiled files exist
core-app-asn1: Check that the application was compiled correctly
@andytill
andytill / riak util scripts.sh
Created September 22, 2015 17:14
riak util scripts.sh
## start_cluster.sh
for node in {1..3}; do dev/dev$node/bin/riak start; done
## cluster_up.sh (clusters the individualnodes)
for node in {2..3}; do dev/dev$node/bin/riak-admin cluster join 'dev1@127.0.0.1'; done
%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2015 Kota UENISHI. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
@andytill
andytill / Time Series Usage.md
Last active September 22, 2015 17:01
Time Series Usage

Create bucket type with the table_def property.

export TAB=GeoCheckin; dev/dev1/bin/riak-admin bucket-type create $TAB "{\"props\":{ \"table_def\": \"CREATE TABLE GeoCheckin (geohash varchar not null, user varchar not null, time timestamp not null, weather varchar not null, temperature varchar, PRIMARY KEY((quantum(time, 15, s)), time, user))\"}}"

Activate it:

dev/dev1/bin/riak-admin bucket-type activate $TAB

@andytill
andytill / in_process_macro.erl
Created September 9, 2015 09:57
Erlang macro to run some eunit test code inside its own process and wait for that process to complete before returning. This is useful when testing resources which get cleaned up when the current process completes like ets tables.
%%% MACRO
-define(in_process(TestCode),
Self = self(),
spawn_link(
fun() ->
TestCode,
Self ! test_ok
end),
receive
@andytill
andytill / proc pooling benchmarks.txt
Created July 22, 2015 13:58
proc pooling benchmarks
processing_in_pools options:
?ITERATIONS: 10000
?KV_SIZE: 500
?PRE_SIZED_HEAP: 4400
scheduler_bind_type: no_node_thread_spread
schedulers_online: 4
processing_in_pools:temporary_workers in 10.226417s
processing_in_pools:temporary_workers_with_pre_sized_heaps in 10.378222s