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 resizeBuffer = null; | |
var prevWidthName = getWindowWidthName(); | |
$(window).on('resize', function () { | |
clearTimeout(resizeBuffer); | |
resizeBuffer = setTimeout(function() { | |
var newWidthName = getWindowWidthName(); | |
if (newWidthName != prevWidthName) { | |
prevWidthName = newWidthName; | |
$(document).trigger(newWidthName); | |
} |
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
/** | |
* You may use this function with both 2 or 3 interval colors for your gradient. | |
* For example, you want to have a gradient between Bootstrap's danger-warning-success colors. | |
*/ | |
function colorGradient(fadeFraction, rgbColor1, rgbColor2, rgbColor3) { | |
var color1 = rgbColor1; | |
var color2 = rgbColor2; | |
var fade = fadeFraction; | |
// Do we have 3 colors for the gradient? Need to adjust the params. |
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
<?php | |
/** | |
* Returns customer notifications | |
* | |
* @param int|null $limit | |
* @param int|null $afterId | |
* @param int|null $beforeId | |
* | |
* [0]*************************************[totalRows] |
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
export function lpad(pad, string) { | |
var trueString = '' + string; | |
return pad.substring(0, pad.length - trueString.length) + trueString; | |
} |
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
// jQuery warriors, assemble! | |
$.fn.cachedFind = function (selector) { | |
var cache = this.data('cached-find') || {}; | |
if (undefined === cache[selector]) { | |
cache[selector] = this.find(selector); | |
this.data('cached-find', cache); | |
} | |
return cache[selector]; | |
}; |
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
<?php | |
/** | |
* Counts the number of lines in a container where character count per line is known or approximate. | |
* It assumes that words can be broken. | |
* | |
* @param string $text | |
* @param int $perLine | |
* | |
* @return int |
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
<?php | |
/** | |
* Expresses a given number in a a-z letter base, e.g.: | |
* 0 -> a, 27 -> ba, 932 -> bjw, ... | |
* | |
* @param int $number | |
* | |
* @return string | |
*/ |
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 roundFloat(number, decimals) { | |
return (Math.round(number * (Math.pow(10, decimals))) / Math.pow(10, decimals)).toFixed(decimals) | |
} |
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
<?php | |
// Trims whitespaces after any tags. Assumes that a tag ends with '/>', '\w>', '">'. | |
$html = preg_replace('#(["|\/|\w]>)(\s+)#', '$1', $html); | |
// Trims whitespaces before any tags. Assumes that tags start with '<\w+' | |
$html = preg_replace('#(\s+)(<\/?\w+)#', '$2', $html); | |
// Trims spaces between tags (both opening and closing). | |
// Assumes that a tag ends with '/>', '\w>', '">' and starts with '<\w+' |
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
<?php | |
// @see https://www.elastic.co/guide/en/elasticsearch/reference/5.x/date-math-index-names.html | |
// @TODO <elastic\\{ON\\}-{now/M}> | |
function escapePathWithDateMath($path) | |
{ | |
$symbols = ['<', '>', '/', '{', '}', '|', '+', ':', ',']; | |
$escaped = ['%3C', '%3E', '%2F', '%7B', '%7D', '%7C', '%2B', '%3A', '%2C']; | |
// Check if the string is already escaped |