Skip to content

Instantly share code, notes, and snippets.

View ericmann's full-sized avatar
⚒️
Creating ...

Eric Mann ericmann

⚒️
Creating ...
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ericmann on github.
  • I am eamann (https://keybase.io/eamann) on keybase.
  • I have a public key whose fingerprint is F7CA EACB D776 6264 C62E 0B32 9DC3 CED2 E6A0 7E86

To claim this, I am signing this object:

@ericmann
ericmann / autoloader.php
Created April 24, 2015 23:23
Simple autoloader for WordPress Must-Use plugins. The loader assumes plugins use the format `{plugin-name}\{plugin-name}`.php for their core file. If not, they're skipped.
<?php
/**
* MU-Plugin Autoloader
*
* @author Eric Mann <eric@eamann.com>
* @license MIT
* @copyright 2015 Eric Mann
*/
if ( ! defined( 'ABSPATH' ) ) {
<?php
$query_timer = 0;
add_filter( 'do_parse_request', function( $parse ) {
global $query_timer;
$query_timer = microtime( true );
return $parse;

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

The node.js application runs on a port on your server. We can configure nginx to proxy to this port and also cache so that we don't need to rely on express, the default n

@ericmann
ericmann / gist:8929492
Created February 11, 2014 04:58
Allow Trash Posts
<?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 December 2, 2013 06:00
PHPUnit Protected accessibility example
<?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 December 29, 2015 17:09
Quicky PHPUnit accessiblity example.
<?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 December 19, 2015 11:39
Pseudo-singleton for WordPress.
<?php
class Example {
public function __construct() {
$this->instantiate();
}
public function instantiate() {
static $instance = null;
@ericmann
ericmann / class-wp-cookie-ixr-client.php
Created June 18, 2013 20:05
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.
@ericmann
ericmann / chandra.js
Last active December 17, 2015 14:38
JavaScript routine for modelling the internal structure of white dwarf stars and calculating the Chandrasekhar Limit.
( 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 );