Skip to content

Instantly share code, notes, and snippets.

Andy Till andytill

Block or report user

Report or block andytill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bench.erl
%% Luke Gorrie's favourite profiling macro.
-define(TIME(Tag, Expr),
(fun() ->
%% NOTE: timer:tc/4 does an annoying 'catch' so we
%% need to wrap the result in 'ok' to be able to
%% detect an unhandled exception.
{__TIME, __RESULT} =
andytill /
Created Oct 1, 2014
public class Engine
final static int MAX_NUM_OF_PARTICLES = 200000;
Vect3D gravity;
double drag;
Particle particles[];
andytill / Probability of Project
Last active Aug 29, 2015
Probability of Project Success
View Probability of Project


There are ten tasks in a project and they all need to be completed within their estimate for the project to be delivered on time. Each task has a 10% chance that is mis-estimated and will take longer.

What is the probability that the project will be delivered on time?

If a task has a 10% chance of being late it has a 90% (0.9) probability of success. Probability of multiple events is calculated by multiplying all the probabilties: 0.9 * 0.9 * 0.9 etc. In the contrived example where all probabilites are the same we can do a simple power of:

Eshell V5.10.2  (abort with ^G)
View .tmux.config
# set prefix key to Ctrl-a
unbind-key C-b
set-option -g prefix C-a
# set the window index to base 1
set -g base-index 1
setw -g pane-base-index 1
# Highlight active window
andytill / Default (OSX).sublime-keymap
Last active Aug 29, 2015
Sublime Text Settings (OSX)
View Default (OSX).sublime-keymap
{ "keys": ["ctrl+forward_slash"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+alt+forward_slash"], "command": "toggle_comment", "args": { "block": true } },
{ "keys": ["f3"], "command": "goto_definition" },
{ "keys": ["super+alt+r"], "command": "reveal_in_side_bar" }
andytill / riak_object_usage.erl
Last active Aug 29, 2015
xref riak_object usage
View riak_object_usage.erl
[xref:add_directory(lol, Dir) || Dir <- code:get_path()].
Exports = riak_object:module_info(exports).
Analyze_fn = fun({F,A}) -> {ok, Use} = xref:analyze(lol, {use, {riak_object, F, A}}), Use end.
[{{riak_object,F,A}, Analyze_fn(FA)} || {F,A} = FA <- Exports, F =/= module_info].
View horsetheperfs output
erlang_spawn_1:spawn_sleep_fun_on_one_proc in 1.057355s
erlang_spawn_1:spawn_fun_on_one_proc in 0.246039s
erlang_spawn_link_1:spawn_link_sleep_fun_on_one_proc in 1.132972s
erlang_spawn_link_1:spawn_link_fun_on_one_proc in 0.421424s
erlang_split_binary_2:split_binary_small_2 in 0.004270s
erlang_split_binary_2:split_binary_large_2 in 0.004266s
erlang_split_binary_2:split_binary_very_large_2 in 0.004171s
erlang_split_binary_2:syntax_split_binary_small_2 in 0.016963s
erlang_split_binary_2:syntax_split_binary_large_2 in 0.019240s
erlang_split_binary_2:syntax_split_binary_very_large_2 in 0.018668s
View proc pooling benchmarks.txt
processing_in_pools options:
?KV_SIZE: 500
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
andytill / in_process_macro.erl
Created Sep 9, 2015
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.
View in_process_macro.erl
Self = self(),
fun() ->
Self ! test_ok
View gen_fsm_visualizer.erl
%% ---------------------------------------------------------------------
%% 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
You can’t perform that action at this time.