Skip to content

Instantly share code, notes, and snippets.

➜ ~ cat ~/.gitconfig
[user]
name = Robert Newson
email = [email protected]
➜ cl-test git:(master) ✗ curl 'localhost:5984/_fti/local/db1/_design/couchapp/idx' -d 'q=*:*' -sv
* Adding handle: conn: 0x7f9761000000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f9761000000) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 5984 (#0)
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5984 (#0)
> POST /_fti/local/db1/_design/couchapp/idx HTTP/1.1
@rnewson
rnewson / git-wrapper.py
Last active August 29, 2015 14:07
git wrapper to optimize network use by maintaining a local mirror
#!/usr/bin/env python
# Put me in /usr/local/bin for magic caching (but set cache_root too!)
# Note this expects to run inside Jenkins, so remove line 20 if you don't do that.
import os
import sys
import urlparse
real_git = '/usr/bin/git'
cache_root = '/gitdata'
global
maxconn 10000
spread-checks 5
defaults
mode http
log global
option httplog
balance roundrobin
option forwardfor
global
maxconn 10000
spread-checks 5
defaults
mode http
log global
monitor-uri /_haproxy_health_check
option httplog
balance roundrobin
[info] [<0.107.0>] 127.0.0.1 - - 'GET' /db1/_changes 200
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Server: CouchDB/1.0.4 (Erlang OTP/R12B)
< Etag: "DC7ZSEOOFMFCH8JS01Q9DCGA"
< Date: Mon, 06 Oct 2014 20:07:17 GMT
< Content-Type: text/plain;charset=utf-8
< Cache-Control: must-revalidate
{"results":[
{"seq":1,"id":"doc1","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
@rnewson
rnewson / gist:d51a0118908b7a175671
Last active August 29, 2015 14:07
db-level security for couchdb / couchdb-lucene
commit 73a15ab0cab9510d3649d6c0ca23f884139eb631
Author: Robert Newson <[email protected]>
Date: 2014-10-06 11:03:01 +0100
Support db-level proxy handling
diff --git a/src/couchdb/couch_httpd_proxy.erl b/src/couchdb/couch_httpd_proxy.erl
index dec3f55..fbfbf76 100644
--- a/src/couchdb/couch_httpd_proxy.erl
+++ b/src/couchdb/couch_httpd_proxy.erl
✗ curl 'localhost:15984/db-to/frnewson5?new_edits=false' -XPUT -T mp.txt -H'content-type:multipart/related; boundary=9b680d467d7e8f4fcea8c57605289b79' -sv
@rnewson
rnewson / gist:d7bbe1d32e91103ce6c9
Created September 12, 2014 08:35
Don't swallow other people's replies
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index d0b4ac9..f292621 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -184,7 +184,7 @@ get_shard([#shard{node = Node, name = Name} | Rest], Opts, Timeout, Factor) ->
{ok, Db};
{Ref, {ok, {unauthorized, _} = Error}} ->
throw(Error);
- _Else ->
+ {Ref, _Else} ->
diff --git a/src/ioq.erl b/src/ioq.erl
index 4983b73..b761a0b 100644
--- a/src/ioq.erl
+++ b/src/ioq.erl
@@ -37,7 +37,12 @@ start_link() ->
call(Fd, Msg, Priority) ->
Request = #request{fd=Fd, msg=Msg, priority=Priority, from=self()},
- gen_server:call(?MODULE, Request, infinity).
+ try