Skip to content

Instantly share code, notes, and snippets.

View jaredmorrow's full-sized avatar

Jared Morrow jaredmorrow

View GitHub Profile
license LICENSE license=Apache2
group gid=98 groupname=riak
user ftpuser=false gcos-field="Riak Server" group=riak login-shell=/usr/bin/bash password=NP uid=98 username=riak home-dir=/opt/riak/etc
<transform dir path=opt/riak/data.* -> set owner riak>
<transform dir path=opt/riak/data.* -> set group riak>
<transform dir path=opt/riak/log.* -> set owner riak>
<transform dir path=opt/riak/log.* -> set group riak>
<transform dir path=opt/riak/etc -> set owner riak>
<transform dir path=opt/riak/etc -> set group riak>
<transform file path=opt/riak/etc/.* -> set owner riak>

I've been playing more with this Erlang factoring technique. As an exercise, I've been trying to force myself to adopt the method, by writing functions that are 3 or less lines long (function clauses actually, so multiple pattern-matched claues are OK).

Death to receive expressions

One place I noticed was causing myself

on the guest SmartOS VM

pkg_add http://pkgsrc.joyent.com/sdc6/2012Q1/i386/All/smtools
# note this is going to shut down the VM
sm-prepare-image

on the global zone

@ferd
ferd / app_deps.erl
Created September 23, 2012 05:33
Quick escript to generate a visualization of app dependencies in Erlang/OTP.
%%% Run with 'escript app_deps.erl'
%%% Change the path in filelib:wildcard/1 as required to capture all
%%% your dependencies.
%%%
%%% Rectangular nodes will represent library apps (no processes involved)
%%% and the circular nodes will represent regular apps. An arrow going from
%%% 'A -> B' means 'A depends on B'.
%%%
%%% This script depends on graphviz being present on the system.
-module(app_deps).
@serby
serby / gist:3933039
Created October 22, 2012 18:05
Increase max file descriptors SmartOS
projdel node
projadd -c "node settings" -U admin -G staff -K "process.max-file-descriptor=(basic,65535,deny)" node
svccfg -s node-nodestack-service setprop 'method_context/project=node'
svcadm disable node-nodestack-service
svcadm enable node-nodestack-service
pgrep node
@amitchhajer
amitchhajer / Count Code lines
Created January 5, 2013 11:08
Count number of code lines in git repository per user
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
@vinoski
vinoski / fd_setsize_on_osx.md
Last active November 7, 2017 06:20
How to raise the maximum number of file descriptors when building Erlang/OTP on OS X.

When you build Erlang/OTP on OS X, it unfortunately defaults to handling a maximum of 1024 file descriptors. You can get around this limitation with the right combination of configuration options and manual changes to a generated config file.

First, go into your unpacked Erlang/OTP source directory and run the following command, replacing the value 10000 with whatever value you want for max file descriptors:

perl -i -pe 's/(define\s+FD_SETSIZE\s+)\d+/\1 10000/' erts/config.h.in 

Next, when you run configure in your Erlang/OTP source directory, be sure to include the right CFLAGS setting, as shown below:

CFLAGS='-DREDEFINE_FD_SETSIZE -DFD_SETSIZE=15000 -D_DARWIN_UNLIMITED_SELECT' ./configure --enable-kernel-poll <other options>
@kevsmith
kevsmith / bench.erl
Last active December 14, 2015 07:09
Simple Erlang message passing benchmark
-module(bench).
-export([run_suite/3, run/1]).
run_suite(Name, Passes, Messages) ->
Results = run_suite1(Passes, Messages, []),
Avg = lists:sum(Results) / Passes,
StdDev = math:sqrt(lists:sum([math:pow(X - Avg, 2) || X <- Results]) / Passes),
Summary = [{avg, Avg}, {stddev, StdDev}, {min, lists:min(Results)},
{max, lists:max(Results)}],
@slfritchie
slfritchie / SLF.+zdss.patch
Last active December 17, 2015 14:29
Erlang/OTP R15B0x and R16B patch for the +zdss flag.
Purpose: To prevent scheduler collapse by disabling scheduler sleep periods.
This patch is relative to R16B01 pre-release but may be applied (with "fuzz")
on R15B01 and R15B03-1 without difficulty.
The new flag, "+zdss", must be used with "+scl false" flag to be successful.
See the erl.xml document for a description. Example use:
erl +scl false +zdss 500:500
Note that this flag used to be called "+zdnfgtse"
@superjamie
superjamie / 2014-09-21-the-8-byte-two-step-redux.md
Last active November 10, 2022 05:33
The 8-Byte Two-Step Redux