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.log('Don\'t nest promises with catch without knowing what you are doing!'); | |
new Promise(function(resolve1, reject1){ | |
reject1('This is fine'); | |
}) | |
new Promise(function(resolve2, reject2){ | |
return new Promise(function(resolve2Inner, reject2Inner){ | |
reject2Inner('This is also fine'); | |
}) |
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
DATESTAMP="$(date -d "1 month ago" +"%Y-%m")" | |
FILESPEC="*${DATESTAMP}*.log" | |
tar cvzf "${DATESTAMP}.tar.gz" $FILESPEC && rm ${FILESPEC} |
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
function getFnName(fn) { | |
var f = typeof fn == 'function'; | |
var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/)); | |
return (!f && 'not a function') || (s && s[1] || 'anonymous'); | |
} | |
console.log(getFnName(String)); // 'String' | |
console.log(getFnName(function test(){})); // 'test' | |
console.log(getFnName(function (){})); // 'anonymous' |
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
(function () { | |
var root = $(document.getElementsByTagName('body')); | |
var watchers = []; | |
var f = function (element) { | |
if (element.data().hasOwnProperty('$scope')) { | |
angular.forEach(element.data().$scope.$$watchers, function (watcher) { | |
watchers.push(watcher); | |
}); | |
} |
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
(function loop(sum, stop) { | |
if (sum < stop) { | |
return Promise.delay(250).then(() => { | |
sum++; | |
console.log(sum); | |
return loop(sum, stop); | |
}); | |
} | |
})(0, 10).then(() => console.log('Done')) |
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
i lovaed it by placing the crt file from https://github.com/bagder/ca-bundle into php's directory and setting this line in php.ini: | |
openssl.cafile="full/path/to/ca-bundle.crt" |
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
//while (max > res.length && num > 0) { | |
if (num & 1) { // 1 if num is odd | |
// res += str; | |
} | |
num >>= 1; // halfs num to an integer (rounded down) | |
// if (!num) break; | |
// str += str; | |
//{ |
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
var keyPressed; | |
if (charCode == 8) keyPressed = "backspace"; // backspace | |
if (charCode == 9) keyPressed = "tab"; // tab | |
if (charCode == 13) keyPressed = "enter"; // enter | |
if (charCode == 16) keyPressed = "shift"; // shift | |
if (charCode == 17) keyPressed = "ctrl"; // ctrl | |
if (charCode == 18) keyPressed = "alt"; // alt | |
if (charCode == 19) keyPressed = "pause/break"; // pause/break | |
if (charCode == 20) keyPressed = "caps lock"; // caps lock | |
if (charCode == 27) keyPressed = "escape"; // escape |
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
// names of known key codes (0-255) | |
var keyboardMap = [ | |
"", // [0] | |
"", // [1] | |
"", // [2] | |
"CANCEL", // [3] | |
"", // [4] | |
"", // [5] | |
"HELP", // [6] |
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
justify-content | |
align-items | |
flex-direction | |
order | |
align-self | |
flex-wrap | |
flex-flow | |
align-content |