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
<?php | |
function minify_css( $buffer ) { | |
if( trim( $buffer ) === "") return $buffer; | |
// Remove comments | |
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); | |
// Remove whitespace | |
$buffer = preg_replace(array('/\s{2,}/', '/[\t\n]/'), ' ', $buffer); |
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
/** | |
* @link https://davidwalsh.name/javascript-debounce-function | |
* | |
* Here's the basic JavaScript debounce function (as taken from Underscore.js): | |
*/ | |
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. |
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 debounce(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}} |
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
// Source: http://stackoverflow.com/questions/14866775/detect-document-height-change | |
var $j = jQuery.noConflict(); | |
$j( document ).ready(function($) { | |
function onElementHeightChange(elm, callback){ | |
var lastHeight = elm.clientHeight, newHeight; | |
(function run(){ | |
newHeight = elm.clientHeight; | |
if( lastHeight != newHeight ) | |
callback(); |
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
// Returns a function, that, when invoked, will only be triggered at most once | |
// during a given window of time. | |
// Source: https://gist.github.com/killersean/6742f98122d1207cf3bd | |
function throttle(callback, limit, callbackArgs) { | |
var wait = false; | |
return function() { | |
if (wait) { | |
return; | |
} | |
callback.call(callbackArgs); |
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
/* Source: http://stackoverflow.com/questions/11173106/apply-style-only-on-ie/36448860#36448860 */ | |
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { | |
#myElement { | |
/* Enter your style code */ | |
} | |
} |
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
/** | |
* timedInterval | |
* | |
* The method calls a function or evaluates an expression at specified intervals (in milliseconds) | |
* until a specified number of milliseconds. | |
* | |
* @param {Function} callback | |
* @param {int} interval - run every [interval] ms | |
* @param {int} expiration - run until [expiration] in ms | |
* @param {mixed} callbackArgs - arguments for callback function |
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
<snippet> | |
<!-- put this file in /packages/User/<Folder Name>/html5.sublime-snippet then restart your Sublime Text 2 --> | |
<content><![CDATA[<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- | |
ToDo: HTML, CSS, JS -> concatenate and minify for production | |
- JavaScript: https://jscompress.com/ |
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
<snippet> | |
<!-- put this file in /packages/User/<Folder Name>/console_log.sublime-snippet then restart your Sublime Text 2 --> | |
<content><![CDATA[console.log( '$1' );$0]]></content> | |
<tabTrigger>conl</tabTrigger> | |
<scope>text.html,source.js</scope> | |
<description>console.log()</description> | |
</snippet> | |
<snippet> | |
<!-- put this in another file /packages/User/<Folder Name>/console_dir.sublime-snippet then restart your Sublime Text 2 --> |
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
<snippet> | |
<!-- put this file in /packages/User/<Folder Name>/jquery.sublime-snippet then restart your Sublime Text 2 --> | |
<content><![CDATA[ | |
/** | |
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't | |
* have to worry about using things such as 'noConflict' or creating your own reference to the jQuery function. | |
* | |
* @version 1.1 | |
* | |
* ToDo: concatenate and minify for production -> https://jscompress.com/ |
OlderNewer