Promise.all
will execute all promises in parallel, and fail whenever any one of the promises fails. This could even include failing synchronously if one is a Promise.reject()
. Instead of doing this, here we want to make sure that all promises finish before we handle the result. We wait for all promises to finish, check their status, and reject or resolve the final promise based on whether any errors were encountered or not.
This file contains hidden or 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 path = require('path'); | |
const chokidar = require('chokidar'); | |
const root = path.resolve('.'); | |
const watcher = chokidar.watch('.', { | |
cwd: root, | |
ignored: [ | |
/(^|[/\\])\../, // Dotfiles |
This file contains hidden or 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
REM https://medium.com/@twister.mr/installing-macos-to-virtualbox-1fcc5cf22801 | |
VBoxManage.exe modifyvm "Mojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff | |
VBoxManage.exe setextradata "Mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" | |
VBoxManage.exe setextradata "Mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
VBoxManage.exe setextradata "Mojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" | |
VBoxManage.exe setextradata "Mojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
VBoxManage.exe setextradata "Mojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
VBoxManage.exe setextradata "Mojave" VBoxInternal2/EfiGopMode 4 | |
REM resize screen |
This file contains hidden or 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
function excelDateToJsDate(excelDate) { | |
// this code was originally written in https://gist.github.com/christopherscott/2782634 | |
return new Date( | |
(excelDate - (25567 + 1)) * 86400 * 1000 | |
); | |
} | |
function jsDateToExcelDate(date) { | |
// just working backwards from the code above | |
return (date.getTime() / (86400 * 1000)) + (25567 + 1); |
This file contains hidden or 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
<script src="//catdad.github.io/tiny.cdn/lib/toast/1.0.0/toast.min.js"></script> | |
<script> | |
(function () { | |
function logger(type) { | |
return function () { | |
toast[type]([].reduce.call(arguments, function (memo, arg) { | |
return memo + ' ' + arg.toString(); | |
}, '')); | |
}; | |
} |
This file contains hidden or 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
function renderMustache(str, obj) { | |
return Object.keys(obj).reduce(function (memo, key) { | |
var value = obj[key]; | |
var regex = new RegExp('\\$\\{' + key + '\\}', 'g'); | |
return memo.replace(regex, value); | |
}, str); | |
}; | |
// usage |
This file contains hidden or 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
BUILD_NUMBER=`node <<- EOM | |
var fs = require('fs'); | |
var file = JSON.parse(fs.readFileSync('./file.json', 'utf8')); | |
process.stdout.write(file.displayName); | |
EOM` |
This file contains hidden or 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
function buff(size) { | |
var buf = new Buffer(size); | |
buf.fill(0); | |
return buf; | |
} | |
var mb = 1024*1024; | |
var temp = []; |
This file contains hidden or 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
var through = require('through2'); | |
function changeChunkSizes() { | |
var buff = ''; | |
var data; | |
var keepIdx; | |
return through(function (chunk, enc, cb) { | |
buff += chunk.toString(); | |
data = keepIdx = undefined; |
This file contains hidden or 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
// Name Function | |
// ---- -------- | |
// CON Keyboard and display | |
// PRN System list device, usually a parallel port | |
// AUX Auxiliary device, usually a serial port | |
// CLOCK$ System real-time clock | |
// NUL Bit-bucket device | |
// A:-Z: Drive letters | |
// COM1 First serial communications port | |
// LPT1 First parallel printer port |
NewerOlder