Skip to content

Instantly share code, notes, and snippets.

View farnscosnippet's full-sized avatar

FarnsCo Snippets farnscosnippet

View GitHub Profile
@farnscosnippet
farnscosnippet / gist:4590402
Last active June 8, 2016 17:29
JS: Sexy PubSub
// Works in modern browswers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unsubscribe = o.off.bind(o);
$.publish = o.trigger.bind(o);
@farnscosnippet
farnscosnippet / gist:4590408
Last active June 8, 2016 17:29
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@farnscosnippet
farnscosnippet / gist:4590453
Last active June 8, 2016 17:29
JS: jQuery PubSub
(function($) {
var o = $( {} );
$.each({
on: 'subscribe',
trigger: 'publish',
off: 'unsubscribe'
}, function( key, api ) {
$[api] = function() {
o[key].apply( o, arguments );
@farnscosnippet
farnscosnippet / gist:4590503
Last active June 8, 2016 17:29 — forked from padolsey/gist:527683
JS: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@farnscosnippet
farnscosnippet / gist:4678930
Last active June 8, 2016 17:29
HTML: Meta Redirect
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">
@farnscosnippet
farnscosnippet / gist:5086980
Last active June 8, 2016 17:29
HTML: HTML5 Boilderplate Site
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
@farnscosnippet
farnscosnippet / gist:5357757
Last active June 8, 2016 17:29
WORDPRESS: Removed <p> from Images and iFrames
//filter the <p> tags from the images and iFrame
function filter_ptags_on_images($content) {
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
return preg_replace('/<p>\s*(<span .*>)?\s*(<iframe .*>*.<\/iframe>)\s*(<\/span>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
@farnscosnippet
farnscosnippet / gist:5471155
Last active June 8, 2016 17:29
CSS: CSS Boilerplate
/************************/
/* Eric Meyer Reset */
/************************/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; }
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
body { line-height: 1; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
@farnscosnippet
farnscosnippet / gist:5529877
Last active June 8, 2016 17:29
JS: Rollover Images
<!-- Rollover Images -->
<script type="text/javascript">
$(function() {
$('img[data-hover]').hover(function() {
$(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
}).each(function() {
$('<img />').attr('src', $(this).attr('data-hover'));
});;
});
</script>
@farnscosnippet
farnscosnippet / gist:5750720
Last active June 8, 2016 17:29
HTACCESS: Add GZip to Site
#BEGIN Add GZip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
#END Add Gzip