This file contains hidden or 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
## `How to access host port from a docker container` | |
## `Access host's ssh tunnel from docker container` | |
## `Prevent from using --net=host` | |
## ... | |
# +-------------------+ | |
# | | | |
# | | | |
# | local container | | |
# | +---+ | |
# +-------------------+ |172.10.0.1 |
This file contains hidden or 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 () { | |
const { S, F } = require ('./src/utils/sanctuary') () | |
const control = F.coalesce (_ => S.Nothing) (S.Just) | |
const fut = F.go (function * () { | |
// const book1 = yield F.resolve ('Python') | |
const book1 = yield control (F.reject ('?network error')) | |
const book2 = yield control (F.resolve ('JavaScript')) | |
return { | |
book1, | |
book2, |
This file contains hidden or 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 foldr (c, h) { | |
return ([a, ...x]) => (a === undefined) | |
? c | |
: h (a) (foldr(c, h)(x)) | |
} | |
function foldl (c, h) { | |
return ([a, ...x]) => (a === undefined) | |
? c | |
: foldl (h(c)(a), h) (x) |
This file contains hidden or 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 uncurry = | |
f => | |
(...args) => | |
args.reduce((p, c) => p(c), f) | |
const curryN = | |
n => | |
fn => | |
(n === 0) ? fn() | |
: /* otherwise */ x => curryN(n - 1)(fn.bind(null, x)) |
This file contains hidden or 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 R = require('ramda') | |
const yaff = | |
R.cond([ | |
[R.equals(0), R.always(1)], | |
[R.equals(1), R.always(1)], | |
[R.T, x => yaff(x - 1) + yaff(x - 2)], | |
]) | |
const fib = |
This file contains hidden or 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
// Requires traceur | |
import { iterate, take, map, foldl } from './list-out-of-yield'; | |
// Sum of squares of integers 1..100 | |
var values = take(100, iterate(x => x + 1, 1)); | |
var result = foldl((x, y) => x + y, 0, map(x => x * x, values)); | |
console.log(result); |
This file contains hidden or 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 dfs (x) { | |
x.visited = true | |
adjacent(x) | |
.forEach(y => y.visited || dfs(y)) | |
} | |
// :: List Node -> List Node | |
function bfs0 (xs) { | |
xs.forEach(x => { x.visited = true }) | |
return (!xs.length) |
This file contains hidden or 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 uncurry = | |
fn => | |
ar => | |
ar.reduce((f, x) => f(x), fn) | |
const curryN = | |
n => | |
fn => | |
(n === 0) ? fn() | |
/* otherwise */ : x => curryN(n - 1)(fn.bind(null, x)) |
This file contains hidden or 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
/** | |
* This short program will encrypt the user password | |
* and insert a new record into a mock database. | |
*/ | |
const Reader = require('fantasy-readers'); | |
const R = require('ramda'); | |
const crypto = require('crypto'); | |
// our mock database | |
const database = [ |
This file contains hidden or 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 I = x => x; | |
const K = x => y => x; | |
const A = f => x => f(x); | |
const T = x => f => f(x); | |
const W = f => x => f(x)(x); | |
const C = f => y => x => f(x)(y); | |
const B = f => g => x => f(g(x)); | |
const S = f => g => x => f(x)(g(x)); | |
const P = f => g => x => y => f(g(x))(g(y)); | |
const Y = f => (g => g(g))(g => f(x => g(g)(x))); |