Skip to content

Instantly share code, notes, and snippets.

View dougwollison's full-sized avatar

Doug Wollison dougwollison

View GitHub Profile
@dougwollison
dougwollison / getotp
Created March 19, 2015 18:11
OTP Generator Python Script
#!/usr/bin/env python
import sys
import base64
import time
import struct
import hashlib
import hmac
# Abort with error if not used properly
@dougwollison
dougwollison / kick
Created March 19, 2015 18:14
Kick user from server (kills all SSH sessions for them)
#!/bin/bash
# Make sure at least the first parameter is set
if [ -z "$1" ]; then
echo "Usage: kick [-d] user"
exit
fi
# Check if the -d flag (delete) is set
if [[ "$1" == '-d' ]]; then
@dougwollison
dougwollison / jquery.removeStyle.js
Created April 8, 2015 21:41
jQuery plugin to remove inline css
jQuery.fn.removeStyle = function( property ) {
// Remove all styles if no property is specified
if ( property === null ) {
return this.removeAttr( 'style' );
}
// Split the property list
var proporties = property.split( /\s+/ );
// Loop through each property and remove them
@dougwollison
dougwollison / googlemaps_url.txt
Created April 16, 2015 14:42
Google Maps Direction URL
https://google.com/maps/?saddr=ORIGIN&daddr=DESTINATION&dirflag=METHOD
# Method = (d)riving | t(r)ansit | (w)alking | (b)icycling
@dougwollison
dougwollison / shortcodes.php.patch
Last active January 21, 2016 00:24
Patch unsupported shortcode tags for WordPress 4.4
add_filter('the_content', function($content){
global $shortcode_tags;
$tagnames = array_keys($shortcode_tags);
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
// Convert [tagname="mainproperty" to [tagname "mainproperty" (still accessible by $atts[0])
$content = preg_replace("/\\[($tagregexp)=/s", '[$1 ', $content);
return $content;
@dougwollison
dougwollison / jquery.maxDimension.js
Created January 21, 2016 20:14
Get max width/height of a collection of objects.
jQuery.fn.maxDimension = function( property ) {
var max = 0;
jQuery( this ).each( function() {
var value = jQuery( this )[ property ]();
if ( value > max ) {
max = value;
}
});
@dougwollison
dougwollison / jquery.cssAnimateTransition.js
Last active February 23, 2016 16:13
jQuery cssAnimate and cssTransition plugins.
(function( $ ) {
// Convert a className string into a classList array
function makeList( string ) {
// trim whitespace
string = ( string || '' ).replace( /^\s+|\s+$/g,'' );
if ( string ) {
return string.split( /\s+/ );
} else {
return [];
}

Keybase proof

I hereby claim:

  • I am dougwollison on github.
  • I am dougwollison (https://keybase.io/dougwollison) on keybase.
  • I have a public key ASBdFwu0vTnNm_o6zyh2Ey8TMn3kWIwX5oU4W77nAWJ_wQo

To claim this, I am signing this object:

@dougwollison
dougwollison / jquery.removeClass.regexp.js
Last active May 12, 2017 18:03
Upgraded jQuery.removeClass, handles Regular Expression
( function( $ ) {
// Store the original method for all other uses
var oldRemoveClass = $.fn.removeClass;
// Replace existing method iwth new version
$.fn.removeClass = function( className ) {
if ( className instanceof RegExp ) {
// Run a regex replace on each element's class name list
return $( this ).each( function() {
var classes = $( this ).attr( 'class' ) || '';
@dougwollison
dougwollison / nlingual-localize_here-fix.php
Last active March 24, 2018 14:00
A fix for nLingual to ensure localized URLs have any extras on the end preserved.
<?php
/*
Plugin Name: nLingual localize_here() fix
Description: A fix for nLingual to ensure localized URLs have any extras on the end preserved.
Version: 1.0.0
Author: Doug Wollison
Author URI: http://dougw.me
License: GPL2
*/