Skip to content

Instantly share code, notes, and snippets.

View wturnerharris's full-sized avatar

Wes Turner-Harris wturnerharris

View GitHub Profile
@wturnerharris
wturnerharris / db_sanitization_wordpress.php
Created December 28, 2016 17:26
Sanitize DB for WooCommerce in MultiDev
<?php
function _sustain_disable_fulfillment_plugin() {
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-admin/includes/plugin.php' );
}
deactivate_plugins( 'woocommerce-fulfillment/woocommerce-fulfillment.php', true );
}
@wturnerharris
wturnerharris / gitlab_changelog.php
Last active December 28, 2016 20:11
Get commit messages from merge requests, to be run on CLI
<?php
if ( php_sapi_name() !== "cli" )
{
exit(1);
}
// Curl response headers
class CurlResponse
{
var $headers;
@wturnerharris
wturnerharris / restrict-ip.php
Last active October 18, 2016 21:36
Restrict server access by whitelisting ip addresses - constructor accepts the request path
<?php
class IP_Access {
public $is_restricted = false;
private $protected_ips = array(
"..."
);
function __construct($request)
{
@wturnerharris
wturnerharris / a2ensite
Last active September 2, 2016 20:17 — forked from kevinmesiab/a2ensite
Enables a2ensite functionality in OSX for Apache virtual hosts
#!/bin/bash
#########################################
#
# This script enables apache virtual hosts
# by creating symlinks in
#
# /private/etc/apache2/sites-enabled
#
# that point to vhost conf files in
#
@wturnerharris
wturnerharris / change_author.sh
Created May 2, 2016 20:11
Change author for commits in range
#!/bin/bash
TARGET_GIT_AUTHOR_NAME="username"
TARGET_GIT_AUTHOR_EMAIL="name@email.com"
TARGET_GIT_COMMIT_SHA1_HASH="a1808eedadf1a8ecfa56d6a6625fe3c59d648315"
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "$TARGET_GIT_AUTHOR_NAME" ];
then export GIT_AUTHOR_NAME="$TARGET_GIT_AUTHOR_NAME"; export GIT_AUTHOR_EMAIL="$TARGET_GIT_AUTHOR_EMAIL";
fi; git commit-tree "$@"' $TARGET_GIT_COMMIT_SHA1_HASH..HEAD
@wturnerharris
wturnerharris / delete_branches.sh
Created May 2, 2016 20:07
Remove all your local git branches but keep master
#!/bin/bash
# from within git repo
git checkout master && git branch | grep -v "master" | xargs git branch -D
@wturnerharris
wturnerharris / gitlab-deploy.php
Created September 1, 2015 22:52
This script will perform some tasks on a staging environment to simulate a full-on auto-deployment routine in gitlab
<?php
/**
* Auto Deployment Script for GitLab. Uses apache + php to perform tasks.
*
*
* @since deploy 0.2
*/
/**
* @internal The following variables are assumed to be valid but minimal validation is performed.
@wturnerharris
wturnerharris / wp_docker.sh
Last active August 29, 2015 14:18
quick docker init script
#!/bin/bash
if [ $# -eq 0 ]; then
printf "===> Needs s fully-qualified git repo\n"
exit
fi
printf "===> Installing dependencies...\n"
apt-get install -y wget nano git
@wturnerharris
wturnerharris / reload.sh
Created January 20, 2015 20:55
This script reloads the top-most Chromium window and alerts any tty windows
#!/bin/bash
# set display
export DISPLAY=":0"
# set var to retrieve window id
WID=$(xdotool search --onlyvisible --class chromium|head -1)
# reload window according to cron schedule
if [ -n $WID ]; then
@wturnerharris
wturnerharris / config.txt
Last active August 29, 2015 14:13
Raspberry Pi configuration file. This configures general layout and board overclocking properties.
# uncomment if you wish to disable the splash screen
disable_splash=1
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1