Skip to content

Instantly share code, notes, and snippets.

View staylor's full-sized avatar
💭
GitHub is not a social network

Scott Taylor staylor

💭
GitHub is not a social network
View GitHub Profile
<?php
namespace NYT\Cache;
use NYT\{Logger,Singleton};
class ObjectCache {
use Singleton;
const DEFAULT_EXPIRATION = 0;
@staylor
staylor / yolo.php
Last active August 29, 2015 14:11
React is weird/awesome
<?php
class React_YOLO {
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
}
public function admin_menu() {
add_menu_page( 'React', 'React', 'edit_posts', 'react', array( $this, 'page' ) );
}
@staylor
staylor / file-handler.php
Created November 25, 2014 22:05
File download thing
<?php
header( 'Cache-Control: no-cache, no-store' );
header( 'User-Agent: My Cool Download Script' );
header( 'Content-Disposition: inline; filename=TARGET_FILENAME_WITH_NO_PATH' );
header( 'Content-type: MIME_TYPE_OF_FILE;charset=CHARSET_OF_FILE' );
header( 'Vary: Accept-Encoding' );
header( 'Keep-Alive: timeout=15, max=1024' );
header( 'Connection: Keep-Alive' );
// readfile() or echo contents of file, whatever
filter:
excluded_paths:
- 'vendor/*'
- 'tests/*'
- 'src/wp-admin/includes/class-ftp*'
- src/wp-admin/includes/class-pclzip.php
- 'src/wp-content/*'
- 'src/wp-includes/ID3/*'
- 'src/wp-includes/SimplePie/*'
- 'src/wp-includes/Text/*'
@staylor
staylor / truth.php
Created August 16, 2013 18:14
PHP is ridic
<?php
/**
*
* @param array $set
* @param string $prop
* @return boolean
*/
function _truthy_prop( $set, $prop ) {
if ( ! isset( $set[$prop] ) )
return;
// Create the media frame.
mediaFrame = wp.media.frames.formatMedia = wp.media({
frame : 'select',
displaySettings: true,
// Set the title of the modal.
title: $el.data('choose'),
// Tell the modal to show only items matching the current mime type.
library: {
<?php
/**
* Handle oEmbed and embedded media
*
* @param $content
*/
function the_featured_audio( &$content ) {
$url = trim( array_shift( explode( "\n", $content ) ) );
if ( 0 === strpos( $url, 'http://' ) ) {
<?php
/*
Plugin Name: Memcached Redux
Description: The real Memcached (not Memcache) backend for the WP Object Cache.
Version: 3.0
Plugin URI: http://wordpress.org/extend/plugins/memcached/
Author: Scott Taylor - uses code from Ryan Boren, Denis de Bernardy, Matt Martz
Install this file to wp-content/object-cache.php
*/
Set-Cookie: EMID=13cbc37f7e44e825ef0c8; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: oatmeal=em=&rsc=&cc=&t=1000000&e=&r=&p=3&bp=170005&rv=5&pv=2&gme=false&sn=&us=&pu=&tb=&id=&bo=&ris=&purl=%2Fwelcome%2Fhome%2F%3Ffref%3D1000000%26p%3D3%26bp%3D170005&ups=true&crs=true; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: sugar=ftu=false&fd=false&gm=false; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT; Path=/
Set-Cookie: JSESSIONID=67A3F2A395E6D8EBB2EE5677CB9AA8AF.abv-app-04; Path=/
Set-Cookie: oatmeal=em=&rsc=US&cc=US&t=666666&e=&r=&p=111776&bp=&rv=5&pv=2&gme=false&sn=&us=-1&pu=&tb=&id=&bo=&ris=&purl=%2Fwelcome%2Femusic-trial-50-14%2F%3Ffref%3D666666%26p%3D111776%26bp%3D2&ups=true&crs=true; Domain=.emusic.com; Expires=Sun, 06-Feb-2022 23:50:50 GMT;