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
commands: | |
01_swapmem_step: | |
command: sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 | |
ignoreErrors: true | |
test: test ! -f .swapmem | |
02_swapmem_step: | |
command: sudo /sbin/mkswap /var/swap.1 | |
ignoreErrors: true | |
test: test ! -f .swapmem | |
03_swapmem_step: |
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
doTheDishes(); | |
watchNetflix(); | |
vacuumTheFloor(); | |
function doTheDishes() { | |
log('Dishes are done!'); | |
} | |
function watchNetflix() { | |
log('Season 99 of <Netflix Show> finished!'); |
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
doTheDishes(); | |
vacuumTheFloor(); | |
watchNetflix(); | |
function doTheDishes() { | |
log('Dishwasher ON!') | |
setTimeout(() => log('Dishes are done!'), 3000); | |
} | |
function vacuumTheFloor() { |
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
// setTimeout receives a callback function, in this example the callback is "logger" | |
// setTimeout will call the function we gave, after the specified amount of time (3000 ms) | |
let logger = () => log('Dishes are done!'); | |
setTimeout(logger, 3000); |
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
watchNetflix(() => gotoSleep()); | |
function watchNetflix(callbackFn) { | |
log('Netflix ON!') | |
setTimeout(() => { | |
log('Season 99 of <Netflix Show> finished!'); | |
callbackFn(); | |
}, 1000); | |
} | |
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
watchNetflix( | |
() => gotoSleep( | |
() => { | |
drinkCoffee(); | |
goToWork( | |
() => goHome() | |
); | |
} | |
) | |
); |
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
watchNetflix( | |
error => { | |
if (error) { | |
callInternetProvider(); | |
} else { | |
gotoSleep((result, error) => { | |
if (error) { | |
tryToSleepAgain(); | |
} else if (!result.rested) { | |
drinkCoffee(); |
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
// This is how you create a promise | |
new Promise((resolve, reject) => { | |
// Here you should do your work, involving some asynchronous operation | |
// Once it finishes, you either call resolve (fulfilled) | |
// or reject (rejected) to transition the promise state | |
}); |
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
new Promise(...) | |
.then(result => { /* promise was fulfilled, do something with result */ }) | |
.catch(error => { /* promise was rejected, do something with error */ }) |
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
log('Waiting one second'); | |
wait(1000) | |
.then(() => log('I waited for one second')) | |
.catch((err) => log('Something went wrong' + err)); | |
log('Meanwhile checking twitter'); | |
function wait(ms) { | |
return new Promise((resolve, reject) => { | |
log('Inside Promise ---> Started waiting') | |
setTimeout(() => resolve(), ms); |
OlderNewer