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 trace = (x, y) => { | |
console.log(x) | |
return y | |
} | |
const trace1 = x => trace(x, x) | |
const id = x => x | |
const swap = ([x, y]) => [y, x] |
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 trace = (x, y) => { | |
console.log(x) | |
return y | |
} | |
const trace1 = x => trace(x, x) | |
const id = x => x | |
Promise.prototype.map = function(f) { | |
return this.then(x => { |
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 wrap1 = (arrow, before, after, f) => | |
arrow.arr(before).pipe(arrow.arrM(f)).pipe(arrow.arr(after)) | |
const wrap12 = (arrow, before, after, f) => new arrow(x => { | |
let b = arrow.arr(before).run(x) | |
let y = arrow.id.pipe(arrow.arrM(f)).run(b) | |
return arrow.id.pipe(arrow.arr(after)).run(y) | |
}) | |
class Func { |
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 timeIt = R.curry((report, f) => (...args) => { | |
const t0 = Date.now() | |
const nArgs = R.init(args) | |
const callback = R.last(args) | |
nArgs.push((...args) => { | |
const t1 = Date.now() | |
callback(...args) | |
report(t1 - t0, ...args) |
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 trace = (msg, x) => { | |
console.log(msg) | |
return x | |
} | |
const serviceCall = x => | |
Math.random() > 0.5 | |
? Promise.resolve(x) | |
: Promise.reject(`not lucky ${x}`) |
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 trace = (msg, x) => { | |
console.log(msg) | |
return x | |
} | |
const serviceCall = x => | |
Math.random() > 0.5 | |
? Promise.resolve(x) | |
: Promise.reject(`not lucky ${x}`) | |
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 stream = require("stream"); | |
var rstream = (function() { | |
var i = 0; | |
var rstream = new stream.Readable(); | |
rstream._read = function(){ | |
return this.push(++i > 2 ? "" : ["hello","world"][i-1]); | |
}; | |
return rstream | |
})(); | |
var wstream = new stream.Writable(); |
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
// utility range function, creates a list of [0, 1, 2, ..., i] | |
const range = i => [...Array(i).keys()] | |
// fixed point, Y combinator (proof at the end of the code) | |
const fix = f => | |
(g => z => f(g(g))(z)) (g => z => f(g(g))(z)) | |
// open recursive definition of factorial funciton | |
// note that x is a funciton |
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
# server | |
while true; do read ui; echo $ui | openssl enc -aes128 -a -k PaSSw; done | nc -vl 192.168.1.2 1300 | |
# client | |
nc 192.168.1.2 1300 | while read so; do decoded=`echo "$so" | openssl enc -d -a -aes128 -k PaSSw`; echo "$decoded"; done; |
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
from-web-socket = require \./ws | |
ws = from-web-socket 'ws://' | |
.filter ({name}) -> name == \all-campaigns | |
.map ({data}) -> JSON.parse data | |
.subscribe do | |
(x) -> | |
console.log x | |
#ws.dispose! | |
(ex) -> |