Skip to content

Instantly share code, notes, and snippets.

<?php
namespace HM\Hotfix;
add_action( 'deleted_option', __NAMESPACE__ . '\\workaround_28701' );
/**
* Workaround cache deletion issue
*
* Ensures that the singular
@mjangda
mjangda / ajaxurl.php
Created August 18, 2011 22:15
Get a domain-mapping safe admin-ajax URL on WordPress.com
<?php
/**
* Generates a domain-mapping safe URL on WordPress.com
* Core's ajaxurl uses admin_url() which returns *.wordpress.com which doesn't work for the front-end on domain-mapped sites.
* This works around that and generates the correct URL based on context.
*/
function my_admin_ajax_url( $path = '' ) {
if ( is_admin() )
$url = admin_url( 'admin-ajax.php' );
else
@jeremyfelt
jeremyfelt / gist:2347611
Created April 10, 2012 00:33
Display excerpt with some tags
<?php
/* Used to display the excerpt of a post across the site. Written very closely with
* wp_trim_excerpt, but instead of stripping out all tags, we want to make sure that
* some basic style still remains as this display function will be used for the index
* and archive templates, not something as plain as a feed or meta description. */
function prefix_display_excerpt( $number_of_words = 55 ) {
global $post;
$content = get_the_content();
$content = strip_shortcodes( $content );
$content = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
@jeremyfelt
jeremyfelt / gist:3006286
Created June 27, 2012 19:35
Rsync repo to repo
repo_to_repo() {
local DEVENV="/directory/to/where/both/repos/are/stored/"
rsync -rv --delete --exclude='.svn' $DEVENV$1/* $DEVENV$2
cd $DEVENV$2
svn status | grep '^!' | awk '{print $2}' | xargs svn rm
svn status | grep '^?' | awk '{print $2}' | xargs svn add
}
@jeremyfelt
jeremyfelt / gist:3094244
Created July 11, 2012 22:42
Local YUI JS Lint Check
js_lint_check() {
local DEVENV=$PWD
local YUICOM="/path/to/yuicompressor/jar/"
cd $YUICOM
java -jar yuicompressor-2.4.7.jar -v $DEVENV/$1 -o $DEVENV/$2
cd $DEVENV
}
@markjaquith
markjaquith / wp-combos.rb
Last active December 10, 2015 16:48
Makes a list of allowed WordPress configurations. Plan to use this to make a vagrant box that has all of them, for testing purposes.
#!/usr/bin/ruby
multisitism = [
:single_site,
:multisite_subdirs,
:multisite_subdomains
]
permalinks = [
:default_permalinks,
<h2>Fullsize Images Tests</h2>
<h3>Captioned (Unlinked)</h3>
[caption id="attachment_2127" align="alignnone" width="1024"]<img class="size-full wp-image-2127" title="Red flower" alt="" src="http://wpthemetestdata.files.wordpress.com/2008/09/test-image-landscape-900.jpg" width="1024" height="685" /> Full - None[/caption]
[caption id="attachment_2127" align="alignleft" width="1024"]<img class="size-full wp-image-2127" title="Red flower" alt="" src="http://wpthemetestdata.files.wordpress.com/2008/09/test-image-landscape-900.jpg" width="1024" height="685" /> Full - Left[/caption]
[caption id="attachment_2127" align="aligncenter" width="1024"]<img class="size-full wp-image-2127" title="Red flower" alt="" src="http://wpthemetestdata.files.wordpress.com/2008/09/test-image-landscape-900.jpg" width="1024" height="685" /> Full - Center[/caption]
[caption id="attachment_2127" align="alignright" width="1024"]<img class="size-full wp-image-2127" title="Red flower" alt="" src="http://wpthemetestdata.files.wordpress.com/
@outmost
outmost / node_beacon.js
Last active December 17, 2015 01:58
Node JS beacon to capture performance metrics from Boomerang.
// Assumptions
// Boomerang makes beacon call to port :8080
// StatsD is running on same server (localhost)
// The following NodeJS modules are installed:
// https://github.com/tobie/ua-parser
// https://github.com/bluesmoon/node-geoip
// Boomerang is configured to send custom parameters for "domain", "page_type", "user_status", "ip" and "user_agent".
// http://lognormal.github.io/boomerang/doc/howtos/howto-5.html
@westonruter
westonruter / readme.md
Last active December 19, 2015 17:38
vassh: Vagrant Host-Guest SSH Command Wrapper/Proxy/Forwarder

THIS REPO HAS MOVED! It has graduated to a dedicated GitHub project: https://github.com/x-team/vassh

The big pain of doing vagrant ssh is that it doesn’t drop you into the corresponding working directory in the Vagrant guest’s synced_folder, so you have to cd to the dir and then run whatever you needed to do (e.g. wp core update). This is the problem that vassh solves: it will make sure you start out in the corresponding directory. So if you’re in your WordPress project on your host machine, all you need to do is:

$ vassh wp core update

There’s also a wrapper called vasshin which will shell you into Vagrant at the current directory, with a prompt for entering commands. This gets you colors and interactive TTY. You can also pass commands as arguments to vasshin to have them executed right away in the colorized TTY (with some additional Vagrant .bash_login echoes and SSH connection close):

@UtahDave
UtahDave / mult-line cmd.run
Last active December 20, 2015 11:39
Multi-line cmd.run wget->tar->rm->cd->make
'''
Redhost functionality
'''
# Import salt libs
import salt.utils
def install_redis():
'''