Skip to content

Instantly share code, notes, and snippets.

View ptasker's full-sized avatar
:fishsticks:

Peter Tasker ptasker

:fishsticks:
View GitHub Profile
<?php
/*
Plugin Name: Annoying Plugin
Plugin URI:
Description: This is not a plugin
Author: Pete T
Version: 1.0
Author URI:
*/
@ptasker
ptasker / unsplashit-image-importer.sh
Last active December 7, 2016 01:02
Unsplash.it WordPress image importer
#!/usr/bin/env bash
DIR="$1"
COUNT="$2"
WP_DIR="$3"
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]
then
echo "Usage: $0 {photos folder dir path} $1 {number of photos} $2 {Absolute directory where WordPress is installed}"
exit 1
@ptasker
ptasker / default.sh
Created November 11, 2016 19:46
Nginx default server block
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@ptasker
ptasker / wpmdb-list-all-subsites.php
Last active December 8, 2016 16:23
wpmdb-list-all-subsites.php
<?php
/*
Plugin Name: WPMDB - List all subsites
Plugin URI: https://gist.github.com/ptasker/3beaa16a5d0333cf49b0e202eaf40849
Description: Fixes get_sites() calls used in WP Migrate DB Pro to return a list of all sites
Author: Delicious Brains
Author URI: http://deliciousbrains.com
Version: 0.1
Network: True
*/
@ptasker
ptasker / jetpack-override.php
Last active September 29, 2016 16:31
Jetpack option override
<?php
/**
*
* Filter to not migrate the 'jetpack_options' value
*
* @param $options
*
* @return array
*
* From the tweaks plugin:
@ptasker
ptasker / jetpack-form-ajax.js
Last active May 9, 2016 13:59
jQuery submit Jetpack Contact Form
//All the contact forms from Jetpack have the .contact-form class. This _should_ match all of them on a page and work correctly.
$(".contact-form").on('submit', function (e) {
//Wrapper for our form fields to submit via ajax
var formData = {};
var contact_form_id = $(this).find('input[name=contact-form-id]').val();
//Get our form fields here. New fields can be added here as well.
formData['g' + contact_form_id + '-name'] = $('input[name=g' + contact_form_id + '-name]').val();
@ptasker
ptasker / window.open.js
Created February 5, 2016 20:39
window.open in a callback
//Do this first!
window.open("about:blank", "sharer");
var params = {...}
ajaxFunction(function (data) {
var url = 'http://google.ca';
//Refer to the original window here...
var w = window.open(url, 'sharer');
@ptasker
ptasker / Date range
Last active October 15, 2015 14:25
Date range
var monthArray = [];
for(var i in monthly){
var month = monthly[i].split('-')[1];
monthArray.push(months[month]);
}
currStartMonth = monthly[0];
@ptasker
ptasker / redhatpermissions.txt
Last active August 29, 2015 14:27
Apply permissions on RHEL (Redhat) for httpd
sudo setsebool -P httpd_unified 1
@ptasker
ptasker / gist:7b0457df5b9ac6bf20da
Created July 14, 2015 12:36
Git remove deleted files
git diff --diff-filter=D --name-only -z | xargs -0 git rm