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 / 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 );
<?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 23:59
Predis - a flexible Redis client for 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 August 8, 2019 14:41
Redis-cached WordPress Nginx configuration file.
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 23:46
Default WordPress Nginx configuration file.
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;
}
@ericmann
ericmann / wp-index-redis.php
Last active September 3, 2019 07:48
Alternative Index file for WordPress that uses Redis as a full-page cache.
<?php
/**
* WP Redix Index
*
* Redis caching system for WordPress. Inspired by Jim Westergren.
*
* @author Jeedo Aquino
* @see http://www.jeedo.net/lightning-fast-wordpress-with-nginx-redis/
* @see http://www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/
*/
<?php
$one_off_filter = function( $text ) {
return str_replace( 'something', 'else', $text );
}
add_filter( 'the_content', $one_off_filter );
the_content();
remove_filter( 'the_content', $one_off_filter );
<?php
$post_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'has_been_twittered',
'value' => 'no',
<?php
// Interface
inferface ArchiveElement {
public function do_something();
}
class TC_Video implements ArchiveElement {
public function do_something() {
// does something
}