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
### | |
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
parseTweet = (tweet) -> | |
### | |
This method parses a plain tweet text and outputs html | |
containing links for all @usernames, #hashtags and links in it. | |
@param {String} tweet | |
@param {String} - html output | |
### | |
links = [ | |
/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g | |
(url) -> |
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 alterResponse = function (opts) { | |
/** | |
* Function modifies $.ajax responses | |
* by allowing you to modify ajax response object before each bound success callback. | |
* Currently it supports only `success` callbacks, `error` and `complete` support to come. | |
* @param {RegExp} opts.urlMatch - use this to filter calls by url | |
* @param {String} opts.dataType - Optional - use this to filter calls by response type | |
* @param {Function} opts.successWrapper - function that gets called before each ajax callback | |
* - function (options:Object, originalOptions:Object, jqXHR:jQuery.XHR, originalSuccess: Function) | |
*/ |
This bookmarklet can be used to keep track of global variables attached to window.
It displays the user-defined global variables by comparing all properties attached on current window to all standard properties extracted from an empty iframe.
To install, create a new bookmark in your bookmark bar and copy-paste the contents of listGlobals.bookmarklet
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 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); |
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; | |
}; |
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
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); |
NewerOlder