Skip to content

Instantly share code, notes, and snippets.

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

Eric Mann ericmann

⚒️
Creating ...
View GitHub Profile
@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: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 );
}

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

<?php
$query_timer = 0;
add_filter( 'do_parse_request', function( $parse ) {
global $query_timer;
$query_timer = microtime( true );
return $parse;
@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 <[email protected]>
* @license MIT
* @copyright 2015 Eric Mann
*/
if ( ! defined( 'ABSPATH' ) ) {

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 / Customfile
Created August 21, 2015 18:23
Hyper-V and Samba Customfile
config.vm.provider :hyperv do |v, override|
override.vm.box = "ericmann/trusty64"
end
config.vm.synced_folders.each do |id, options|
# Make sure we use SMB for file mounts on Windows
if ! options[:type] && Vagrant::Util::Platform.windows?
options[:type] = "smb"
end
end
@ericmann
ericmann / temp-testing-curl.php
Last active August 29, 2015 14:28
Temporary Test Code
/**
* Gets the PURL from the Friendbuy API.
*
* @param string e-mail address
* @returns object API Response
*/
function friendbuy_get_purl( $email ) {
// Verify param is actually an e-mail
if ( ! is_email( $email ) ) {
@ericmann
ericmann / pr.md
Created June 22, 2017 21:05 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ericmann
ericmann / yubikey-reset.sh
Created July 6, 2018 03:37 — forked from pkirkovsky/yubikey-reset.sh
Utility for resetting a Yubikey to factory defaults using gpg-connect-agent. This will wipe out any stored keys and reset PINs to default values.
gpg-connect-agent <<EOF
/hex
scd serialno
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40
scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40