sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh
// Either monad using discriminated unions | |
export type Either<L, R> = | |
| { type: "left"; value: L } | |
| { type: "right"; value: R }; | |
export function Left<L, R>(a: L): Either<L, R> { | |
return { | |
type: "left", | |
value: a | |
}; |
/** | |
* Van Laarhoven Lenses in JavaScript | |
* by Gabriel Lebec (https://github.com/glebec) | |
* | |
* Based on https://www.codewars.com/kata/lensmaker | |
* See also https://github.com/ekmett/lens/wiki/History-of-Lenses | |
*/ | |
/** | |
* Composition and Combinators |
/** | |
* Minimal demo of parser combinators, possibly as a target for recent | |
* JS web dev graduates to implement as an exercise. | |
* | |
* Huge credit to Hutton, Meijer, and Swierstra for their papers | |
* on the subject. | |
*/ | |
class Parser { |
node: Platform built on V8 to build network applications | |
git: Distributed revision control system | |
wget: Internet file retriever | |
yarn: JavaScript package manager | |
python3: Interpreted, interactive, object-oriented programming language | |
coreutils: GNU File, Shell, and Text utilities | |
pkg-config: Manage compile and link flags for libraries | |
chromedriver: Tool for automated testing of webapps across many browsers | |
awscli: Official Amazon AWS command-line interface | |
automake: Tool for generating GNU Standards-compliant Makefiles |
var isWrapper = Symbol('isWrapper'); | |
function _(arg, args=[], ops=[]) { | |
const myArgs = args.concat([arg]); | |
const myOps = ops.slice(0); | |
const f = ([op]) => ( | |
myOps.push(op), | |
wrap(arg2 => _(arg2, myArgs, myOps), myArgs, myOps) | |
); |
// fix.js | |
// _has :: String => Boolean | |
var _has = k => _[k] != null; | |
// last :: Array a => a? | |
var last = xs => xs[xs.length-1]; | |
// copyArray :: Array a => Array a | |
var copyArray = xs => xs.slice(0); |
'use strict' | |
const toUpper = async string => { | |
if (string === 'invalid') return [Error('Invalid input')] | |
return [null, string.toUpperCase()] | |
} | |
const errorHandler = () => { console.log('There has been an error. I\'ll handle it.') } | |
const print = console.log | |
const foo = async input => { |
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.