This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
(function(){ | |
var cache = {}; | |
this.tmpl = function tmpl(str, data){ | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? | |
cache[str] = cache[str] || |
This file contains hidden or 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 hidden or 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 hidden or 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; | |
}; |
This file contains hidden or 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 streams = require('stream'); | |
var events = require('events'); | |
var util = require('util'); | |
var csv = require('csv'); | |
var InputStream = function () {}; | |
util.inherits(InputStream, streams.Stream); | |
var OutputStream = function () {}; | |
util.inherits(OutputStream, events.EventEmitter); |
OlderNewer