Easy access for a property in higher order functions, enables composition & piping
const strings = ["", "a"]
const filteredStrings = strings.filter(.length) // ["a"]
const bb = require('bluebird'); | |
const axios = require('axios'); | |
const f = require('lodash/fp'); | |
const autheader = 'token xxx'; | |
const fetch = (page, continuePredicate, accumulator = [] ) => | |
axios.get('https://api.github.com/orgs/:org/repos', { | |
params: { | |
page, | |
per_page: 100 |
const makeRequest = () => { | |
return promise1() | |
.then(value1 => { | |
// do something | |
return Promise.all([value1, promise2(value1)]) | |
}) | |
.then(([value1, value2]) => { | |
// do something | |
return promise3(value1, value2) | |
}) |
const makeRequest = async () => { | |
await callAPromise() | |
await callAPromise() | |
await callAPromise() | |
await callAPromise() | |
await callAPromise() | |
throw new Error("oops"); | |
} | |
makeRequest() |
// this will not work in top level | |
// await makeRequest() | |
// this will work | |
makeRequest().then((result) => { | |
// do something | |
}) |
const makeRequest = async () => { | |
const value1 = await promise1() | |
const value2 = await promise2(value1) | |
return promise3(value1, value2) | |
} |
# install zsh | |
sudo apt-get update | |
sudo apt-get install zsh git -y | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
chsh -s $(which zsh) | |
# manual: edit theme in ~/.zshrc to "clean" | |
# ssh-key | |
ssh-keygen -t rsa |
# cron tab | |
# 0 0 */5 * * /root/certbot-renew | |
#!/bin/sh | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
#old /root/certbot-auto renew | |
certbot renew | |
# don't forget chmod +x /root/certbot-renew |
function add (x, y) {return x+y} | |
let curry = (f, ...args) => f.bind.apply(f,[null, ...args]) | |
let add4 = curry(add,4) | |
console.log(add4(5)) //9 | |
let add4n6 = curry(add4,6) | |
console.log(add4n6()) //10 |
const makeRequest = () => { | |
return callAPromise() | |
.then(() => callAPromise()) | |
.then(() => callAPromise()) | |
.then(() => callAPromise()) | |
.then(() => callAPromise()) | |
.then(() => { | |
throw new Error("oops"); | |
}) | |
} |