Skip to content

Instantly share code, notes, and snippets.

@a-laughlin
a-laughlin / index.html
Created March 2, 2016 17:42 — forked from anonymous/index.html
JS Bin 3 ways to do Promise.all(asyncVals) // source http://jsbin.com/wegoha/14
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="3 ways to do Promise.all(asyncVals)">
<script src="https://cdn.rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
[Enter steps to reproduce below:]
1. ...
2. ...
**Atom Version**: 1.6.1
**System**: Mac OS X 10.9.5
**Thrown From**: [keybinding-resolver](https://github.com/atom/keybinding-resolver) package, v0.33.0
[Enter steps to reproduce below:]
1. ...
2. ...
**Atom Version**: 1.6.1
**System**: Mac OS X 10.9.5
**Thrown From**: Atom Core
[Enter steps to reproduce below:]
1. ...
2. ...
**Atom Version**: 1.6.1
**System**: Mac OS X 10.9.5
**Thrown From**: Atom Core
[Enter steps to reproduce below:]
1. ...
2. ...
**Atom Version**: 1.6.1
**System**: Mac OS X 10.9.5
**Thrown From**: Atom Core
@a-laughlin
a-laughlin / instababel.sh
Created September 18, 2016 18:40
install babel and transpile a directory of files appropriate for your specified environment (e.g., node 6, ie9+ browsers)
function instababel(){
outputEnv=$1
destDir=$2
srcDir=$3
if [[ ! $3 ]]; then
echo "Must call as $ instababel <outputEnv> <srcDir> <destDir>"
echo "outputEnv options are node6 & ie9+"
return;
fi
@a-laughlin
a-laughlin / lodash_reduce_experiments.md
Last active October 21, 2016 02:20
lodash reduce experiments for composing values

###Results from running function at bottom in console: ###Lodash 4.10 reduce vs vanilla reduce

_.reduce(['a','b','c'],(last,next)=>(last+next)) vs ['a','b','c'].reduce((last,next)=>(last+next))
// abc vs abc
_.reduce(['a','b','c'],(last,next)=>(last+next),undefined) vs ['a','b','c'].reduce((last,next)=>(last+next),undefined)
// undefinedabc vs undefinedabc
_.reduce(['b','c'],(last,next)=>(last+next),'a') vs ['b','c'].reduce((last,next)=>(last+next),'a')
// abc vs abc
_.reduce(['a'],(last,next)=&gt;(last+next),undefined) vs ['a'].reduce((last,next)=&gt;(last+next),undefined)
@a-laughlin
a-laughlin / composeWalker.js
Last active March 9, 2018 08:45
composeWalker - Composable Graph Walker
// Copyright 2017 Adam Laughlin (github.com/a-laughlin).
// License - MIT
const _ = require('lodash');
// Temporarily abstracting this to a gist from private functions in another repo.
// Eventually destined for its own repo with documentation and testing given its usefulness.
// TBD notes are scattered through the code, and need creation as GH issues on transfer.
/**
* composeWalker
(function(){
// problem 1
const curryJoin = a => b =>`${a}-${b}`;
// test 1 (expected: 'foo-bar')
console.log(curryJoin('foo')('bar'));
// problem 2 (not the cleanest solution, but not bad for hand-written with a 5 minute time constraint)
function pickGroup(groupsCollection){
@a-laughlin
a-laughlin / pre-commit
Created March 15, 2017 19:13 — forked from broofa/pre-commit
Git pre-commit hook that runs `eslint` with the `--fix` option to fix up issues where possible, and adds "fix"ed files into the commit
#!/bin/bash
cd "$(git rev-parse --show-toplevel)"
ESLINT="node_modules/.bin/eslint"
pwd
if [[ ! -x "$ESLINT" ]]; then
printf "\t\033[41mPlease install ESlint\033[0m (npm install eslint)\n"
exit 1
fi