Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Jaquith markjaquith

View GitHub Profile
View gist:523972
<?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 ) );
View employee-list.php
<?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() {
View git-svn-diff.sh
#!/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 Mar 6, 2011
Example code for doing activate/deactivate/uninstall hooks in a WordPress plugin
View activate-deactivate-uninstall-example.php
<?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 Jun 24, 2011
Disables specified WordPress plugins when doing local development
View disable-plugins-when-doing-local-dev.php
<?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 Jun 30, 2011
WordPress plugin example code to correctly set a custom number of posts to display per page, for specific types of views
View cws-posts-per-page.php
<?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 Jul 2, 2011
I hear the FCC wrote a WordPress plugin. This is what I expected it to be.
View fcc.php
<?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 Jul 25, 2011
Disable comments query plugin
View disable-comments-query.php
<?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 Aug 16, 2011
TLC Transients — On the fly WordPress transients with soft expiration and one-liner chained syntax.
View README.md
View gist:1291960

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}
You can’t perform that action at this time.