Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@fdmanana
fdmanana / gist:1199903
Created September 7, 2011 06:21
Erlang OTP R14B, Mac OS X Lion 64bits and XCode 4.1

Issue

On Mac OS X Lion (64bits at least), we get random "Bus error 10" (or "Segmentation fault: 11") crashes if init:restart/0 is called and the crypto application is loaded. Why? XCode 4.1 ships an OpenSSL version that deprecates many functions used by OTP's crypto NIF (lib/crypto/c_src/crypto.c).

Example:

$ erl
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@max-mapper
max-mapper / readme.md
Created September 28, 2011 02:01
SLEEP - syncable.org

Your API does REST, but can it SLEEP?

SLEEP (Syncable Lightweight Event Emitting Persistence) is an emerging standard for distributed data sync using HTTP and JSON. A generalized version of CouchDB's much lauded built-in replication, SLEEP extends the REST architecture to define a way in which databases can offer syncable JSON APIs that foster open data innovation by allowing developers to replicate entire databases over the net.


SLEEP comes from the Apache CouchDB project which is now widely known for it's multi-master streaming HTTP + JSON replication. This is possible in part because of the CouchDB _changes feed, which is a particular API that lets you see if there have been any changes made to the database since last time you synchronized. CouchDB can efficiently implement the _changes feed because of one subtle difference between it and most other databases: it stores a history of all changes that happen to the database, including deletes.

If you synchronize data from a remote source and then the

@dch
dch / couchdocs_refresh.md
Created November 22, 2011 14:04
CouchDB Doc Refresh

Hi devs,

Over the last two years we've discussed improving our documentation, website, and wiki. We have discussed several designs ad mortem[1]…[5], and while the wiki has evolved substantially, not much else has changed.

This proposal summarises a consensus direction, and puts forward an approach that should allow us to improve docs in incremental stages with the usual peer review process for the actual patches/changes.

@dch
dch / couchdb-ec2-install.sh
Created November 30, 2011 12:30 — forked from msmith/couchdb-ec2-install.sh
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"
@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() ->
@eleclerc
eleclerc / Solarized (Dark).tmTheme
Created February 25, 2012 00:38
Solarized theme (dark & light) with markdown support for Sublime Text 2 editor
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Solarized (dark)</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@codification
codification / proc.clj
Created March 6, 2012 08:10
Clojure asynchronous process
(ns proc
(:import [java.lang ProcessBuilder])
(:use [clojure.java.io :only [reader writer]]))
(defn spawn [& args]
(let [process (-> (ProcessBuilder. args)
(.start))]
{:out (-> process
(.getInputStream)
(reader))

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.