Skip to content

Instantly share code, notes, and snippets.

View dscape's full-sized avatar

Nuno Job dscape

View GitHub Profile
@BenHall
BenHall / Installing_0_11_On_Ubuntu
Created April 3, 2010 19:50
Upgrading Couchdb 0.10 to 0.11
sudo aptitude install automake spidermonkey-bin autoconf subversion-tools libtool help2man build-essential erlang erlang-manpages libicu38 libmozjs-dev wget libicu-dev libreadline5-dev checkinstall
sudo apt-get install libcurl4-openssl-dev
wget http://mirrors.enquira.co.uk/apache/couchdb/0.11.0/apache-couchdb-0.11.0.tar.gz
tar -xzvf apache-couchdb-0.11.0.tar.gz
cd apache-couchdb-0.11.0
./configure --bindir=/usr/bin --sbindir=/usr/sbin --localstatedir=/var --sysconfdir=/etc
make
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@cpinto
cpinto / mustache_xpath_partials.js
Created October 4, 2010 18:21
Read the top comments
/*
* Q: What is this?
* A: A sample file that uses mustache to render a single html tmeplate (including partials) on the serverside but keeps those partials intact so that they can be used by the client-side as well (ie. browser)
*
* Q: How is this useful?
* A: To you, I have little idea. I'm doing this because I want to be able to fully render a page on the server and then refresh parts of it on the client, while reusing the widget presentation code. As the widget code is in the file, I just have to bring in mustache.js, fetch new data, and have it render the parts I need to update. And I'd like to keep it all in a single file also.
*
* Q: Isn't that template code broken?
* A: Yes. I'll come back to it as I plan to patch Mu to support xpath partials natively.
* */
@fdmanana
fdmanana / gist:832610
Created February 17, 2011 20:27
The CouchDB replicator database

1. Introduction to the replicator database

A database where you PUT/POST documents to trigger replications and you DELETE to cancel ongoing replications. These documents have exactly the same content as the JSON objects we used to POST to /_replicate/ (fields "source", "target", "create_target", "continuous", "doc_ids", "filter", "query_params".

Replication documents can have a user defined "_id". Design documents (and _local documents) added to the replicator database are ignored.

The default name of this database is _replicator. The name can be changed in the .ini configuration, section [replicator], parameter db.

2. Basics

@indexzero
indexzero / git-commit-prefixes
Created April 20, 2011 22:09
Short list of Git commit prefixes used at Nodejitsu
[api]: New apis / changes to apis
[test]: Update test/* files
[dist]: Changes to submodules, version bumps, updates to package.json
[minor]: Small changes
[doc]: Updates to documentation
[ux]: Updates to UX
[fix]: Bug fixes
[bin]: Update binary scripts associated with the project
[merge]: Resolved git merge from upstream or otherwise
[refactor]: Refactor of existing code with no external API changes
var start = Date.now()
http = require("http")
console.error("%d scheduling nextTick", Date.now() - start)
process.nextTick(function interval(){
process.nextTick(interval)
process.stderr.write(".")
var STATUS =
{ VALUE: 0 // now comes an object, array, string, or whatever else you can imagine
, ARRAY: 1
, STRING: 2
, NUMBER: 3
, TRUE: 4
, FALSE: 5
, NULL: 6
, OBJECT: 7
}
@creationix
creationix / output.log
Created December 21, 2011 15:38
sample usage for jsonparse.
'bar'
{ foo: 'bar' }
'Hello'
'World'
[ 'Hello', 'World' ]
1
2
3
[ 1, 2, 3 ]
[ [ 'Hello', 'World' ], [ 1, 2, 3 ] ]
@indexzero
indexzero / README.md
Created January 14, 2012 04:38
npmcount output for groups of node.js thought leaders
@max-mapper
max-mapper / index.js
Created February 5, 2012 22:29
node bufferedstream proxy
var request = require('request');
var BufferedStream = require('morestreams').BufferedStream;
function requestHandler(req, res) {
// immediately pipe the incoming request into a paused bufferedstream.
// if you try to pipe after a nextTick it won't work because data starts
// arriving immediately
var bufferedStream = new BufferedStream
bufferedStream.pause()
req.pipe(bufferedStream)