(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* "Thunks, Trampolines, and Continuation Passing" | |
* Python implementation from http://jtauber.com/blog/2008/03/30/ | |
* JavaScript implementation by Thomas Darr <me@trdarr.com>. | |
*/ | |
// thunk = lambda name: lambda *args: lambda: name(*args) | |
var thunk = function thunk(fn) { | |
return function _thunk() { | |
var splat = Array.prototype.slice.apply(arguments); | |
return function __thunk() { return fn.apply(this, splat); }; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// See http://blog.sigfpe.com/2008/12/mother-of-all-monads.html | |
// MARK: function composition | |
infix operator >>> { associativity left } | |
func >>> <A, B, C>(f: A -> B, g: B -> C) -> A -> C { | |
return { x in g(f(x)) } | |
} | |
// MARK: Continuation monad | |
struct Cont<R, A> { |
const daggy = require('daggy') | |
const {compose, curry, map, prop, identity, intersection, union} = require('ramda'); | |
const inspect = (x) => { if(!x) return x; return x.inspect ? x.inspect() : x; } | |
// F-algebras | |
// Fix | |
// ============ | |
// Fx is a simple wrapper that does almost nothing. It's much more useful in typed languages to check that we have a recursive f (Fix f) |
# local port forwarding | |
# the target host 192.168.0.100 is running a service on port 8888 | |
# and you want that service available on the localhost port 7777 | |
ssh -L 7777:localhost:8888 user@192.168.0.100 | |
# remote port forwarding | |
# you are running a service on localhost port 9999 | |
# and you want that service available on the target host 192.168.0.100 port 12340 |
import {StateT} from 'fantasy-states' | |
import Task from 'data.task' | |
import {prop, compose, map, chain, merge, always} from 'ramda' | |
// Unfortunately Binary Gendered Baby Page | |
//========================================== | |
// data App a b c = App State a (Task b c) | |
const App = StateT(Task) | |
const {get, put, modify} = App; |
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 S_ = f => g => x => f (g (x)) (x) | |
const S2 = f => g => h => x => f (g (x)) (h (x)) |
Picking the right architecture = Picking the right battles + Managing trade-offs
import * as mongoose from 'mongoose'; | |
export let Schema = mongoose.Schema; | |
export let ObjectId = mongoose.Schema.Types.ObjectId; | |
export let Mixed = mongoose.Schema.Types.Mixed; | |
export interface IHeroModel extends mongoose.Document { | |
name: string; | |
power: string; |