This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = 'yello world' | |
const upperFirst = pipe( | |
juxt([pipe(head, toUpper), tail]), | |
join('')) | |
upperFirst(a) | |
// => 'Yello world' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```json | |
"ava": { | |
"require": "babel-register", | |
"babel": "inherit" | |
} | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { padStart } = require('lodash') | |
const pad0 = e => padStart(e, 2, '0') | |
const date = new Date() | |
const today = [ | |
date.getUTCFullYear(), | |
pad0(date.getUTCMonth() + 1), | |
pad0(date.getUTCDate()) | |
].join('.') | |
// => 2018.01.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dotPath = R.useWith(R.path, [R.split('.')]) | |
const propsDotPath = R.useWith(R.ap, [R.map(dotPath), R.of]) | |
var obj = { | |
a: { b: { c: 42 } }, | |
d: 2 | |
} | |
propsDotPath(['a.b.c', 'd'], obj) | |
// => [ 42, 2 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (module.parent) { | |
return | |
} | |
const readline = require('readline') | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
// terminal: false // isTTY | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $scrolledelement = document.getElementById("left"); | |
$scrolledelement.scrollTop = localStorage.scrollPosition; | |
$scrolledelement.onscroll = function() { | |
$pos = $scrolledelement.scrollTop | |
localStorage.setItem("scrollPosition", $pos); | |
$outelement.innerHTML = localStorage.scrollPosition; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (require.main === module) { | |
console.log('Called from bash') | |
} else { | |
console.log('Called as a module') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// here condR === undefined | |
const falsy = (condL, condR) => condL !== condR; | |
const map = (fn, [first, ...rest]) => | |
(falsy(first) && []) && [fn(first), ...map(fn, rest)]; | |
console.log(':)', map((x) => (x + x), [1, 2, 3])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// char => char | |
function closingTag(char) { | |
return { | |
'(': ')', | |
'{': '}', | |
'[': ']' | |
}[char]; | |
} | |
// char => boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function match_brackets(str){ | |
var stack = [], | |
lookup = { | |
//key : value pairs | |
'(' : ')', | |
'{' : '}', | |
'[' : ']', | |
}, | |
_keys = Object.keys(lookup), |