Skip to content

Instantly share code, notes, and snippets.

One thing you could do is have something like, say Film.js:

exports.toString = `
  type Film {
    characters(): [Character]
  }
`

exports.characters = function (film, args) { ... }
@matthewmueller
matthewmueller / index.js
Created October 10, 2015 09:24
redux reduxed
var Debug = require('redux-debug')
var debug = require('debug')
var assign = require('object-assign')
var thunk = require('redux-thunk')
var Redux = require('redux')
function store_enhancer (options) {
return function (next) {
return function (reducer, initial_state) {
@matthewmueller
matthewmueller / lazy-load-redux-action.js
Last active October 9, 2015 01:56
Non-working lazy-load redux action. The reason it doesn't work is because webpack cannot resolve dynamic paths (without assistance). Makes sense to create a loader like `react-proxy-loader` that will generate this. Then you can stick this in middleware and be done.
/**
* Module Dependencies
*/
var relative = require('path').relative
/**
* Action
*/
@matthewmueller
matthewmueller / promise.js
Last active August 29, 2015 14:27
Runthrough of Promise control flow
var a = new Promise(function (resolve, reject) {
reject(1)
})
function b_success() {
console.log('b: success', err);
// not called...
@matthewmueller
matthewmueller / inject.js
Created May 1, 2015 06:18
Testing injection mad science
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');

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 / flow.js
Created November 25, 2014 01:32
Generator Flow
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
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@matthewmueller
matthewmueller / gulpnduo.js
Last active August 29, 2015 14:06
Duo gulp integration
/**
* 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');
@matthewmueller
matthewmueller / flow-based-programming.md
Last active August 29, 2015 14:05
Some quick notes on flow-based programming

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: