Skip to content

Instantly share code, notes, and snippets.

View angrycub's full-sized avatar

Charlie Voiselle angrycub

View GitHub Profile
@gburd
gburd / haproxy.conf
Last active July 5, 2022 13:34
Recommended haproxy settings to balance Riak protobuf and http interfaces (note: WORK IN PROGRESS)
# Documentation for HAProxy
# http://code.google.com/p/haproxy-docs/w/list
# http://haproxy.1wt.eu/download/1.2/doc/architecture.txt
# NOTES:
# open files limits need to be > 256000, use ulimit -n to set (on most POSIX systems)
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
@pburkholder
pburkholder / GoingAway.scpt
Created July 26, 2012 19:20
AppleScript for Away From Keyboard: Mark as away in HipChat and enable screensaver (Lock screen)
# Credit to Sean: http://ertw.com/blog/2012/05/02/controlling-hipchat-status-through-applescript/
# I link this to a Quicksilver trigger so I can press 'Shift-Option-L' when I Leave
tell application "System Events" to tell UI element "HipChat" of list 1 of process "Dock"
perform action "AXShowMenu"
delay 0.5
click menu item "Status" of menu 1
click menu item "Away" of menu 1 of menu item "Status" of menu 1
end tell
activate application "ScreenSaverEngine"
@rzezeski
rzezeski / gist:3250870
Created August 3, 2012 19:53
detect bad merge index files
#!/usr/bin/env escript
%% -*- erlang -*-
-include_lib("kernel/include/file.hrl").
-compile(export_all).
-define(LOG(S), io:format(S)).
-define(LOG(S,A), io:format(S,A)).
main(Dirs) ->
CodePath = case os:getenv("RIAK_LIB") of
@renatoalbano
renatoalbano / encode_uri_rfc3986.erl
Created September 27, 2012 21:06
erlang percent encoding that works with utf-8
-module(encode_uri_rfc3986).
-author('Renato Albano <renatoalbano@gmail.com>').
-export([encode/1]).
%% Taken from <http://erlangexamples.com/>,
%% from <http://github.com/CapnKernul/httparadise>
%% and <http://www.erlang.org/doc/man/edoc_lib.html>
encode([C | Cs]) when C >= $a, C =< $z ->
@kellymclaughlin
kellymclaughlin / gist:3834437
Created October 4, 2012 15:32
Change # of schedulers online
%% Get current number of online schedulers
Schedulers = erlang:system_info(schedulers_online).
%% Reduce number online to 1
erlang:system_flag(schedulers_online, 1).
%% Restore to original number of online schedulers
erlang:system_flag(schedulers_online, Schedulers).
@angrycub
angrycub / process.md
Created November 8, 2012 22:06
Replacing a Node to End with a Node of the Same Name

##Replacing a node with a machine of the same name ###Objective The goal is to replace a Riak instance with a new Riak instance of the same name so that the application environment does not need to have instance-name related changes.

###Scenario

Riak is running in a cluster of five nodes.

  • riak@node1.localdomain on node1.localdomain (192.168.17.11)
  • riak@node2.localdomain on node2.localdomain (192.168.17.12)
@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>

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>
@cdahlqvist
cdahlqvist / keylister.erl
Last active December 15, 2015 14:48
Script to list all keys in a Riak bucket and spool to a file. To be run while attached to riak console.
%% -------------------------------------------------------------------
%%
%% keylister: Utility for listing all keys in a bucket
%%
%% Copyright (c) 2013 Basho Technologies, Inc. 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
@aphyr
aphyr / gist:5428061
Last active December 16, 2015 11:29
This is a last-write-wins Riak application running across five nodes. Clients are subject to a perfect global write lock: no two clients will ever change a key at the same time. "." means 100 writes, "!" means a single failed write. The string of !!!s in the middle, gradually decreasing in density, is the effect of a network partition followed b…
user=> (run (apps (comp locking-app riak-lww-sloppy-quorum-app)))
.......!!!!!!!!!!!!!!!!!!!!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.!!!!!!!!!!!!!!!!.!!!!!!!!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.........Hit enter when ready to collect results.
#_=>
Writes completed in 178.326 seconds
2000 total
1841 acknowledged
1246 survivors
599 acknowledged writes lost! (╯°□°)╯︵ ┻━┻
505 506 510 511 515 516 ... 1985 1986 1990 1991 1995 1996