Skip to content

Instantly share code, notes, and snippets.

@blobaugh
blobaugh / speedtestssh.sh
Created December 1, 2016 15:44
Speedtest ssh connection - bash function
speedtestssh() {
# Verify we have a host to check agains
[[ -z "$1" ]] && {
echo "You must provide an ssh host" ;
return;
}
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "\n${RED}Press CTRL-C to exit test${NC}\n";
@blobaugh
blobaugh / mysql_backup.sh
Created August 30, 2016 20:29
Quick and dirty db backup. Stores backups for 30 days
#!/bin/bash
# Database credentials
user="USERNAME"
password="PASSWORD"
host="HOST"
db_name="DATABASE"
# General config
backup_path="/WHERE/TO/PUT/BACKUP/FILE"
@blobaugh
blobaugh / sep_logs_by_date.sh
Last active May 25, 2016 17:15
Seperate a PHP log file by date
#!/bin/bash
# Location of log file is passed in as the first parameter
# Get a list of all the dates in the file
DATES="$(grep "2016" $1 | cut -d ' ' -f 1 | sort | uniq)"
for i in ${DATES}; do
# $i contains the string of the date we are looking at
# Remove the leading [ to prevent grep regex errors
@blobaugh
blobaugh / mysql_who.pl
Created February 29, 2016 16:57
Who is connected to a mysql server
#!/usr/bin/perl
use DBI;
use 5.010;
use Getopt::Long;
# Set defaults
my $host = 'localhost';
my $db = 'information_schema';
my $user = '';
@blobaugh
blobaugh / gist:7977545
Created December 15, 2013 20:13
server from wpcom
<?php
/*
Plugin Name: Serve from WordPress.com
Plugin URI: http://github.com/blobaugh/serve-from-wordpress-com
Description: Switches the URL on built-in WordPress javascript files to serve from WordPress.com rather than locally
Author: Ben Lobaugh
Version: 0.6
Author URI: http://ben.lobaugh.net
*/
@blobaugh
blobaugh / gist:7223022
Created October 29, 2013 21:32
Add additional support for Infinite Scroll in Jetpack
function tweakjp_custom_is_support() {
$supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() );
return $supported;
}
add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );
@blobaugh
blobaugh / gist:6330219
Created August 24, 2013 20:21
Add custom post type to Jetpack
function tweakjp_allow_cpt( $allowed_post_types ) {
// my_cpt is the name of your <span class="hilite">Custom</span> <span class="hilite">Post</span> <span class="hilite">Type</span>
$allowed_post_types[] = 'my_cpt';
return $allowed_post_types;
}
add_filter( 'rest_api_allowed_post_types', 'tweakjp_allow_cpt' );
@blobaugh
blobaugh / wp-seo-no.php
Created December 17, 2015 19:41
Prevents WP SEO from requesting updates
add_filter( 'site_transient_update_plugins', 'wds_wp_seo_no_update' );
function wds_wp_seo_no_update( $value ) {
if ( empty( $value ) || empty( $value->response['wordpress-seo/wp-seo.php'] ) ) {
return $value;
}
unset( $value->response['wordpress-seo/wp-seo.php'] );
return $value;
}
@blobaugh
blobaugh / gist:5165152
Created March 14, 2013 20:54
options.php in plugin
<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
* If the identifier changes, it'll appear as if the options have been reset.
*
*/
function optionsframework_option_name() {
@blobaugh
blobaugh / gist:5165142
Created March 14, 2013 20:53
Original options.php
<?php
// Grab the original options.php file
require_once( WOT_PLUGIN_DIR . '3rd-party/options.php' );
add_filter( 'wot_options_page', 'wot_theme_add_options' );
/**
* Add any custom fields that are required to the options framework