Skip to content

Instantly share code, notes, and snippets.

diff --git a/couchjs/c_src/SConscript b/couchjs/c_src/SConscript
index 757e028..0693f60 100644
--- a/couchjs/c_src/SConscript
+++ b/couchjs/c_src/SConscript
@@ -17,7 +17,10 @@ def require_lib(name):
print 'Could not find required library', name
Exit(1)
-env = Environment(CCFLAGS='-g -O2 -DXP_UNIX')
+env = Environment(CCFLAGS='-g -O2 -DXP_UNIX',
@KlausTrainer
KlausTrainer / BigCouch_read_request_handling.md
Created September 7, 2010 20:30
Handling Read Requests in BigCouch

Handling Read Requests in BigCouch

  • R=1, D=1, S=1: V

  • R=2, D=1, S=1:

    • V
    • 503 Service Unavailable
  • R=2, D=1, S=2:

@KlausTrainer
KlausTrainer / Consistency_in_BigCouch.md
Created September 30, 2010 20:58
Consistency in BigCouch

Consistency in BigCouch

In a BigCouch cluster, there are N replicas, who can either be in the state alive or dead. The case of all replicas being alive is defined as the absence of network partitions, i.e., no message is lost. Network partitions are modeled as total failure of one or more replica. For instance, take a set of network partitions P. For each network partition Pi, all replicas that are located in a different network partition than Pi, are defined as dead.

When there's a read or write request, the request first hits one of the replicas, which is referred to as the leader. The leader starts a voting round, i.e., it forwards the request to all replicas. When the leader receives a response from a replica, it's said that the replica has voted. A response may either contain a document version, or some error code indicating e.g. that the document was not found, or the revision number of a newly created document version.

If at least

@KlausTrainer
KlausTrainer / couchapp-autopush.sh
Created October 23, 2010 12:31
couchapp-autopush
#! /bin/sh -e
inotifywait -m -r --exclude "\.swp$" -e modify . | xargs -n 1 -I {} echo "couchapp push" | bash
@KlausTrainer
KlausTrainer / delete_documents_from_view_result.rb
Created December 27, 2010 19:11
Delete all documents whose id appears in a given view result.
#!/usr/bin/env ruby
require 'rubygems'
require 'rest_client'
require 'json'
require 'cgi'
def bye
abort("Usage: #{$0} [view_url]\nExample: #{$0} http://admin:secret@127.0.0.1:5984/db/_design/ddoc/_view/recent-posts")
@KlausTrainer
KlausTrainer / recover_git_commits.sh
Created March 22, 2011 11:50
recover lost git commits
for i in `git fsck --full | grep "dangling commit" | head | grep -o -E "[0-9a-f]+$"`; do git show $i | vim -; done
#!/usr/bin/env ruby
require 'rubygems'
require 'rest_client'
require 'json'
require 'cgi'
def bye
abort("Usage: #{$0} [log_file(s)] [couch_db_url]\nExample: #{$0} log/* http://admin:secret@127.0.0.1:5984/db")
@KlausTrainer
KlausTrainer / group.erl
Created July 9, 2011 22:12
A native list function for CouchDB that groups view results by its first key element.
fun(Head, {Req}) ->
Fun = fun({Row}, {PrevKey, RowCount}) ->
Key = case couch_util:get_value(<<"key">>, Row) of
K when is_list(K) -> hd(K);
K -> K
end,
Doc = couch_util:get_value(<<"value">>, Row),
DocJson = couch_util:to_binary(couch_util:json_encode(Doc)),
KeyJson = <<"{\"key\":\"",Key/binary,"\"">>,
@KlausTrainer
KlausTrainer / _etc_init_mysql.conf
Created February 8, 2012 09:11
MySQL in tmpfs
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1@ubuntu.com>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@KlausTrainer
KlausTrainer / tls-cipher-check.sh
Created March 30, 2013 21:15
Get a list of a server's supported SSL/TLS ciphers. http://ubuntuforums.org/showthread.php?t=1909914
#!/bin/bash
if ! [ $1 ];
then
echo syntax: $0 host [-v]
exit
fi
if [ "$2" == "-v" ];
then