Skip to content

Instantly share code, notes, and snippets.

@pitch-gist
pitch-gist / gist:2920362
Created Jun 12, 2012
JavaScript: jQuery Make Checkbox Labels Clickable iOS
View gist:2920362
// this makes checkbox labels clickable on iOS
$('label.checkbox').click(function() {});
@pitch-gist
pitch-gist / gist:2920380
Created Jun 12, 2012
JavaScript: jQuery Validation Hide Error Labels
View gist:2920380
// 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:2920336
Created Jun 12, 2012
JavaScript: Add iOS Class
View gist:2920336
// 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:2920368
Created Jun 12, 2012
JavaScript: jQuery Animate Anchor Scroll
View gist:2920368
// 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:2962808
Created Jun 20, 2012
Apache: gzip and cache rules
View gist:2962808
# 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:3073581
Created Jul 9, 2012
JavaScript: Display Screen Width
View gist:3073581
// 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 Oct 9, 2015
Javascript: Price Switching
View gist:3432288
// 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
},
View gist:3753751
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)
View Sublime: Preferences
{
"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",
@pitch-gist
pitch-gist / gist:4956207
Last active Dec 13, 2015
Emmet: Simple Navigation
View gist:4956207
nav.main-navigation>ul>(li>a[href="#"][title=""])*6