View machine.js
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
View retryIfEmpty.ts
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
import isEmpty from 'lodash/isEmpty' | |
const retryIfEmpty = async (input): Promise<any> => { | |
const { request, timeout = 200, maxCalls = 6 } = input; | |
return new Promise(async (resolve, reject) => { | |
try { | |
const { data } = await request; | |
if (isEmpty(data)) { |
View index.js
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 toListItem = async item => { | |
const { thing } = await sendRequest(); | |
return thing; | |
}; | |
const delayTime = 100; | |
const items = delayedMap(listOfStuff, toListItem, delayTime); |
View index.js
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 delayedMap = async (list, iterator, delayTime) => { | |
let promises = []; | |
for (const item of list) { | |
await delay(delayTime); | |
promises.push(await iterator(item)); | |
} | |
return Promise.all(promises); | |
}; |
View index.js
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 delay = time => | |
new Promise(resolve => setTimeout(resolve, time)); | |
const list = new Array(10).fill(); | |
for (let index of list.keys()) { | |
await delay(1000); | |
console.log(index); | |
} |
View index.js
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 delay = time => | |
new Promise(resolve => setTimeout(resolve, time)); | |
const list = new Array(10).fill(); | |
list.forEach(async (_, index) => { | |
await delay(1000); | |
console.log(index); | |
}); |
View index.js
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 delay = time => | |
new Promise(resolve => setTimeout(resolve, time)); | |
const sendRequest = async () => { | |
await delay(1000); | |
return axios.get(API_URL); | |
} | |
// request fires after 1 second | |
sendRequest(); |
View index.js
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
import axios from 'axios'; | |
const API_URL = "https://jsonplaceholder.typicode.com/posts/1"; | |
// Before async/await | |
const logPostId = () => { | |
axios.get(API_URL) | |
.then(resp => { | |
const { data } = resp; | |
const { id } = data; |
View .irbrc
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
# load libraries | |
require 'rubygems' rescue nil | |
require 'wirble' | |
#require 'json' | |
alias q exit | |
class Object | |
def local_methods | |
(methods - Object.instance_methods).sort |
View .tmux.conf
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
set-option -g default-shell /bin/zsh | |
set-option -g default-terminal "screen-256color" | |
set-option -g base-index 1 | |
setw -g pane-base-index 1 | |
set-option -g xterm-keys on | |
setw -g aggressive-resize on | |
set -s escape-time 0 |
NewerOlder