Skip to content

Instantly share code, notes, and snippets.

View guybrush's full-sized avatar

Patrick guybrush

View GitHub Profile
  • 4 space indentation

  • 80 character max per line

  • if's always have space before braces

  • if's always have braces

      if () {
        return;
      }
    
  • exception: if (err) throw err;

var Seq = require('seq')
, data = ['a', 'b', 'c']
function incr(x, cb) {
cb(null, ++x)
}
function get(x, cb) {
if (x == 'all') cb(null, data)
else if (!data[x]) cb("data["+x+"] doesn't exist")
var chain = require('seq')()
for (var i=0; i<3; i++) {
chain.seq(function(){
console.log(i) // prints 3 .. wtf?!
})
}
var data = ['a', 'b', 'c']
function get(x, cb) {
if (x == 'all') cb(null, data)
else if (!data[x]) cb("data["+x+"] doesn't exist")
else cb(null, data[x])
}
require('step')(
function(){
@guybrush
guybrush / client.html
Created January 12, 2011 22:04
client
<html>
<head></head>
<body>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
var arr = {
str1 : 'test'
, str2 :'test2'
, array1 : ['12','13','14']
#!/bin/sh
echo
echo "**** Pushing changes to github"
echo
git push master github
exec git-update-server-info
@guybrush
guybrush / unhosted_notepad.md
Created January 28, 2011 05:40
unhosted notepad

unhosted notepad

Unhosted is an approach to break the one-to-one link between software publisher and hostage-providers by separating the source-code (client-side, hosted by anyone anywhere) from the data (persistent storage preferably owned by the user of the webapp).

modules

A module is a software which provides a client-side interface to communicate

@guybrush
guybrush / performance-parser.js
Created January 30, 2011 04:53
testing performance of parsing xml/html with nodejs
//
// this is about parsing-performance of xml/html-parsers
// to be more precisely, i just want to look for specific nodes/attributes
//
// i am testing
//
// * (htmlparser)[https://github.com/tautologistics/node-htmlparser]
// * (html5)[https://github.com/aredridel/html5]
// * (sax)[https://github.com/isaacs/sax-js]
// * (jsdom)[https://github.com/tmpvar/jsdom] + sizzle/jquery
//
// CouchEmitter
//
// this will listen for _changes of a given couchdb
// idea is shameless stolen from
// https://github.com/mikeal/dbemitter/blob/master/main.js
(function(exports, $, EventEmitter, undefined){
exports.CouchEmitter = CouchEmitter