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
| In ES5: | |
| function pluck(array, key) { | |
| return array.map(function(obj) { | |
| return obj[key]; | |
| }); | |
| } | |
| In ES6: | |
| function pluck(array, key) { |
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 remove = (arr, func) => | |
| Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { | |
| arr.splice(arr.indexOf(val), 1); return acc.concat(val); | |
| }, []) | |
| : []; | |
| // remove([1, 2, 3, 4], n => n % 2 == 0) -> [2, 4] |
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 truncateString = (str, num) => | |
| str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; | |
| // truncateString('boomerang', 7) -> 'boom... |
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 mix(...mixins){ | |
| class Mix{}; | |
| for (let mixin of mixins){ | |
| copyProperties(Mix,mixin); | |
| copyProperties(Mix.prototype,mixin.prototype); | |
| } | |
| } | |
| function copyProperties(target,source){ | |
| for (let key of Reflect.ownKeys(source)){ | |
| if(key !== 'constructor' && key !== 'prototype' && key !== 'name'){ |
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 isDivisible = (dividend, divisor) => dividend % divisor === 0; | |
| // isDivisible(6,3) -> true |
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 getQuerySrings() { | |
| var qs = location.search.length > 0 ? location.search.substring(1) : ""; | |
| var args = {}; | |
| var items = qs.length ? qs.split('&') : []; | |
| var item = null, | |
| name = null, | |
| value = null, | |
| i = 0; | |
| for (var i = 0; i < items.length; i++) { | |
| item = items[i].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
| background-image: url('data:image/gif;base64,R0lGODlhPAA8APYAAJeXl56enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19nZ2dra2tvb29zc3N3d3eDg4OHh4ePj4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkEAEIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAPAA8AAAH/oBCgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpuKJgwMJ5ycBQAABaKbBKUEqI9BQUCIA6UDhyELDRytg7BAQYezALWGCgEBDLuCvUCxhcHDhA4CAgELyULLzYTPhSAF0wMS10LMzL/btIUNAdPW49nngtyDFQPTBBjjyuXaQqoArAYlmCYggr5B/OIZKGVgUAR7Ak5x+tGjh49Dy+JdMGDgwiAG7Aoe8iBBwgdJPXio7PHDUK94hx5MU2CIQ4QEBw5MQKmyZw9DzBghOGDIggIESA+I49lT5cVLFhYgndpABCUfTVdagpBg6oEFFDClbPpzkoOpCBJMIKHJx1ge/mUlPRiK4IEGVG6fUpowocPBv4ADCz7EIweOw4gR88BUIoOFx5AfY0j |
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 excerpt(str, nwords) { | |
| var words = str.split(' '); | |
| words.splice(nwords, words.length-1); | |
| return words.join(' ') + | |
| (words.length !== str.split(' ').length ? '…' : ''); | |
| } |
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
| originUrl.replace(/(\.[\w\d_-]+)$/i, size+'$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
| server { | |
| root /webserver; | |
| location ~* \.(eot|otf|ttf|woff|svg)$ { | |
| add_header Access-Control-Allow-Origin *; | |
| } | |
| } | |
| server { | |
| root /webserver; |