Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@jhs
jhs / discussion.md
Created January 8, 2012 04:08
Log the conflict winner comparison

Conflict winners are chosen dynamically, every time a request for the document arrives. The revision tree is sort of like a git repository: most updates are based on a parent update. In general, you have a tree of changes, but usually it works out to a linear linked list.

Anyway, the winner is the version with the longest revision history. (That is arbitrary but deterministic, so two couches with the same revision trees will pick the same winner.)

couch_doc:to_doc_info_path does the main job: converting the revision tree into an array of paths from root to leaf. It returns this array sorted, with the longest path first. The diff here will print a log message every time the comparison function is called by lists:sort().

The execution path basically goes:

  1. couch_http_db:db_doc_req()
  2. couch_db:open_doc()
@evanmiller
evanmiller / rr_db.erl
Created January 10, 2012 14:29
Scattered remains of Chicagosaurus Rex
-module(rr_db, [Server, PhotoRoot]).
-define(MIME_TYPE, "application/json").
-compile(export_all).
init() ->
inets:start(),
inets:start(httpc, [{profile, database}]).
reset() ->
@divadrei
divadrei / gist:2511533
Created April 27, 2012 18:22
setup iterm2 compatible tmux on debian6
echo "deb http://backports.debian.org/debian-backports squeeze-backports main contrib" >> /etc/apt/sources.list
echo "deb http://ftp.de.debian.org/debian sid main" >> /etc/apt/sources.list
apt-get update
apt-get upgrade
apt-get install libevent-dev autoconf pkg-config gcc g++ libncurses5-dev make
mkdir tmux
cd tmux
wget "http://iterm2.googlecode.com/files/tmux-for-iTerm2-20120203.tar.gz"
tar -zxf tmux-for-iTerm2-20120203.tar.gz
cd tmux-for-iTerm2-20120203/
@jlouis
jlouis / t.erl
Created June 12, 2012 19:28
Percept example
-module(t).
-export([start/0, go/0, analyze/0, server/0]).
start() ->
percept:profile("test.dat", {t, go, []}, [procs]).
go() ->
Led = led:start(1),
Led1 = led:start(1),
@dch
dch / GITHUB-COMPARE-LINKS.md
Created July 2, 2012 09:04 — forked from mbbx6spp/GITHUB-COMPARE-LINKS.md
This Gist is worth a million beers. So buy me one (or send me a really cool t-shirt, make sure it is REALLY cool though)! :)
@jimklo
jimklo / a-spidermonkey-test.js
Created July 2, 2012 22:43
OpenPGP.js with SpiderMonkey example
// make check for navigator properties not fail.
var navigator = {};
// support some basic HTML5 localStorage operations
function _localStorage() {
this.ls = {};
this.getItem = function(key) {
@cdkamat
cdkamat / emacs-format-file.el
Created October 18, 2012 07:25
Emacs function to batch untabify and reindent
;;; File: emacs-format-file
;; http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html
;; to be run as --
;; emacs -batch *.[ch] -l ~/src/scripts/emacs-format-file -f emacs-format-function
(defun emacs-format-function ()
"Format the whole buffer."
(if (< 1 (count-windows))
(delete-other-windows (selected-window)))
(catch 'tag
; vim: filetype=clojure
(logging/init :file "riemann.log")
(tcp-server)
(udp-server)
(ws-server)
(periodically-expire 10)
@rjcorwin
rjcorwin / simple-file-attachment-for-couchdb.html
Created November 14, 2012 20:03
A very basic example in Javascript of how to attach a file to a CouchDB document. This will work wether or not the Document ID you define exists.
<!DOCTYPE html>
<! --
A very basic example in Javascript of how to attach a file to a CouchDB document. This will work wether or not the Document ID you define exists.
Log in at /_utils, upload this file to a document, and then view it for your own uploader. See the code for comments. ajaxSubmit() is the magic that attaches
as long as the Couch Doc exists because you can't submit a new Couch Document with an attachment.
by @rjsteinert http://rjsteinert.com
-->
<html xmlns="http://www.w3.org/1999/xhtml">
Carbon relay - performance
alias(color(sumSeries(group(carbon.agents.*.updateOperations)), "blue"),"Updates")
alias(color(sumSeries(group(carbon.agents.*.metricsReceived)), "green"), "Metrics Received")
alias(color(sumSeries(group(carbon.agents.*.committedPoints)),"orange"),"Committed Points"))
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.pointsPerUpdate)),"yellow")),"PPU")
alias(secondYAxis(color(averageSeries(group(carbon.agents.*.cpuUsage)),"red")),"CPU (avg)")
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.creates)),"purple")),"Creates")
Metrics received
carbon.agents.*.metricsReceived