Skip to content

Instantly share code, notes, and snippets.

View markjaquith's full-sized avatar

Mark Jaquith markjaquith

View GitHub Profile
<?php
function gigaom_script_slug_swap( $pairs ) {
global $wpdb;
foreach ( $pairs as $pair ) {
$_temp_name = $pair[0] . '-gigaom-temp-123456789';
$slugs = "'" . implode( "', '", $pair ) . "'";
$ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_name IN( $slugs ) LIMIT 2" );
$wpdb->update( $wpdb->posts, array( 'post_name' => $_temp_name ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $pair[0] ) );
$wpdb->update( $wpdb->posts, array( 'post_name' => $pair[0] ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $pair[1] ) );
$wpdb->update( $wpdb->posts, array( 'post_name' => $pair[1] ), array( 'post_status' => 'publish', 'post_type' => 'post', 'post_name' => $_temp_name ) );
<?php
/*
Plugin Name: Employee List
Description: Leverages an existing "employee" custom post type to create a shortcode for a list of employees
Version: 0.1
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
function tampa_employee_list() {
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by t.broyer@ltgt.net - fixes diffs that introduce new files
# modified by m@rkj.me - fix sed syntax issue in OS X
#
# Generate an SVN-compatible diff against the tip of the tracking branch
@markjaquith
markjaquith / activate-deactivate-uninstall-example.php
Created March 6, 2011 17:27
Example code for doing activate/deactivate/uninstall hooks in a WordPress plugin
<?php
// Change /*CUSTOMIZE_THIS*/ to a unique name (two places). Go ahead, make it long.
// Like, your initials, and your full plugin name.
// e.g. MTJ_Some_Awesome_Plugin_Controller
/*CUSTOMIZE_THIS*/_Controller::init();
class /*CUSTOMIZE_THIS*/_Controller {
function init() {
@markjaquith
markjaquith / disable-plugins-when-doing-local-dev.php
Created June 24, 2011 10:24
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@markjaquith
markjaquith / cws-posts-per-page.php
Created June 30, 2011 20:21
WordPress plugin example code to correctly set a custom number of posts to display per page, for specific types of views
<?php
/*
Plugin Name: CWS Posts Per Page
Version: 0.1
Description: Sets a custom number of posts to display per page, for specific types of views
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
class CWS_Posts_Per_Page_Plugin {
@markjaquith
markjaquith / fcc.php
Created July 2, 2011 04:43
I hear the FCC wrote a WordPress plugin. This is what I expected it to be.
<?php
class FCC_Safe_Harbor_Indecency_Plugin {
static $instance;
private $seven_dirty = array(
'shit(s|ty|head)?' => '{BLEEP}$1',
'piss(es|ed|ing)?' => '{BLEEP}$1',
'fuck(s|er|ers|ing|ed)?' => '{BLEEP}$1',
'cunt([ys])?' => '{BLEEP}$1',
'cock(sucker[s]?)' => '{BLEEP}$1',
@markjaquith
markjaquith / disable-comments-query.php
Created July 25, 2011 16:08
Disable comments query plugin
<?php
/*
Plugin Name: Disable Comment Querying
Description: Disables comment queries
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@markjaquith
markjaquith / README.md
Created August 16, 2011 19:33
TLC Transients — On the fly WordPress transients with soft expiration and one-liner chained syntax.
@markjaquith
markjaquith / gist:1291960
Created October 17, 2011 04:55
Siri queries

The following are useful queries that Apple's Siri has successfully answered, or tasks it has completed

Location and Directions

  • Where am I?
  • Where is my wife?
  • Show me {city, state}
  • Show me {street address, city, state}
  • Where is the closest {business name | business type}?
  • Show me {business name | business type} in {city, state}
  • Give me directions to {contact}'s {home | house | work}