Skip to content

Instantly share code, notes, and snippets.

View shawncampbell's full-sized avatar

Shawn Campbell shawncampbell

View GitHub Profile
/* Uncheck All Twitter Interests */
/* https://twitter.com/settings/your_twitter_data/twitter_interests */
let checkboxes = document.querySelectorAll( "input[type='checkbox']" )
for ( var i = 0; i < checkboxes.length; i++ ) {
if ( checkboxes[i].checked ) { checkboxes[i].click() }
}
@shawncampbell
shawncampbell / log-heroku-config-vars-as-json.js
Created December 18, 2019 00:09
Log Heroku Config Vars as JSON object in Console
// Run jQuery in Console
// @see https://blog.wplauncher.com/run-jquery-in-chrome-console/
var jqry = document.createElement('script');
jqry.src = "https://code.jquery.com/jquery-3.3.1.min.js";
document.getElementsByTagName('head')[0].appendChild(jqry);
jQuery.noConflict();
// Log Heroku Config Vars as JSON in Console
// @see https://blog.wplauncher.com/backup-heroku-config-vars/
var config_vars = {}
@shawncampbell
shawncampbell / already-subscribed.js
Created November 20, 2017 21:34
custom handler for existing subscribers with MailChimp embed forms
// mc.ajaxOptions.success
if (mc && mc.ajaxOptions && mc.ajaxOptions.success) {
mc.ajaxOptions.success = function(resp) {
$ = jQuery
$('#mce-success-response').hide();
$('#mce-error-response').hide();
// On successful form submission, display a success message and reset the form
if (resp.result == "success") {
$('#mce-' + resp.result + '-response').show();
@shawncampbell
shawncampbell / setting_the_client_id_on_the_destination_domain.js
Created March 1, 2017 17:42
Assign Google Analytics Client ID from URL Parameter
// @see https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#setting_the_client_id_on_the_destination_domain
ga('create', 'UA-1813655-3', 'auto', {
'clientId': location.search.match(new RegExp("_ga=[.0-9]*"))[0].slice(4)
});
@shawncampbell
shawncampbell / bookmarklet.js
Created February 23, 2016 23:00
Log all global variables (except standard properties of window)
javascript:(function(){var standardGlobals=['CSS', 'InstallTrigger', '__commandLineAPI', 'alert', 'applicationCache', 'atob', 'blur', 'btoa', 'cancelAnimationFrame', 'captureEvents', 'chrome', 'clearInterval', 'clearTimeout', 'clientInformation', 'close', 'closed', 'confirm', 'console', 'content', 'crypto', 'defaultStatus', 'defaultstatus', 'devicePixelRatio', 'document', 'dump', 'external', 'find', 'focus', 'frameElement', 'frames', 'fullScreen', 'getComputedStyle', 'getDefaultComputedStyle', 'getSelection', 'history', 'indexedDB', 'innerHeight', 'innerWidth', 'length', 'localStorage', 'location', 'locationbar', 'matchMedia', 'menubar', 'moveBy', 'moveTo', 'mozAnimationStartTime', 'mozCancelAnimationFrame', 'mozCancelRequestAnimationFrame', 'mozIndexedDB', 'mozInnerScreenX', 'mozInnerScreenY', 'mozPaintCount', 'mozRequestAnimationFrame', 'name', 'navigator', 'offscreenBuffering', 'onabort', 'onafterprint', 'onbeforeprint', 'onbeforeunload', 'onblur', 'oncanplay', 'oncanplaythrough', 'onchange', 'onclick', 'o
@shawncampbell
shawncampbell / CustomPress YARPP Support
Last active September 3, 2015 03:53
Add YARPP support to WordPress custom post types created with WPMU DEV CustomPress
/**
* CustomPress YARPP Support
*
* Add YARPP support to WordPress custom post types created with WPMU DEV CustomPress
*/
add_action( 'registered_post_type', 'my_custom_post_type_yarpp_support', 10, 2 );
function my_custom_post_type_yarpp_support( $post_type, $args ) {
// Optionally specify a single custom post type
//if ( 'my_custom_post_type' === $post_type ) {
######################################################################
#
# Custom Nginx Server Configuration for WordPress Multisite & Magento
#
# WordPress Multisite installed in root:
# network home => /
# network admin => /wp-admin/
# default blog => /blog/
# site-n => /site-n/
# site-n admin => /site-n/wp-admin/
@shawncampbell
shawncampbell / jquery-pagination.html
Created March 8, 2012 05:52
jQuery Pagination (Proof-of-Concept)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<style type="text/css">
#content {
width: 300px;
height: 240px;
border: 1px solid black;
}
.control {
width: 50px;