Skip to content

Instantly share code, notes, and snippets.

Ryan Quinn ryanwilliamquinn

Block or report user

Report or block ryanwilliamquinn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View streams
const fs = require('fs')
// app.js has one line: console.log('this is app.js')
const appReadstream = fs.createReadStream('files/app.js')
// index.js has one line: console.log('this is index.js')
const indexReadstream = fs.createReadStream('files/index.js')
const out1 = fs.createWriteStream('files/outindexfirst.js')
const out2 = fs.createWriteStream('files/outappfirst.js')
indexReadstream.pipe(appReadstream.pipe(out1))
appReadstream.pipe(indexReadstream.pipe(out2))
View synonyms
'use strict';
var bpromise = require('bluebird'),
request = require('request'),
_ = require('lodash');
/* fn takes a phrase - may the force be with you
which word has the most synonyms */
var key = "TZlKw4gd1qFQhA2CbMLa";
View gist:434d6d5d0f921618af08
var BPromise = require('bluebird');
BPromise.try(function () {
console.log(1);
console.log(x.y);
console.log(2);
}).catch(function (err) {
console.log('caught an error with try', err);
});
@ryanwilliamquinn
ryanwilliamquinn / Function.bind.bind
Created Jul 29, 2014
sorting out function.bind.bind
View Function.bind.bind
1. Function.bind.bind(Function.call) = Function.call.bind
2. Function.call.bind(someOtherFn) = someOtherFn.call
3. someOtherFn.call(newThisValue)
First you set up the 'binder' function. Note that 'binder' is not an official term, I just made it up:
var bb = Function.bind.bind(Function.call); // bb ends up as a function: Function.call.bind
then you can use it like so:
var boundfn = bb(someOtherFn); // boundfn is now a function: someOtherFn.call
You can’t perform that action at this time.