Skip to content

Instantly share code, notes, and snippets.

Matthew Mueller matthewmueller

Block or report user

Report or block matthewmueller

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
@matthewmueller
matthewmueller / gen.js
Last active Aug 29, 2015
understanding generators
View gen.js
/**
* Excerpt from: Analysis of generators and other async patterns in node
* URL: http://spion.github.io/posts/analysis-generators-and-other-async-patterns-node.html#a-gentle-introduction-to-generators
*
* When next is invoked, it starts the execution
* of the generator. The generator runs until it
* encounters a yield expression. Then it pauses
* and the execution goes back to the code that
* called next.
@matthewmueller
matthewmueller / flow-based-programming.md
Last active Aug 29, 2015
Some quick notes on flow-based programming
View flow-based-programming.md

Flow-based Programming is all about reacting to event sources. Event sources in the browser might be:

  • A DOM event
  • AJAX call
  • Onload initial data passing
  • Local DB fetch (local storage, indexdb)

In order to build larger systems, nodes need to be chainable and flows need to be composable. I think the best way to do this in Javascript may look something like this:

@matthewmueller
matthewmueller / gulpnduo.js
Last active Aug 29, 2015
Duo gulp integration
View gulpnduo.js
/**
* Module Dependencies
*/
var debug = require('debug')('lapwing:build');
var relative = require('path').relative;
var resolve = require('path').resolve;
var extname = require('path').extname;
var uglify = require('gulp-uglify');
var Batch = require('better-batch');
View flow.js
function *something(msg) {
msg += yield msg; // yields "a", returns "b"
msg += yield msg; // yields "ab", returns "c"
msg += yield msg; // yields "abc", returns "d"
return msg; // returns "abcd"
}
var gen = something('a');
console.log(gen.next().value); // a
console.log(gen.next('b').value); // ab
View keybase.md

Keybase proof

I hereby claim:

  • I am matthewmueller on github.
  • I am matthewmueller (https://keybase.io/matthewmueller) on keybase.
  • I have a public key whose fingerprint is BFED 49E4 15E0 9C6E C008 3E7F 490F 7168 F0D0 85EB

To claim this, I am signing this object:

@matthewmueller
matthewmueller / inject.js
Created May 1, 2015
Testing injection mad science
View inject.js
var script = document.currentScript;
var sheet = script.getAttribute('sheet');
var el = document.createElement('div');
el.textContent = 'hi world!';
script.parentNode.replaceChild(el, script);
console.log('lol');
@matthewmueller
matthewmueller / promise.js
Last active Aug 29, 2015
Runthrough of Promise control flow
View promise.js
var a = new Promise(function (resolve, reject) {
reject(1)
})
function b_success() {
console.log('b: success', err);
// not called...
@matthewmueller
matthewmueller / Underscore templating with Express
Created Mar 25, 2011
Javascript: Use underscore templating to parse HTML files in Express
View Underscore templating with Express
// Express with Underscore templating
app.register('.html', {
compile : function(str, options) {
return function(locals) {
return _.template(str, locals);
};
}
});
@matthewmueller
matthewmueller / gist:2018660
Created Mar 11, 2012
Javascript: step(fns...) - Tiny, flexible step function for running async functions in series
View gist:2018660
/*
Step - tiny, but flexible step library
Usage:
var first = function(next) {
...
return next(null, name, date);
}
@matthewmueller
matthewmueller / gist:2018609
Created Mar 11, 2012
Javascript: after(len) - counter used for async iteration
View gist:2018609
/*
Counter used for async calls
Example:
var files = ['a', 'b'];
finished = after(files.length);
finished() // false
finished() // true
You can’t perform that action at this time.