This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
Utility to add setters and getters to a class in coffeescript. | |
@see https://github.com/thingdom/node-neo4j/blob/master/lib/PropertyContainer._coffee | |
### | |
class A | |
get = (props) => | |
@::__defineGetter__ name, getter for name, getter of props | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert = (require 'chai').assert | |
Q = require 'q' | |
util = require './util' | |
describe '.any()', -> | |
it 'should fail when no promise resolves', (done) -> | |
fns = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<title> host </title> | |
<meta charset="utf-8"> | |
<div id="container">host.html</div> | |
<script src="jquery-1.6.1.js"></script> | |
<script src="jquery.tinypubsub.js"></script> | |
<script src="postmessage.js"></script> | |
<script src="xPubSub.js"></script> | |
<script> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// js barrier, waits for all events to be fired before executing the callback | |
// dependencies: | |
// 1. jquery 1.4.2+ - jquery.com | |
// 2. ben alman's tiny jquery pub/sub - https://gist.github.com/661855 | |
(function($){ | |
$.barrier = function( evs , callback ){ | |
var events = evs.split(' ') ; | |
var flags = {} ; | |
var collector = {} ; | |
$.each( events , function( i, ev ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newDefered = function(){ | |
var state = 0 ; // 0 - unresolved, 1 - resolved, 2 - rejected | |
var resolveCallbacks = [] ; | |
var resolveArgs = [] ; | |
var rejectCallbacks = [] ; | |
var rejectArgs = [] ; | |
var execute = function( callbacks, args ){ | |
while( callbacks.length !== 0 ){ | |
callbacks.shift().call( {}, args ) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//deps | |
var mongoose = require( 'mongoose' ); | |
var Schema = mongoose.Schema; | |
var ObjectId = mongoose.Schema.ObjectId; | |
//config | |
var mongo = require( './../conf.js' ).mongo ; | |
mongo.database = 'learn'; | |
//connect to mongo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//register a *simple* html renderer | |
app.register( '.html', { | |
compile: function( str, options ){ | |
return function( locals ){ | |
return str; | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var zlib = require('zlib'); | |
// A two-way passthrough Stream, made by @felixge | |
// https://github.com/felixge/node-passthrough-stream/blob/master/lib/passthrough_stream.js | |
var PassthroughStream = function () { | |
this.writable = true; | |
this.readable = true; | |
} | |
util.inherits(PassthroughStream, streams.Stream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stores arrays binded to keys in localstorage | |
(function (win) { | |
var isStorage = function (obj) { | |
return (Object.prototype.toString.call(obj) === '[object Storage]'); | |
}; | |
var decode = function (str) { | |
try { | |
var arr = JSON.parse(str); | |
if (!Array.isArray(arr)) return false; | |
return arr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jquery style `extend` work in ES5 compatible envs | |
var extend = function (obj) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
args.forEach( function (source) { | |
for (var prop in source) | |
if (source.hasOwnProperty(prop)) obj[prop] = source[prop]; | |
}); | |
return obj; | |
}; |
OlderNewer