Skip to content

Instantly share code, notes, and snippets.

@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');
}
@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: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: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: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:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@pitch-gist
pitch-gist / gist:3073581
Created July 9, 2012 00:42
JavaScript: Display Screen Width
// write the current screen width to our screen
$("#widget span").html($(window).width());
$(window).resize(function() {
$("#widget span").html($(window).width());
});
@pitch-gist
pitch-gist / gist:3432288
Last active October 9, 2015 03:38
Javascript: Price Switching
// setup our default plans and their pricing options, we only support rounded to the dollar prices
var plans = {
'standard': {
price: 6,
term: 10
},
'premium': {
price: 10,
term: 12
},
@pitch-gist
pitch-gist / gist:3753751
Created September 20, 2012 03:11
Mobile Testing
Below is the list of devices that we are currently testing at Pitch. We have found them to be the most popular and giving us over 90% coverage of mobile traffic on our client websites. It's not perfect, check your analytics but this is probably a good place to start.
iPhone 3GS (Apple iOS 5)
iPhone 4 (Apple iOS 6)
iPhone 5 (Apple iOS 6)
iPad 1 (Apple iOS 5)
iPad 3 (Apple iOS 6)
Nexus S (Google Android 4.1)
Nexus 7 Tablet (Google Android 4.1)
Samsung Galaxy S3 (Google Android 4.0)
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Tomorrow-Night.tmTheme",
"find_selected_text": true,
"folder_exclude_patterns":
[
".svn",
".git"
],
"font_face": "Source Code Pro",