Credits: @andrewray
URL: http://blog.andrewray.me/
git log -p -M --follow --stat -- /path/to/file/name
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
// CoffeeScript | |
square = (x) -> x * x | |
cube = (x) -> square(x) * x | |
fill = (container, liquid = "coffee") -> | |
"Filling the #{container} with #{liquid}..." | |
// ES6 | |
let square = (x) => x*x | |
let cube = (x) => square(x)*x | |
let fill = (container, liquid = null) => `Filling the ${container} with ${liquid}...` |
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
/* | |
Implementation of The Luhn Algorithm (https://en.wikipedia.org/wiki/Luhn_algorithm) | |
*/ | |
function validate(n) { | |
/** | |
* Check if the given number is of valid type | |
*/ | |
if (!n || typeof n !== 'number') { |
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 revrot(str, sz) { | |
/** | |
* If string (str), size (sz) or size is greater than string's | |
* length, return empty string. | |
*/ | |
if (sz === 0 || str.length === 0 || sz > str.length) { | |
return '' | |
} |
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
$('<div id="dim_overlay">') | |
.css({ | |
'background-color': 'rgba(0, 0, 0, 0.5)', // change the last value to adjust the brightness. | |
'min-height': '100%', | |
'min-width': '100%', | |
'position': 'fixed', | |
'pointer-events': 'none', // keeps website's functionality intact | |
'z-index': 999 | |
}) | |
.appendTo(document.body); |
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
// with map | |
[...Array(5)].map((elm, idx) => { | |
switch(idx) { | |
case 0: | |
return Math.random().toString(36).slice(2, 8) | |
case 4: | |
return Math.random().toString(36).slice(2, 14) | |
default: | |
return Math.random().toString(36).slice(2, 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
const promises = [ | |
() => | |
new Promise(resolve => | |
setTimeout(() => { | |
resolve(console.log(1)); | |
}, Math.floor(Math.random() * 2000) + 1000) | |
), | |
() => | |
new Promise(resolve => |
OlderNewer