I hereby claim:
- I am luislee818 on github.
- I am dapeng (https://keybase.io/dapeng) on keybase.
- I have a public key ASC3S3lwpsXhgvCEJWlltt0Di70wwv8RXOMsnzj0OgqCRQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| import Text.Printf | |
| import System.Process | |
| -- Downloads free PragPub issues from 2009.07 to 2013.07 from https://pragprog.com/magazines | |
| -- relies on 'wget' command for downloading | |
| -- run `processAll` to download | |
| -- constants | |
| savePath = "/Users/Dapeng/Downloads/PragPub/" |
| --- | |
| version: '2' | |
| services: | |
| zk1: | |
| image: confluentinc/cp-zookeeper:3.0.1 | |
| ports: | |
| - "22181:22181" | |
| environment: | |
| ZOOKEEPER_SERVER_ID: 1 | |
| ZOOKEEPER_CLIENT_PORT: 22181 |
| // using v0.24.1 | |
| const R = require('ramda'); | |
| // adjust | |
| // [a -> a] -> Number -> [a] -> [a] | |
| const arr = [1, 2, 3]; | |
| let result = R.adjust(R.add(1), 1, arr); | |
| console.log('adjust: ', result); // [1, 3, 3] | |
| // update |
| defmodule Funcs do | |
| def greet(name) do | |
| "Hola #{name}" | |
| end | |
| def test do | |
| # functions as target of pipe | |
| IO.puts test_1() | |
| IO.puts test_2() | |
| IO.puts test_3() |
| var R = require('ramda'); | |
| var log = console.log; | |
| var Maybe = function(val) { | |
| this.__val = val; | |
| } | |
| Maybe.of = (val) => new Maybe(val); | |
| Maybe.prototype.map = function(fn) { |
| // Dependencies | |
| // _ | |
| // Some helper functions to be used in composition, inspired by Ramda | |
| window.r = (function(_) { | |
| var curry, | |
| flip2, | |
| invoke, | |
| split, | |
| map, |
| const Y = (f) => { | |
| const something = x => f(v => x(x)(v)); | |
| // const something = x => f(x(x)); // actually it's this, but will cause stask overflow | |
| return something(something); | |
| }; | |
| const factorial = Y(function f(fac) { | |
| return function almost(n) { | |
| return (n == 0 ? 1 : n * fac(n - 1)); |
| Promise.resolve().then(function() { | |
| console.log('starting'); | |
| return 123; | |
| }).then(function(val) { | |
| console.log(val); | |
| return val + 1; | |
| }).then(function(val) { | |
| console.log('starting second step...'); | |
| return new Promise(function(resolve) { | |
| setTimeout(function() { |
| // Chap 1 | |
| function splat(fun) { | |
| return function(array) { | |
| return fun.apply(null, array); | |
| }; | |
| } | |
| var addArrayElements = splat(function(x, y) { return x + y }); | |
| addArrayElements([1, 2]); |