Skip to content

Instantly share code, notes, and snippets.

View stevegrunwell's full-sized avatar

Steve Grunwell stevegrunwell

View GitHub Profile
### Keybase proof
I hereby claim:
* I am stevegrunwell on github.
* I am stevegrunwell (https://keybase.io/stevegrunwell) on keybase.
* I have a public key whose fingerprint is 56A8 ED6A 4437 6DE0 0EE9 3D74 5435 2694 8DF1 91E1
To claim this, I am signing this object:
@stevegrunwell
stevegrunwell / gist:6286357
Created August 20, 2013 19:53
Easily add a new Bitbucket repo on a Redmine server. Add this to the Redmine user's .bash_profile, run `bitbucket-add-repository <slug>`, then add the repo to Redmine project configuration. Modifying this to use with Github is trivial, just update git@bitbucket.org to git@github.com (and update textual references, of course).
# Create a bare clone in ~/git_repositories/{slug}.git
# Before running this command ensure that the repo on Bitbucket has an appropriate deploy key.
# You'll also want to set a POST hook (e.g. http://{redmine}/github_hook?project_id={slug})
#
# Usage: bitbucket-add-repository <slug>
function bitbucket-add-repository {
base=/home/redmine/git_repositories/
if [ -n "$1" ]; then
path=$base$1.git
@stevegrunwell
stevegrunwell / database-backup.sh
Last active December 14, 2017 21:07
Dump each MySQL database and send its backup to Amazon S3. https://engineering.growella.com/automatic-database-backups-amazon-s3/
#!/bin/bash
#
# Backup local databases to Amazon S3.
#
# This script takes a single argument: an S3 bucket name with optional path.
#
# Usage:
# database-backup.sh backup.example.com
# database-backup.sh backup.example.com/some/path
#
#!/usr/bin/env bash
#
# Check a WordPress domain against CVE-2017-8295.
# https://exploitbox.io/vuln/WordPress-Exploit-4-7-Unauth-Password-Reset-0day-CVE-2017-8295.html
#
# Usage:
# ./wordpress-host-check <domain> <username>
#
# <domain>
# The WordPress domain you wish to check. For example, http://example.com.
@stevegrunwell
stevegrunwell / airstory-update-published-posts.php
Created August 8, 2018 14:05
Enable the Airstory WordPress plugin to update published posts as well as drafts. A response to https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
<?php
/**
* Plugin Name: Airstory: Enable Updating of Published Posts
* Plugin URI: https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
* Description: Enable Airstory to update the contents of posts of any post status, not just drafts.
* Version: 0.1.0
* Author: Steve Grunwell
* Author URI: https://stevegrunwell.com
*
* @link https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
@stevegrunwell
stevegrunwell / gist:8578709
Created January 23, 2014 13:51
(Quick and dirty) modification of http://stevegrunwell.com/blog/woocommerce-restrict-shipping/ to help Katie from http://noizepro.com/ with limiting WooCommerce shipping for two shipping methods.
<?php
/**
* Return an array of restricted shipping locations for WooCommerce
*
* Restricted locations include Alaska, American Samoa, Guam, Hawaii, North Mariana Islands, Puerto Rico,
* US Minor Outlying Islands, and the US Virgin Islands
*
* @return array
*/
@stevegrunwell
stevegrunwell / gist:2140268
Created March 20, 2012 19:32
Create a URL-safe slug from a string, useful for creating permalinks
<?php
/**
* Create a URL slug from a string
*
* @param string $str String to create slug from (str)
* @param mixed $limit Limit the number of characters returned (optional)
* @return string
* @author Steve Grunwell
*/
function create_slug($str, $limit=64){
@stevegrunwell
stevegrunwell / functions.php
Created March 15, 2016 18:56
WP404: Send an email to Eric Mann every time there's a 404
<?php
/**
* Email the error log to Eric Mann every time a 404 error occurs.
*
* @param array $report The WP404 report.
* @return array The (untouched) WP404 report.
*/
function mytheme_spam_eric_with_404s( $report ) {
wp_mail(
@stevegrunwell
stevegrunwell / gist:2897997
Created June 8, 2012 20:29
Remove Contact Form 7 scripts and styles through the WordPress action hook API
/**
* Remove Contact Form 7's scripts and styles without having to add anything to wp-config.php (as described
* in the CF7 docs) by using the wpcf7_enqueue_styles and wpcf7_enqueue_scripts actions that Takayuki was
* nice enough to include in includes/controller.php
* @link http://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/
*/
add_action( 'wpcf7_enqueue_styles', function() { wp_deregister_style( 'contact-form-7' ); } );
add_action( 'wpcf7_enqueue_scripts', function() { wp_deregister_script( 'jquery-form' ); } );
@stevegrunwell
stevegrunwell / limit-orders-15min.php
Created May 19, 2020 04:50
Add an "Every 15 minutes" option to Limit Orders for WooCommerce
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - 15min Intervals
* Description: Add an "Every 15 minutes" option to Limit Orders for WooCommerce.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Add "Every 15min" to the list of intervals.