Skip to content

Instantly share code, notes, and snippets.

@pitch-gist
pitch-gist / gist:2962808
Created June 20, 2012 23:06
Apache: gzip and cache rules
# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
@pitch-gist
pitch-gist / gist:2920380
Created June 12, 2012 21:57
JavaScript: jQuery Validation Hide Error Labels
// form validation
$("form").validate({
rules: {
// define extra rules
},
errorPlacement: function(error, element) {
// don't add the error labels
return true;
}
});
@pitch-gist
pitch-gist / gist:2920368
Created June 12, 2012 21:55
JavaScript: jQuery Animate Anchor Scroll
// smooth anchor
// add a class of scroll to any anchor link and this will smoothly scroll to the location.
$(".scroll").click(function(e){
e.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
});
@pitch-gist
pitch-gist / gist:2920362
Created June 12, 2012 21:53
JavaScript: jQuery Make Checkbox Labels Clickable iOS
// this makes checkbox labels clickable on iOS
$('label.checkbox').click(function() {});
@pitch-gist
pitch-gist / gist:2920336
Created June 12, 2012 21:48
JavaScript: Add iOS Class
// find out if the device is an ios device and add a class.
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
$('html').addClass('ios');
}