Skip to content

Instantly share code, notes, and snippets.

/**
* Go one step further and create a `run` function that takes a `generator` function
* as it's only argument
* https://strongloop.com/strongblog/how-to-generators-node-js-yield-use-cases/
*
* a) `run` caches the generator object
* b) contains a private `_next` function that initially starts the generator
* c) `_next` also acts as the callback to the Node callback signature (i.e. (err, data) => {})
* - first time around it obtains the "thunkified" function from `yield`
* - `_next` is then called recursively by the "thunked" function
@dtothefp
dtothefp / thunk.js
Last active December 6, 2015 02:55
/**
* Thunk function returns a function that takes all args except the last `cb` that will return `err` or `data
* @param {Function} fn the function to wrap. ex. fs.readFile
* @param {Object|undefined} ctx the context to call the original `fn` with
* @return {Function} first function to be called with all args except the `cb`
* ex. const read = thunk(fs.readFile);
* const stuffFromTheCb = yield read('/path/to/cool/stuff.js');
*
* ex. const cp = child_process.spawn('./path/to/some/binary', ['--cool', 'stuff']);
* const cpEventThunked = thunk(cp.on, cp); //pass the child process as context or it breaks
function *foo(x) {
var y = 2 * (yield (x + 1));
var z = yield (y / 3);
return (x + y + z);
}
//this "instantiates" (not sure if this is correct??) the generator
//and returns an object with a `next` method
var it = foo( 5 );
@dtothefp
dtothefp / isparta-loader-example.js
Created December 2, 2015 23:01
Isparta Loader for Webpack, Babel 6, and React
//webpack config
export default {
isparta: {
embedSource: true,
noAutoWrap: true,
babel: {
presets: ['es2015', 'stage-0', 'react']
}
},
module: {
@dtothefp
dtothefp / test.js
Last active December 2, 2015 18:30
//specific values for desktop and mobile
export default {
desktop: [ 'chrome', 'ie', 'safari'],
mobile: [ 'iphone', 'android' ]
};
//run all default desktop browsers
export default {
desktop: true
};
var includePaths = require('@hfa/pantsuit').includePaths;
gulp.src('**')
.pipe(sass({includePaths: includePaths}))
.pipe(gulp.dest('./dist'))
//scss
@import 'pantsuit';
@dtothefp
dtothefp / tools.md
Last active November 4, 2015 18:17

Ok added additional logging:

with iso tools using Promise in .server method rather than callback

bin/runner.js LOADING bin/runner.js => BRANCH dfp/update-environmentalization 
DEBUG: Wed, 04 Nov 2015 16:11:02 GMT bin/runner.js [lambda: init] 
DEBUG: Wed, 04 Nov 2015 16:11:02 GMT app/index.js LOADING app/index.js => BRANCH dfp/update-environmentalization 
DEBUG: Wed, 04 Nov 2015 16:11:02 GMT app/index.js Running Isomporphic Tools 
DEBUG: Wed, 04 Nov 2015 16:11:02 GMT app/index.js Running bootstrap#init 
DEBUG: Wed, 04 Nov 2015 16:11:02 GMT app/index.js Requiring lambda function: 1446653462914 
## Most importantly change your keybindings
# system preferences > keyboard >modifier keys => map caps lock to ctrl for all devices you use, i.e. laptop, external keypboard
# download Karabiner https://pqrs.org/osx/karabiner/
# go to "change the ctrl-l key > Ctrl-l to Ctrl-l > when you type Ctrl-l only, send escape" not jk BS to move out of insert mode
# go to "key repeat" tab and crank up your setting for super fast scrolling in vim
#### .tmux.conf
unbind C-b
set -g prefix C-Space
bind Space send-prefix
var $select = $('#id_donate_state');
var lastSelectVal = null;
$select.on('change', function(e) {
var val = e.target.value;
var isUnSelected = val === '' || _.isUndefined(val) || _.isNull(val);
if (isUnSelected) {
this.value = lastSelectedVal;
} else {
lastSelectedVal = val;
@dtothefp
dtothefp / SassMeister-input.scss
Created September 11, 2015 04:22
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.3)
// ----
//Properties are the css property, show value, hide value -- ex. opacity 1 0
@mixin optly--animate($properties, $transition, $enter: true, $leave: true) {
&.optly-hide {
display: none!important;