Skip to content

Instantly share code, notes, and snippets.

View rmccue's full-sized avatar

Ryan McCue rmccue

View GitHub Profile
@rmccue
rmccue / gist:4584739
Last active December 11, 2015 10:08 — forked from pippinsplugins/gist:4583339
Code Golf!
<?php
//get the review type based on page custom meta field
function oswc_get_review_meta($postid) {
//try every reasonble conceivable variation that the user my enter to make this as user friendly as possible
$possible = array(
'Review Type',
'review type',
'reviewtype',
'Reviewtype',
// http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
// http://gist.github.com/raw/63002/b53853727856bad494dcbb7ffed4fc17f289af92/gistfile1.rb
// $z is the pnormaldist with power = 0.05. I.e., pnormaldist(1-power/2)
function score($pos, $n) {
if ($n == 0) { return 0; }
$z = 1.95996397158435;
$phat = 1.0*$pos/$n;
return ($phat + $z*$z/(2*$n) - $z * sqrt(($phat*(1-$phat)+$z*$z/(4*$n))/$n))/(1+$z*$z/$n);
}
@rmccue
rmccue / find-local-vars.php
Created January 22, 2012 14:51 — forked from nacin/find-local-vars.php
Find Unset Local Variables
<?php
/**
* Find unset PHP variables
*
* Deals with scope fairly correctly.
*
* Known bugs:
* - Does not yet support `if: ... endif;` (etc)
* - Does not yet support {$a}/${a} (coming soon)
*/
@rmccue
rmccue / plugin-file.php
Created January 17, 2012 12:27 — forked from kovshenin/plugin-file.php
Improved class concept
<?php
/*****
All new versions will be posted at
https://github.com/rmccue/Rotor_WPPlugin
Please use that repository instead of this Gist.
******/
<?php
/*
Plugin Name: Taxononmy Navigation Dropdown
Version: 0.1
Plugin URI: http://anthonycole.me/wordpress/taxonomy-nav-dropdown/
Description: This plugin allows you to add a simple widget linking all of your taxonomies together.
Author: Anthony Cole
Author URI: http://anthonycole.me/
Copyright 2010 Anthony Cole ( email: anthony@radiopicture.com.au )
@rmccue
rmccue / aggregate-feed.php
Created April 22, 2010 08:25 — forked from smajda/aggregate-feed.php
An improved version of the RSS merger
<?php
/* Merge multiple RSS feeds with SimplePie
*
* Just modify the path to SimplePie and
* modify the $feeds array with the feeds you want
*
* You should probably also change the channel title, link and description,
* plus I added a CC license you may not want
*
* Help from: http://www.webmaster-source.com/2007/08/06/merging-rss-feeds-with-simplepie/