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
// Spec http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify | |
const replacer = (key, value) => | |
value instanceof Object && !(value instanceof Array) ? | |
Object.keys(value) | |
.sort() | |
.reduce((sorted, key) => { | |
sorted[key] = value[key]; | |
return sorted | |
}, {}) : | |
value; |
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 printNumbers(a, b) { | |
if (a > b || typeof a !== 'number' || typeof b !== 'number') { | |
throw 'Incorrect arguments'; | |
} | |
for(let i = a, counter = 0, promises = []; i <= b; i++, counter++) { | |
promises.push( | |
new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(i) | |
}, 1000 * counter) |
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 printNumbers(a, b, cb) { | |
if (a > b || typeof a !== 'number' || typeof b !== 'number') { | |
throw 'Incorrect arguments'; | |
} | |
for(let i = a, counter = 0; i <= b; i++, counter++) { | |
setTimeout(() => { | |
cb(i); | |
}, 1000 * counter) | |
} |
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
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
RewriteRule ^(.*) /index.html [NC,L] |
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
loadImage.parseMetaData( | |
file, (data) => { | |
if (!data.imageHead) { | |
return; | |
} | |
const orientation = data.exif ? data.exif[0x0112] : null; | |
if (orientation) { | |
loadImage( |
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 startLoader = function () { | |
(function() { | |
process.stdout.write('Some text here...' + "\n"); | |
var P = ["\\", "|", "/", "-"]; | |
var x = 0; | |
return setInterval(function() { | |
process.stdout.write("\r" + P[x++]); | |
x &= 3; | |
}, 250).unref(); | |
})(); |
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
_.mixin({ pickSchema: function (model, excluded) { | |
var fields = []; | |
model.schema.eachPath(function (path) { | |
_.isArray(excluded) ? excluded.indexOf(path) < 0 ? fields.push(path) : false : path === excluded ? false : fields.push(path); | |
}); | |
return fields; | |
} | |
}); | |
// Example |
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 getActivityColor(activityID) { | |
var color; | |
for (var key in activityColors) { | |
if (activityColors[key].activityID == activityID) { | |
color = activityColors[key].color; | |
break; | |
} | |
} | |
if (!color) { | |
var letters = '0123456789ABCDEF'.split(''); |
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
<div class="grid"> | |
<div class="grid-item grid-item--width2">1</div> | |
<div class="grid-item grid-item--height2">2</div> | |
<div class="grid-item">3</div> | |
<div class="grid-item">4</div> | |
<div class="grid-item grid-item--width2 grid-item--height2">5</div> | |
<div class="grid-item grid-item--width2">6</div> | |
<div class="grid-item grid-item--height2">7</div> | |
<div class="grid-item">8</div> |
NewerOlder