Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / magic_ring.cpp
Last active November 27, 2017 18:02 — forked from rygorous/magic_ring.cpp
The magic ring buffer.
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <string.h>
#include <Windows.h>
// This allocates a "magic ring buffer" that is mapped twice, with the two
// copies being contiguous in (virtual) memory. The advantage of this is
// that this allows any function that expects data to be contiguous in
// memory to read from (or write to) such a buffer. It also means that
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
Use a ramdisk on OS X to speed up local dev cluster
Download ramdisk.sh:
https://gist.github.com/nickva/74f12b6163e578c3afb0649370f59dc5
$ chmod a+x ./ramdisk.sh
$ ./ramdisk.sh create 4000 # create a 4GB disk mounted to /Volumes/ramdisk
Create ramdisk...
@nickva
nickva / dderl
Last active April 18, 2016 15:25
Erlang tool to benchmark writing n blocks of size s (for a total of n*s bytes). Optionally issue fsync after each write
#!/usr/bin/env escript
%% -*- erlang -*-
%
% File writer benchmarking tool
%
% chmod a+x make sure escript is there, then run as:
% $ ./dderl block_count block_size fsync|nofsync
%
% Example:
% $ ./dderl 10000 4096 fsync
@nickva
nickva / bench.erl
Created June 7, 2016 17:08 — forked from 0xYUANTI/bench.erl
disk_log vs file
-module(bench).
-compile(export_all).
%% Luke Gorrie's favourite profiling macro.
-define(TIME(Tag, Expr),
(fun() ->
%% NOTE: timer:tc/4 does an annoying 'catch' so we
%% need to wrap the result in 'ok' to be able to
%% detect an unhandled exception.
{__TIME, __RESULT} =
#!/usr/bin/env python
import sys, couchdb
DBURL='http://adm:pass@localhost:15984'
V = 'v'*1
def add_view(db):
db['_design/d1'] = {
"views": {
#!/usr/bin/env python
import sys, socket, hashlib
import couchdb
import base64
def setup_db(dbname, user, password, port):
url = 'http://%s:%s@127.0.0.1:%d'% (user, password, port)
print "url:", url
#!/usr/bin/env python
import argparse
import sys
import requests
import couchdb
import random
import string
import uuid
import time
#!/usr/bin/env python
import argparse
import sys
import couchdb
import random
import string
import uuid
import time
import copy
#!/usr/bin/env python
import argparse
import sys
import couchdb
import random
import string
import uuid
import time
import copy