Skip to content

Instantly share code, notes, and snippets.

View kocolosk's full-sized avatar

Adam Kocoloski kocolosk

View GitHub Profile
diff --git a/bin/couchdb.tpl.in b/bin/couchdb.tpl.in
index 502d6b3..8d93b06 100644
--- a/bin/couchdb.tpl.in
+++ b/bin/couchdb.tpl.in
@@ -185,17 +185,10 @@ start_couchdb () {
start_arguments="$start_arguments \\\"$file\\\""
background_start_arguments="$background_start_arguments -c \\\"$file\\\""
done
- command="`%ICU_CONFIG% --invoke` \
- %ERL% $interactive_option -smp auto -sasl errlog_type error +K true \
case vector_clock:compare(RemoteVersion, LocalVersion) of
equal -> % TODO assert that info is the same on both remote and local
{equal, State};
less ->
{equal, State};
greater ->
server_list_into_table(RemoteServerList, Servers),
NewState = State#membership{
nodes = RemoteNodes,
version = RemoteVersion,
@kocolosk
kocolosk / top-50-by-value.js
Created September 9, 2009 21:10
reduce function to return a sorted array of the top 50 values
function(doc) {
emit(doc.parent_id, doc.visits);
}
function (keys, values, rereduce) {
var result = [];
var unique_keys = [];
function add_to_result(parent_id, visits) {
var index = unique_keys.indexOf(parent_id);
@kocolosk
kocolosk / config_bench.erl
Created October 23, 2009 17:17
measures couch_config lookup throughput
-module (config_bench).
-export ([doit/2]).
doit(Conns, Reps) ->
doit(Conns, Reps, false).
doit(Conns, Reps, AlsoWrite) ->
Conf = couch_config:all(),
Begin = erlang:now(),
Self = self(),
@kocolosk
kocolosk / gist:244781
Created November 29, 2009 03:59
take MySQL RunLog text dump and save to sqlite
def upload_runlog():
import sqlite3 as sqlite
f = open('/tmp/runlog.txt')
db = sqlite.connect('/Users/kocolosk/data/analysis.db')
dbc = db.cursor()
for line in f:
data = line.split('|')[1:-1]
run = int(data[0].strip())
trigId = int(data[1].strip())
prescale = float(data[2].strip())
-module(keysearch_microbench).
-compile(export_all).
test(ListLength, NumberOfReps) ->
crypto:start(),
Data = make_data(ListLength),
% TestId = key(), % worst-case, missing key
TestId = element(1,lists:nth(4,Data)), % some key in the list
#define _XOPEN_SOURCE 600
#ifdef __APPLE__
#define _DARWIN_C_SOURCE
#endif
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int fd;
fd = open(argv[1], O_RDONLY);
drop_cache(Db) ->
Cmd = couch_config:get("couchdb", "bin_dir") ++ "/drop_cache " ++
Db#db.filepath,
Port = erlang:open_port({spawn, Cmd}, [exit_status]),
?LOG_DEBUG("waiting for drop_cache exit while compacting ~p", [Db#db.name]),
receive
{Port, {exit_status, 0}} ->
ok;
{Port, {exit_status, Status}} ->
?LOG_ERROR("drop_cache on ~s exited with ~p", [Db#db.filepath, Status]),
@kocolosk
kocolosk / gist:1054286
Created June 29, 2011 16:49
raw fstab on SL machines
We couldn’t find that file to show.
@kocolosk
kocolosk / gist:1189561
Created September 2, 2011 19:14 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job: Erlanger, databases and distributed systems
Favorite Python project: PyPy
Favorite Conference: Erlang Factory SF Bay
Python Experience Level: ~4 years, mostly scientific computing (PyROOT) and scripting work