Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@DrewAPicture
DrewAPicture / gistmerge.sh
Last active August 15, 2016 18:12
Script to merge a Gist fork into your original. You'll need the id of your Gist and the id of the fork.
#!/bin/bash
# usage: ORIG=###### NEW=###### ./gistmerge.sh
# $ORIG = The Gist ID of your Gist
# $NEW = The Gist ID of the fork
# Note: chmod u+x gistmerge.sh may be necessary
# if you're getting permissions errors
printf "\n\n... Cloning original Gist.\n\n"
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
for i in `cat unusual.txt`; do echo "$RANDOM $i"; done | sort | sed -E 's/^[0-9]+ //' > randorder.txt
@DrewAPicture
DrewAPicture / plugin_repo_bookmarklet.html
Last active December 19, 2015 18:09
Plugin Repo bookmarklet. Clicking this bookmarklet while on any WordPress.org-hosted plugin page or sub-page will jump you to the trunk directory of that plugin's SVN repository..
<a href="javascript:(function(){var split=window.location.pathname.split('/');location.href='http://plugins.svn.wordpress.org/' + split[2] + '/trunk/'})();">Plugin Repo</a>
@DrewAPicture
DrewAPicture / ww_svn_log_props.php
Last active December 19, 2015 13:18
SVN log props counter. WordPress function to trawl the commits log and count props. Counts are more accurate after removing the array_reduce(). Still not totally accurate.
<?php
/**
* List contributor props from most to least
*
* @param string $url (optional) The SVN repo URL.
*/
function ww_svn_log_props( $url = 'http://core.svn.wordpress.org/trunk' ) {
$log = get_transient( '36_log' ); // 12 Hour transient
if ( ! $log ) {
$log = shell_exec( 'svn log -r 23171:HEAD --xml ' . esc_url( $url ) );
@DrewAPicture
DrewAPicture / 36_props.sh
Last active December 19, 2015 13:09
WordPress props between two revisions. Requires ack or grep (just replace ack calls with grep).
svn log http://develop.svn.wordpress.org/trunk -r 26861:HEAD | ack -i "props" | ack -ic "DrewAPicture"
@DrewAPicture
DrewAPicture / first.css
Created June 13, 2013 17:54
Working with this list of footer links (it's coming from a wp_nav_menu() call), I need to select only the first href inside the first list item.
<nav>
<div>
<ul>
<li>
<a href="#">First</a>
</li>
<li>
<a href="#">Second</a>
</li>
<li>
@DrewAPicture
DrewAPicture / git.sh
Created May 30, 2013 03:59
Branch highlighting
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
@DrewAPicture
DrewAPicture / gist:5506043
Created May 2, 2013 22:44
New Functions in 3.6
wp_add_id3_tag_data()
wp_read_video_metadata()
wp_read_audio_metadata()
wp_nav_menu_disabled_check()
wp_nav_menu_update_menu_items()
do_accordion_sections()
wp_slash()
wp_unslash()
wp_is_writable()
wp_auth_check_load()
@DrewAPicture
DrewAPicture / wp_core_doc_tags.sh
Last active December 15, 2015 22:19
This script returns counts for the ~20 most-used phpdoc @tags used in WordPress core as of 3.6 Beta 1. Uses ack to get the counts.
#!/bin/bash
# Return counts for 20 phpDoc @tags used in WordPress core
# @tags array
tags=( @var @package @subpackage @since @link @deprecated @param @return @access @name @copyright @author @license @version @see @uses @internal @TODO @global @result @option @method )
echo "Total @tags to search: ${#tags[*]}"