Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan McCue rmccue

View GitHub Profile
View gist:daf72eaffe984f988a0a

Commit Guidelines

Commit messages are one of the most important parts of using version control. Badly written messages make it much harder to see at a glance what's changed in the project.

Commit Content

Keep your commits as small and atomic as possible. The best way to consider this is to think about reverting your commit. That is, if something is wrong in a commit, what are the logically separate parts that could be undone?

@rmccue
rmccue / gist:61b683b61011b96149bb
Created Jun 11, 2014
Experiments in skipping the main WP query
View gist:61b683b61011b96149bb
<?php
add_action( 'setup_theme', function () {
global $wp;
class RM_FakeWP extends WP {
public $skip_query = false;
function main($query_args = '') {
$this->init();
View gist:4a0dadc68aa4e75c851f
<?php
namespace HM\Hotfix;
add_action( 'deleted_option', __NAMESPACE__ . '\\workaround_28701' );
/**
* Workaround cache deletion issue
*
* Ensures that the singular
@rmccue
rmccue / README.md
Created Nov 4, 2014
Commit message syntax highlighting in Vim with submodules
View README.md

Ever tried committing inside a git submodule, only to find that Vim doesn't syntax highlight your commit message? Worry no more!

Simply save the following file as ~/.vim/filetype.vim

@rmccue
rmccue / gist:99df1e545bd8bf45c9b8
Last active Aug 29, 2015
Demo code from WC talk - Requires v2 of the REST API
View gist:99df1e545bd8bf45c9b8
<?php
/**
* Grab latest post title by an author!
*
* @param array $data Options for the function.
* @return string|null Post title for the latest,
 * or null if none.
*/
function my_awesome_func( $data ) {
$posts = get_posts( array(
View proxy
From 253278458860aadf0d25b11351357bcf90c6db7a Mon Sep 17 00:00:00 2001
From: Ryan McCue <me+gist197903@ryanmccue.info>
Date: Tue, 29 Sep 2009 19:41:53 +1000
Subject: [PATCH] Add proxy support. Closes #19
---
simplepie.inc | 78 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/simplepie.inc b/simplepie.inc
@rmccue
rmccue / gist:248095
Created Dec 3, 2009
A quick demo of how to get comments for a Blogger post with SimplePie.
View gist:248095
<?php
$sp = new SimplePie('http://example.com', './cache');
foreach($sp->get_items() as $item) {
echo '<h2>' . $item->get_title() . '</h2>';
$link = $item->get_link(0, 'replies');
if($link) {
$comments = new SimplePie($link);
foreach($comments->get_posts() as $comment) {
echo 'Comment: ' . $comment->get_content();
@rmccue
rmccue / gist:250682
Created Dec 7, 2009
Normalise SimplePie items to put into a database
View gist:250682
<?php
require('simplepie.inc');
$feed = new SimplePie('http://example.com/feed/');
foreach($feed->get_items() as $item) {
$new_item = (object) array(
'hash' => $item->get_id(true),
'timestamp' => $item->get_date('U'),
'title' => $item->get_title(),
'content' => $item->get_content(),
@rmccue
rmccue / gist:250195
Created Dec 6, 2009
Read SimplePie cache without opening SimplePie
View gist:250195
<?php
require('simplepie.inc');
$cache = SimplePie_Cache::create($cache_location, md5($url), 'spc');
// Load data
$data = $cache->load(); // returns instance of SimplePie
// Get timestamp
$time = $cache->mtime(); // returns integer
@rmccue
rmccue / blackout.php
Created Dec 21, 2009
A plugin for the Great Australian Internet Blackout
View blackout.php
<?php
/*
Plugin Name: Blackout your Blog
Description: From Monday, January 25th to Friday, January 29th, Aussie websites will turn their lights out — "black out" — to inform Australians about the threat of imposed Internet censorship. Pledge your support, and install this plugin!
Version: 1.0
Author: Ryan McCue
*/
function blackout_js() {
?>