Skip to content

Instantly share code, notes, and snippets.

View jbrinley's full-sized avatar

Jonathan Brinley jbrinley

View GitHub Profile
@jbrinley
jbrinley / gist:1762585
Created February 7, 2012 22:29
PHP Downgrade to 5.2 for Ubuntu 10.04
php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# remove all php packge
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# use karmic for php pakage
# pin-params: a (archive), c (components), v (version), o (origin) and l (label).
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@jbrinley
jbrinley / gist:6693934
Created September 25, 2013 01:32
Redirect a user after a successful community events submission.
<?php
/**
* This actually does the redirect. If an event was submitted, and we're about
* to reload the submission page (with a message instead of a form), this will
* redirect to the home page.
*
* @param WP $wp
* @return void
*/
@jbrinley
jbrinley / gist:6848286
Last active February 14, 2016 20:59
Filter Modern Tribe's Events Calendar to show ticket prices from the WooCommerce Tickets add-on. Add this to your theme's functions.php, or put it in an mu-plugin.
function my_wootickets_tribe_get_cost( $cost, $postId, $withCurrencySymbol ) {
if ( empty($cost) && class_exists('TribeWooTickets') ) {
// see if the event has tickets associated with it
$wootickets = TribeWooTickets::get_instance();
$ticket_ids = $wootickets->get_Tickets_ids( $postId );
if ( empty($ticket_ids) ) {
return '';
}
// see if any tickets remain, and what price range they have
@jbrinley
jbrinley / 17817.patch
Created October 17, 2013 12:30
Refactor WordPress hook iteration
Index: src/wp-includes/plugin.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-includes/plugin.php (revision 25823)
+++ src/wp-includes/plugin.php (revision )
@@ -20,7 +20,7 @@
*/
@jbrinley
jbrinley / gist:7025774
Created October 17, 2013 14:21
Temporary fix for rel="canonical" links on recurring events when object caching is enabled
add_filter( 'wp', 'tribe_temporary_filter_canonical_link_on_recurring_events', 10, 1 );
function tribe_temporary_filter_canonical_link_on_recurring_events() {
if ( is_singular(TribeEvents::POSTTYPE) && get_query_var('eventDate') && has_action('wp_head', 'rel_canonical') ) {
remove_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_head', 'tribe_temporary_output_recurring_event_canonical_link' );
}
}
@jbrinley
jbrinley / test_17817.php
Last active December 28, 2015 14:59
17817 Performance Test - Benchmarks the patch submitted at http://core.trac.wordpress.org/ticket/17817
<?php
require_once( dirname( __FILE__ ) . '/test_17817_shared.php' );
if ( isset($_SERVER['HTTP_HOST']) ) { echo "<pre>"; }
printf( "Running %d times with %d callbacks\n", TICKET_17817_LOOP_COUNT, TICKET_17817_CALLBACK_COUNT );
$old_path = dirname( __FILE__ ) . '/test_17817_old.php';
$new_path = dirname( __FILE__ ) . '/test_17817_new.php';
$old_results = unserialize( shell_exec( sprintf( 'php "%s"', $old_path ) ) );
<?php
/**
* Switch the interal blog id.
*
* This changes the blog id used to create keys in blog specific groups.
*
* @since 3.5.0
*
* @param int $blog_id Blog ID
*/
<?php
/*
Plugin Name: The Events Calendar - Downgrade Recurrence
Description: Downgrading from 3.4 to an earlier version of The Events Calendar? Activate this plugin to restore recurrence settings.
Version: 1.0
Author: Modern Tribe, Inc.
Author URI: http://tri.be?ref=tec-plugin
Text Domain: tribe-events-calendar
License: GPLv2 or later
@jbrinley
jbrinley / fill-the-db.php
Created February 19, 2014 14:42
Adds 1M actions to the Action Scheduler queue, with 20K of them already due, and another 100 coming due each minute.
<?php
function action_scheduler_load_testing() {
/** @var wpdb $wpdb */
global $wpdb;
$sql = "INSERT INTO {$wpdb->posts} (post_author, post_date, post_date_gmt, post_content, post_title, post_status, post_name, post_modified, post_modified_gmt, post_type) VALUES ";
for ( $i = -200 ; $i < 9800 ; $i++ ) {
$date = new DateTime($i.' minutes');
$action = md5($i);