Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<title>Post Title</title>
</head>
<body>
<header>
<esi:include src="http://my-url.com/rest-api/get/name/user-a" max-age="0" />
</header>
<article>
<h1>Post Title</h1>
@tollmanz
tollmanz / hidpi.txt
Created February 1, 2013 20:05 — forked from simX/hidpi.txt
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@tollmanz
tollmanz / gist:4259320
Created December 11, 2012 15:25
Update option without autoloading it
/**
* Wrapper for adding/updating an option without autoloading it.
*
* @author tollmanz
*
* @uses get_option
* @uses add_option
* @uses update_option
*
* @param string $key Option name.
@tollmanz
tollmanz / gist:4138257
Created November 24, 2012 03:41
Easy sync for git and svn repo
# -s assumes normal branches/tags/trunk structure
git svn clone -s http://svn.my.little.repo.com
# Add the git repo
git remote add git-repo git@github.com:tollmanz/my-little-repo.git
# Pull in the git remote
git fetch git-repo
# Create new tracking branch
@tollmanz
tollmanz / gist:3882534
Created October 13, 2012 00:25
Get Google Analytics Data With Incrementor
<?php
function zt_get_top_posts( $args, $force = false ) {
// Define the cache key
$identifier = md5( maybe_serialize( $args ) );
$cache_key = 'top-posts-' . $identifier;
// Define the cache group
$cache_group = 'zt-ga-data-' . zt_get_incrementor();
// Attempt to get data from cache
@tollmanz
tollmanz / gist:3882524
Created October 13, 2012 00:23
Basic Incrementor/Versioning Pattern
<?php
function get_object( $force = false ) {
$cache_key = 'my-object-' . get_incrementor();
$object = wp_cache_get( $cache_key );
if ( false === $object ) {
$object = regenerate_cached_object();
wp_cache_set( $cache_key, $object, 3600 );
}
@tollmanz
tollmanz / gist:3882215
Created October 12, 2012 23:21
Cache Google Analytics Data with Unique Key
<?php
function zt_get_top_posts( $args, $force = false ) {
// Define our cache key
$identifier = md5( maybe_serialize( $args ) );
$cache_key = 'top-posts-' . $identifier;
// Define the cache group
$cache_group = 'zt-ga-data';
// Attempt to grab data from cache
@tollmanz
tollmanz / gist:3882208
Created October 12, 2012 23:20
Get Google Analytics Data With Variable Arguments
<?php
function zt_get_top_posts( $args, $force = false ) {
// Define our cache key
$cache_key = 'zt-top-posts';
// Attempt to grab data from cache
$top_posts = wp_cache_get( $cache_key );
// If not found in cache or forced, regenerate
if ( false === $top_posts || true === $force ) {
@tollmanz
tollmanz / gist:3882203
Created October 12, 2012 23:19
Cache Google Analytics Data with Variable Args
<?php
function zt_generate_top_posts( $args ) {
// Queries GA, relates to internal posts
$top_post_objects = zt_magic_GA_querier( $args );
// If no objects are returned, exit the function
if ( false === $top_post_objects )
return false;
// Start building the HTML
@tollmanz
tollmanz / gist:3882202
Created October 12, 2012 23:19
Refresh Google Analytics Data on an Interval
<?php
function zt_schedule_ga_refresh() {
if ( ! wp_next_scheduled( 'zt-refresh-top-posts' )
wp_schedule_event( time(), 'zt-refresh-top-posts' );
add_action( 'zt-refresh-top-posts', 'zt_refresh_top_posts' );
}
add_action( 'init', 'zt_schedule_ga_refresh' );