Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / purgesh.sh
Created June 22, 2022 05:16
Add some views and docs then purge files
#!/bin/sh
http delete $DB/db
http put $DB/db'?q=4'
http put $DB/db/_design/d views:='{"v": {"map":"function(doc){emit(doc._id, 42);}"}}'
http put $DB/db/x a=b
http put $DB/db/y a=b
http put $DB/db/z a=b
@nickva
nickva / sorting.sh
Created June 10, 2022 19:56
Sorting an already sorted list in Erlang
% ./erlperf \
'runner(Unsorted) -> lists:sort(Unsorted).' \
--init_runner '[{rand:uniform(), I} || I <- lists:seq(1,500)].' \
'runner(Sorted) -> lists:sort(Sorted).' \
--init_runner 'lists:sort([{rand:uniform(), I} || I <- lists:seq(1,500)]).'
Code || QPS Time Rel
runner(Sorted) -> lists:sort(Sorted). 1 69223 14446 ns 100%
runner(Unsorted) -> lists:sort(Unsorted). 1 7158 140 us 10%
@nickva
nickva / perfparams.py
Last active June 26, 2024 10:27
perfparams - convert a simple .conf file to couchdb .ini and vm.args files
#!/usr/bin/env python3
import optparse
from dataclasses import dataclass
from collections import defaultdict
@dataclass
class Param:
name: str
@nickva
nickva / dist_perf.erl
Last active April 13, 2022 20:59
Erlang Distribution Protocol Benchmark
%
% $ erl -name n1@127.0.0.1
%
% $ erl -name n2@127.0.0.1
% (n2@127.0.0.1)2> dist_perf:go('n1@127.0.0.1').
% started
% Sent:953MB/s, Hist:{6,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,97,0}
% Sent:961MB/s, Hist:{1,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,155,0}
% Sent:953MB/s, Hist:{6,0,0,12,0,0,0,0,0,0,0} RHist:{0,0,0,0,0,0,0,0,0,202,0}
%
-module(slow_tuples).
-export([
run/0
]).
run() ->
run(7500, 0.0008, {1647,841737,351137}).
@nickva
nickva / stampede_dbs_ddocs_vdpus.py
Created March 18, 2022 14:43
Stampede a bunch of ddoc and VDU calls on a CouchDB cluster
#!/usr/bin/env python
#
# Use a 3 node cluster
#
# Args examples:
# ./script.py -x 20 -n 100 -w 5 -p 10 -q
# ./script.py -x 100 -n 2 -p 20 -w 1 -t 10
# ./script.py -x 101 -n 2 -p 10 -w 5 -t 2
@nickva
nickva / repscript.sh
Created February 27, 2022 20:43
Simple CouchDB replication setup
#!/bin/bash
set -xe
DB=http://adm:pass@localhost:15984
http $DB
http -b delete $DB/_replicator
http -b delete $DB/source
http -b delete $DB/target
@nickva
nickva / read_only_replication_source.sh
Last active February 10, 2022 19:45
Prevent regular doc writes to the replication source
#!/bin/sh
# Prevent regular doc writes to the replication source. Used, for example, when
# migrating to a new instance and we want to prevent clients writing to the old
# instance by accident. Design doc writes and all doc reads can still take
# place.
#
# (`http` is the httpie client https://httpie.io/)
DB="http://adm:pass@localhost:15984"
@nickva
nickva / monitor_nodes.erl
Created November 11, 2021 20:05
Erlang net_kernel:monitor_nodes/1 snippet
spawn(fun () ->
net_kernel:monitor_nodes(true),
F = fun Loop() ->
receive Msg ->
io:format("~n *** mon msg:~p~n", [Msg]),
Loop()
end
end,
F()
end).
@nickva
nickva / validate_erlang_install.md
Last active November 8, 2021 22:34
Validate Erlang Install By Running Custom Tests Suites

Based on https://www.erlang.org/doc/installation_guide/install

Erlang Version:

commit eef2e7066ecdf9de5dc7fd81dc5043d9a9757efa (HEAD -> maint-24, tag: OTP-24.1.4, origin/maint-24)
Author: Erlang/OTP <otp@erlang.org>
Date:   Mon Nov 1 15:26:06 2021 +0100

SSL Versions: