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 getJSON = require('get-json'); | |
/** api data **/ | |
const API = { | |
uri: 'http://beta.json-generator.com/api/json', | |
tables: { | |
profiles: '4ybyRpIWz', | |
users: 'NJq8uvBWM' | |
} | |
}; |
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 response = await fetch(url); | |
const reader = response.body.getReader(); | |
while (true) { | |
const {done, value} = await reader.read(); | |
if (done) | |
break; | |
// Do something with value otherwise | |
console.log(value); | |
} |
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
// We now can write this, more human readable form: | |
placeOrder([ | |
farmhouseLight(10), | |
farmhouseDark(4), | |
columbian(3, 3), | |
columbian(4, 3), | |
arrrrrggg(letMeThink(), itDepends()) | |
]); |
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
// Now where we once would have written this: | |
placeOrder([ | |
baristaJoe('farmhouse blend', 10, 10), | |
baristaJoe('farmhouse blend', 0, 4), | |
baristaJoe('columbian', 3, 3), | |
baristaJoe('columbian', 4,3), | |
baristaJoe('half-caff carmel-mocha pumkin-karaoke', letMeThink(), itDepends()) | |
]); |
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
// Those 5 lines of code we wrote above to create more specific functions, | |
// is about the same as writing these 35 lines of code down here... power. | |
/* So to be clear, we don't have to write these implementations */ | |
function farmhouse(creams, sugars) { | |
const coffee = getCoffee('farmhouse blend'); | |
coffee.add.cream(creams); | |
coffee.add.suger(sugars); | |
return coffee; | |
} |
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
// If baristaJoe was a curried function, we could create more specific functions | |
// by "partially applying" an argument at a time. | |
const farmhouse = baristaJoe('farmhouse blend'); | |
const columbian = baristaJoe('columbian'); | |
const arrrrrggg = baristaJoe('half-caff carmel-mocha pumkin-karaoke'); | |
const farmhouseLight = farmhouse(10); | |
const farmhouseBlack = farmhouse(0); |
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
// Our friendly work-adjacent coffee man! | |
function baristaJoe(flavor, creams, sugars) { | |
const coffee = getCoffee(flavor); // Pour the coffee | |
coffee.add.cream(creams); // How many creams to add | |
coffee.add.suger(sugars); // How many sugars to add | |
return coffee; | |
} |
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
// Our friendly work-adjacent coffee man! | |
function baristaJoe(flavor, creams, sugars) { | |
const coffee = getCoffee(flavor); // Pour the coffee | |
coffee.add.cream(creams); // How many creams to add | |
coffee.add.suger(sugars); // How many sugars to add | |
return coffee; | |
} |
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
// To learn more about the halting problem check out Gary Bernhardt's series on computation | |
https://www.destroyallsoftware.com/screencasts | |
// Ethereum Yellow Paper | |
http://gavwood.com/paper.pdf | |
// Ethereum OpCodes List | |
http://ethereum.stackexchange.com/questions/119/what-opcodes-are-available-for-the-ethereum-evm | |
// Ethereum OpCodes Gas Costs |
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
console.clear() | |
// The Ramda Library functions you need to breathe. | |
const Maybe = iJustMetYouThisIsCrazyImAMonadSoCallMeMaybe() | |
const { | |
map, chain, compose, reduce, filter, prop, curry | |
} = R | |
// fromEvent :: Str -> Elem -> Obs | |
const fromEvent = curry((eventType, elem) => { | |
return Rx.Observable.fromEvent(elem, eventType) |