Skip to content

Instantly share code, notes, and snippets.

View markjaquith's full-sized avatar

Mark Jaquith markjaquith

View GitHub Profile
@markjaquith
markjaquith / gist:4500280
Last active April 17, 2024 21:06
Bash command to fix a quirk with Sublime Text 2's "subl" command. Sometimes, when using it, under hard-to-pinpoint circumstances, it will open up Sublime Text 2 completely blank (i.e. the file you asked it to open will not be open). This snippet fixes that by essentially kicking subl under the table to wake it up and then passing on the command …
function subl() {
if [[ ! -p /dev/stdin ]]; then
command subl > /dev/null 2>&1
fi
command subl "$@"
}
@markjaquith
markjaquith / gist:6225805
Last active February 21, 2024 23:56
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
@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 / 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',
<?php
/*
Plugin Name: SQMS Remove Menu Items
Plugin URI: http://sequoiaims.com
Description: Plugin for Sequoia MasterSite to remove menu items based on current user level
Author: Ryan Olson
Author URI: http://thatryan.com
Version: 1.1
*/
@markjaquith
markjaquith / suicidal-filter.php
Last active October 22, 2023 23:14
Version of `add_filter()` for WordPress that only runs once
<?php
/*
Use this just like `add_filter()`, and then run something that calls the filter (like
`new WP_Query`, maybe).
That's it. If the filter gets called again, your callback will not be.
This works around the common "filter sandwich" pattern where you have to remember to
call `remove_filter` again after your call.
@markjaquith
markjaquith / wp-config.php
Created August 12, 2013 20:19
`wp-config.php` file to sit above a pristine WordPress directory, whereby the site can symlink their WP directory to a common one, and this file will make sure their `wp-config.php` is the one that gets called. Untested in production. Just an idea right now.
<?php
$path = str_replace( $_SERVER['DOCUMENT_ROOT'], '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
$path_parts = explode( '/', $path );
while ( count( $path_parts ) > 0 ) {
$path = $_SERVER['DOCUMENT_ROOT'] . implode( '/', $path_parts ) . '/wp-config.php';
if ( file_exists( $path ) ) {
include( $path );
break;
} else {
array_pop( $path_parts );
@markjaquith
markjaquith / Laracon US 2023.md
Created July 20, 2023 21:29
Rough notes from Laracon US 2023

These notes are super rough, and I didn’t take notes for a couple sessions. Let me know if you found them useful or they helped you remember things presented at the conference! @markjaquith on Twitter.

Pest PHP

by Nuno Maduro

[!question] How do snapshots work in CI? Won’t there not be an existing snapshot when the tests run?

Cool new features

@markjaquith
markjaquith / gist:2628225
Last active March 29, 2023 23:30
Script to sync WordPress SVN to GitHub
#!/bin/bash
# cd into the directory
cd ~/gitsync/github-wordpress-sync/;
# Make sure we are not already running
if [ -f .sync-running ];then
if test ! `find ".sync-running" -mmin +10`;then
# Currently running, but not stuck
exit 1;
fi
fi;
@markjaquith
markjaquith / nginx.conf
Last active December 25, 2022 15:55
My WordPress Nginx setup
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
}
upstream hhvm {
server unix:/var/run/hhvm/hhvm.sock;
}
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;