Skip to content

Instantly share code, notes, and snippets.

View gMagicScott's full-sized avatar

Scott Lesovic gMagicScott

View GitHub Profile
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
@gMagicScott
gMagicScott / README.md
Created April 21, 2014 03:52
Disable jQuery Migrate

I drop this in WPMU_PLUGIN_DIR when developing.

WPMU_PLUGIN_DIR defaults to wp-content/mu-plugins/ but is configurable in wp-config.php

@gMagicScott
gMagicScott / gist:1edf8534a408fbf40607
Created September 30, 2014 22:35
Sudo aware bash prompt
LOGNAME=$(logname)
UUSER=$([ "${LOGNAME}" = "${USER}" ] && echo ${USER} || echo '$(tput setaf 1)${LOGNAME}$(tput sgr0) as ${USER}')
PS1="[${UUSER}@\h \W]\\$ "
add_filter( 'author_link', 'prefix_adjust_author_link', 10, 3 );
function prefix_adjust_author_link( $link, $author_id, $author_nicename ) {
$author_id = intval( $author_id ); // Sanitize
$user_info = get_userdata( $author_id );
if ( ! $user_info ) {
return $link;
}
$link = home_url( '/' ) . 'who/' . $user_info->user_login;
@gMagicScott
gMagicScott / AS Table Highlight
Created September 16, 2012 01:15
jQuery to highlight (add css class) table row for form fields on focus
$(document).ready(function () {
$("input,select,textarea").focus(function() {
$(this).closest("tr").addClass("curFocus")
});
$("input,select,textarea").blur(function() {
$(this).closest("tr").removeClass("curFocus")
});
});
@gMagicScott
gMagicScott / gist:3734672
Created September 16, 2012 22:42
Trigger change event for AS-Birthday
if(CheckPlural(this.value)===1){this.form.field11.selectedIndex=3;$('#field11').change()}
@gMagicScott
gMagicScott / gist:3735034
Created September 17, 2012 00:59
Combined AS-Birthday frontpage test
/*jslint browser:true */
/*global $*/
(function () {
"use strict";
var multiAR, genderField, tomorrowField, childNameField, defaultAR, getGender, changeAR, titleCaseHandler, pluralHandler;
//******************************
// Settings
//******************************
multiAR = 'XXXXXX'; //Multi-Child Autoresponder ID Number
tomorrowField = '#field7'; //Field that holds tomorrow's date
@gMagicScott
gMagicScott / gist:3801735
Created September 28, 2012 19:41
calculate distance between two lat&lng points
function distance($lat1, $lng1, $lat2, $lng2, $miles = true) {
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lng1 *= $pi80;
$lat2 *= $pi80;
$lng2 *= $pi80;
$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;
$dlng = $lng2 - $lng1;
@gMagicScott
gMagicScott / gist:4367337
Last active December 10, 2015 02:28
Amazing System 1ShoppingCart Form Boilerplate
<form name="form1" method="post" action="http://www.mcssl.com/app/contactsave.asp">
<div class="hidden-fields">
<input name="merchantid" type="hidden" value="%%MERCH_ID%%" />
<input name="ARThankyouURL" type="hidden" value="www.1shoppingcart.com/app/thankyou.asp?merchantid=%%MERCH_ID%%" />
<input name="copyarresponse" type="hidden" value="1" />
<input name="custom" type="hidden" id="custom" value="1" />
<input name="defaultar" type="hidden" value="%%DEFAULT_AR%%" />
<input name="allowmulti" type="hidden" value="0" />
<input name="visiblefields" type="hidden" value="Email1" />
<input name="requiredfields" type="hidden" value="Email1" />
http://davidfarr.com/click/all-night-graduation-parties.php?email=%$email$%&Name=%$name$%&Company=%$company$%&Workphone=%$workphone$%&Homephone=%$homephone$%&City=%$city$%&field9=%$custom:field9$%&field2=%$custom:field2$%&auto=yes