Skip to content

Instantly share code, notes, and snippets.

View bsparrow435's full-sized avatar

Brian Sparrow bsparrow435

View GitHub Profile
@angrycub
angrycub / bitcaskhintcheck.erl
Created March 20, 2014 15:52
escript bitcask hintcheck
#!/usr/bin/env escript -f
%% -*- erlang -*-
-define(OFFSETFIELD, 64).
-define(TSTAMPFIELD, 32).
-define(KEYSIZEFIELD, 16).
-define(TOTALSIZEFIELD, 32).
-define(HINTHEADSIZE, 18). %%(?TSTAMPFIELD + ?KEYSIZEFIELD + ?TOTALSIZEFIELD + ?OFFSETFIELD)/8
@kellymclaughlin
kellymclaughlin / pb_status_anon.txt
Created September 28, 2012 21:18
How to get poolboy status for each Riak Vnode
PBStatusFun = fun() ->
VnodePids = [Pid || {_, Pid} <- riak_core_vnode_manager:all_index_pid(riak_kv_vnode)],
Links = [process_info(Pid, [links]) || Pid <- VnodePids],
WorkerPoolPids = [WPPid || [{links,[_, WPPid]}] <- Links],
WorkerPoolLinks = [process_info(Pid, [links]) || Pid <- WorkerPoolPids],
PoolboyPids = [PoolboyPid || [{links,[_, PoolboyPid]}] <- WorkerPoolLinks],
[poolboy:status(Pid) || Pid <- PoolboyPids]
end.
PBStatusFun = fun(Index) ->
@freerobby
freerobby / export_bucket_keys.rb
Last active December 10, 2015 11:59
Exports all keys in a riak bucket into a newline-delimited file.
# This function uses net::http streaming and the Riak HTTP endpoint
# to export all keys in a riak bucket into a newline-delimited file.
require 'json'
require 'net/http'
RIAK_ROOT = 'http://localhost:8098'
# bucket: The bucket to export
# path: The folder into which to put the output file
@cdahlqvist
cdahlqvist / pb_status_monitor.erl
Created May 24, 2013 13:27
Process that monitors the status of the poolboy worker pool used for coverage queries.
%% -------------------------------------------------------------------
%%
%% pb_status_monitor: PoolBoy pool monitor
%%
%% 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
@macintux
macintux / split-info
Last active December 19, 2015 23:29
For use with large cluster-info files generated via riak-admin. Will split them into more manageable file sizes.
#!/usr/bin/perl -w
use strict;
use warnings;
sub usage {
my ($errmsg) = @_;
my $msg = <<END;
Usage: split-info <info file> <output directory>
dtrace -n 'syscall::writev:entry /execname == "node" && arg2 > 16/ { printf("iovcnt: %d", arg2); }' -n 'syscall::writev:return /execname == "node" && arg1 == -1 && errno == 22/ { printf("%s %s %d\\n", curpsinfo->pr_psargs, probefunc, errno); jstack(100, 8000); }'
1 10260 writev:entry iovcnt: 57
1 10261 writev:return node --nouse-idle-notification /voxer/server/node_router/node_router.js /voxer/ writev 22\n
libc.so.1`__writev+0x15
node`uv__write.part.5+0x18f
node`uv_write2+0x1b9
node`uv_write+0x35
node`_ZN4node10StreamWrap6WritevERKN2v89ArgumentsE+0x678
node`_ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x157
<< internal code >>
@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
@Mohamed3on
Mohamed3on / The Technical Interview Cheat Sheet.md
Last active April 23, 2020 20:47 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is a fork to fix the markdown errors in the original gist.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

Array

Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.

On the Viability of Erlang Releases and CouchDB

There has been some discussion on what versions of Erlang CouchDB should support, and what versions of Erlang are detrimental to use. Sadly there were some pretty substantial problems in the R15 line and even parts of R16 that are landmines for CouchDB. This post will describe the current state of things and make some potential recommendations on approach.

Scheduler Collapse

@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