Skip to content

Instantly share code, notes, and snippets.

View plasticmind's full-sized avatar

Jesse Gardner plasticmind

View GitHub Profile
@plasticmind
plasticmind / gist:14e04ebfa734b13e720f
Created November 19, 2014 17:07
Adjusted Bounce Rate for Google Analytics
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX']);
_gaq.push(['_trackPageview']);
setTimeout("_gaq.push(['_trackEvent', '15_seconds', 'read'])",15000);
setTimeout("_gaq.push(['_trackEvent', '30_seconds', 'read'])",30000);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
// == Create a simple hash based on a file checksum
function sr_version_hash($file) {
if(!$file) return false;
$full_path = get_template_directory() . $file;
return hash_file('CRC32',$full_path);
}
<?php
// change to repo directory, run a git pull and echo the output
echo shell_exec("cd /your/repo/path/here && git pull");
die("done " . mktime());
@plasticmind
plasticmind / gist:9260407
Created February 27, 2014 21:53
UIWebView links open in Safari if the URL doesn't match a certain pattern
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
NSString *urlString = request.URL.absoluteString;
// Set the pattern to search the request URL for
NSRange range = [urlString rangeOfString:@"mobile.example.com"];
if (range.location != NSNotFound) {
NSLog(@"%s", "This link matches the pattern and will be loaded in-app within the UIWebView.");
return YES;
} else {
NSLog(@"%s", "This link does NOT match the pattern and will be loaded in Safari.");
@plasticmind
plasticmind / navigate-all
Created February 13, 2014 18:53
Next/Previous: Include multiple post types
/* = Adjust next/previous links to include multiple post types */
/*
* Replacement for get_adjacent_post()
*
* This supports only the custom post types you identify and does not
* look at categories anymore. This allows you to go from one custom post type
* to another which was not possible with the default get_adjacent_post().
* Orig: wp-includes/link-template.php
*
@plasticmind
plasticmind / gist:6799419
Last active December 24, 2015 12:39
All apple-touch-icon permutations...
<!-- non-retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="apple-touch-icon-57x57.png" sizes="57x57">
<!-- non-retina iPad pre iOS 7 -->
<link rel="apple-touch-icon" href="apple-touch-icon-72x72.png" sizes="72x72">
<!-- non-retina iPad iOS 7 -->
<link rel="apple-touch-icon" href="apple-touch-icon-76x76.png" sizes="76x76">
<!-- retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="apple-touch-icon-114x114.png" sizes="114x114">
<!-- retina iPhone iOS 7 -->
<link rel="apple-touch-icon" href="apple-touch-icon-120x120.png" sizes="120x120">
@plasticmind
plasticmind / jquery.infinitescroll.sr.js
Created June 12, 2013 18:11
Behavior for Infinite Scroll jQuery plugin: infinite scrolling doesn't begin until after a manual trigger is clicked.
/*
--------------------------------
Infinite Scroll Behavior
Simply Recipes Mobile Style
: Infinite scroll waits for a one-time manual trigger
--------------------------------
by Jesse Gardner, http://plasticmind.com
*/
$.extend($.infinitescroll.prototype,{
@plasticmind
plasticmind / gist:5262783
Created March 28, 2013 12:34
Bookmarklet: Search this domain
javascript:(function(){ p=prompt('Search this domain for:',''); if(p){ document.location.href='http://www.google.com/search?q=site:'+document.location.href.split('/')[2]+' '+escape(p)} })();
@plasticmind
plasticmind / gist:4339164
Created December 19, 2012 18:31
Confuse and annoy your friends with CSS. Every 20 seconds, blur the screen for 2 seconds.
html {
-webkit-animation: annoy 20s ease alternate infinite;
}
@-webkit-keyframes annoy {
0% { -webkit-filter: blur(0px) }
90% { -webkit-filter: blur(0px) }
100% { -webkit-filter: blur(1px) }
}
@plasticmind
plasticmind / gist:4337952
Created December 19, 2012 16:20
Adds a confirmation dialogue to the WordPress publish button.
/* = Add a "molly guard" to the publish button */
add_action( 'admin_print_footer_scripts', 'sr_publish_molly_guard' );
function sr_publish_molly_guard() {
echo <<<EOT
<script>
jQuery(document).ready(function($){
$('#publishing-action input[name="publish"]').click(function() {
if(confirm('Are you sure you want to publish this?')) {
return true;