Skip to content

Instantly share code, notes, and snippets.

View update-resolv-conf
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
# Used snippets of resolvconf script by Thomas Hood <>
# and Chris Hanson
# Licensed under the GNU GPL. See /usr/share/common-licenses/GPL.
View gist:4546241
From b3895efe1cff61182dfe76fed25c00d6cb590a71 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana <>
Date: Wed, 16 Jan 2013 10:18:36 +0000
Subject: [PATCH] Fix memory leak in efile_drv
When the port's stop callback (file_stop) is invoked, we
schedule a file close task (FILE_CLOSE_ON_PORT_EXIT) that
will be picked up by an async thread, to avoid blocking the
scheduler thread for too long. However, because after this
task is executed the port is not alive anymore, its callback
fdmanana / gist:2160061
Created Mar 22, 2012
OS X 64bits release target
View gist:2160061
From 0a8c3023b5c29463b58d09fc574c5f8f3bd36b99 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana <>
Date: Fri, 23 Mar 2012 13:48:15 +0000
Subject: [PATCH] Add support for Mac OS X 64bit builds with GYP
Note that in order to build for 64bits mode, you'll have
to specify the target architecture explicitely, the default
is still 32bits for Mac OS X.
Example with make:
View gist:1930807
Before COUCHDB-1186
fdmanana 23:21:05 ~/git/hub/slow_couchdb (master)> docs=500000 batch=5000 ./ wow.tpl
Server: CouchDB/1.2.0a-a68a792-git (Erlang OTP/R14B03)
[INFO] Created DB named `db1'
[INFO] Uploaded 5000 documents via _bulk_docs
[INFO] Uploaded 5000 documents via _bulk_docs
View gist:1930804
# comment lines start with a sharp (#)
"type": "#{pick(human,orc,elf,dwarf)}",
"category": "#{pick(warrior,assassin,thief,wizard)}",
"ratio": #{random_int(0, 1)}.#{random_int(0, 9)},
"level": #{random_int(1, 20)},
"data1": "#{random_string(40)}",
"data2": "#{random_string(50)}",
"data3": "#{random_string(35)}",
fdmanana / gist:1343454
Created Nov 6, 2011
Erlang/OTP gen_server simplified API, basics
View gist:1343454

Client side API

Start a gen_server programmatically

gen_server:start(ModuleName, Arguments, Options) -> {ok, Pid} | {error, Reason}

gen_server:start(ServerName, ModuleName, Arguments, Options) -> {ok, Pid} | {error, Reason}

fdmanana / gist:1199903
Created Sep 7, 2011
Erlang OTP R14B, Mac OS X Lion 64bits and XCode 4.1
View gist:1199903


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).


$ erl
fdmanana / user_default.erl
Created Aug 24, 2011 — forked from dustin/user_default.erl
Helpful stuff for figuring out what's going on in there...
View user_default.erl
-export([proc_count/1, proc_count/0,
proc_mem/2, proc_mem/1, proc_mem/0,
matching/2, matching/1]).
proc_info(X, Info) ->
case proplists:get_value(X, Info) of
{proc_lib, init_p, _} ->
fdmanana / gist:1092157
Created Jul 19, 2011
Erlang skew data structure (priority queue for functional languages)
View gist:1092157
-export([new/0, size/1, in/3, out/2, min/1]).
-define(null, []).
new() ->
size(?null) ->
fdmanana / gist:1034294
Created Jun 19, 2011
replicator always retry on attachment streaming failure
View gist:1034294
diff --git a/src/couchdb/couch_api_wrap.erl b/src/couchdb/couch_api_wrap.erl
index aa481c7..63e607a 100644
--- a/src/couchdb/couch_api_wrap.erl
+++ b/src/couchdb/couch_api_wrap.erl
@@ -597,7 +597,7 @@ doc_from_multi_part_stream(ContentType, DataFun) ->
started ->
exit(Parser, kill),
- restart_remote_open_doc_revs();
+ restart_att_streaming();
You can’t perform that action at this time.