Skip to content

Instantly share code, notes, and snippets.

Creating ...

Eric Mann ericmann

Creating ...
Block or report user

Report or block ericmann

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ericmann
ericmann / gist:8929492
Created Feb 11, 2014
Allow Trash Posts
View gist:8929492
<?php
class My_Post_Work {
public function __construct() {
add_action( 'init', array( $this, 'custom_rewrites' ) );
add_filter( 'posts_results', array( $this, 'make_trash_public' ), 10, 2 );
add_filter( 'the_posts', array( $this, 'make_trash_private' ), 10, 2 );
}
@ericmann
ericmann / gist:7745729
Created Dec 2, 2013
PHPUnit Protected accessibility example
View gist:7745729
<?php
/**
* This class contains one protected method we wish to test.
* In reality, it would also contain several public methods,
* but that's immaterial to our discussion.
*
* @pacakge Tutorials
*/
class ClassToTest {
/**
@ericmann
ericmann / gist:7702180
Last active Dec 29, 2015
Quicky PHPUnit accessiblity example.
View gist:7702180
<?php
/**
* This class contains two private methods we wish to test.
* In reality, it would also contain several public methods,
* but that's immaterial to our discussion.
*
* @package Tutorials
*/
class ClassToTest {
/**
@ericmann
ericmann / gist:5949377
Last active Dec 19, 2015
Pseudo-singleton for WordPress.
View gist:5949377
<?php
class Example {
public function __construct() {
$this->instantiate();
}
public function instantiate() {
static $instance = null;
@ericmann
ericmann / class-wp-cookie-ixr-client.php
Created Jun 18, 2013
Build an IXR_Client object that uses WordPress' built-in HTTP request layer as a transport, while still passing user cookies along with the request.
View class-wp-cookie-ixr-client.php
@ericmann
ericmann / chandra.js
Last active Dec 17, 2015
JavaScript routine for modelling the internal structure of white dwarf stars and calculating the Chandrasekhar Limit.
View chandra.js
( function( window, undefined ) {
var md, rd;
// Constants
var MU = 2.0;
G = 6.626 * Math.pow( 10, -8 ),
PI = 3.14159,
MS = 1.989 * Math.pow( 10, 33 ),
RS = 6.96 * Math.pow( 10, 10 ),
CSQ = Math.pow( 2.9979 * Math.pow( 10, 10 ), 2 );
View gist:5605333
<?php
$post_ids = array( 1, 2, 3, 4 );
foreach ( $post_ids as $post_id ) {
$post = get_post( $post_id );
if ( null === $post ) {
continue;
}
@ericmann
ericmann / predis.php
Created May 11, 2013
Predis - a flexible Redis client for PHP
View predis.php
<?php
namespace Predis;
class PredisException extends \Exception { }
class ClientException extends PredisException { } // Client-side errors
class AbortedMultiExec extends PredisException { } // Aborted multi/exec
class ServerException extends PredisException { // Server-side errors
public function toResponseError() {
return new ResponseError($this->getMessage());
@ericmann
ericmann / default-cached.conf
Last active Aug 8, 2019
Redis-cached WordPress Nginx configuration file.
View default-cached.conf
server {
listen 80;
server_name XX.XX.XX.XX;
root /var/www/html/default;
location /index.php {
alias /var/www/html/default/wp-index-redis.php;
}
location / {
@ericmann
ericmann / default.conf
Created May 11, 2013
Default WordPress Nginx configuration file.
View default.conf
server {
listen 80;
server_name XX.XX.XX.XX;
root /var/www/html/default;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
You can’t perform that action at this time.