Skip to content

Instantly share code, notes, and snippets.

View greatislander's full-sized avatar
⛴️

Ned Zimmerman greatislander

⛴️
View GitHub Profile
@greatislander
greatislander / check_for_production.php
Created August 20, 2013 22:51
Only display analytics code (Google Analytics, GoSquared, etc.) if you are on your production site as opposed to dev or staging.
<?php $production = ( site_url() == 'http://myproductionsite.com' ) ? true : false; // no trailing slash
if ( $production == true && !is_user_logged_in() ) {
// Put your analytics code here.
} ?>
@greatislander
greatislander / copyright_year.php
Created January 3, 2014 22:45
Display appropriate license timespan starting from a certain year, e.g. 2014 if the license began in 2014 and it is currently 2014, or 2013–2014 if the license began in 2013 and it is currently 2014.
@greatislander
greatislander / pr.md
Last active August 29, 2015 14:11 — forked from piscisaureus/pr.md

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 = git@github.com: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:

@greatislander
greatislander / keybase.md
Last active March 8, 2017 18:40
Keybase identity proof.

Keybase proof

I hereby claim:

  • I am greatislander on github.
  • I am greatislander (https://keybase.io/greatislander) on keybase.
  • I have a public key whose fingerprint is B4BA 3C38 2D1C 7717 4F12 E912 D539 BBB6 5132 A204

To claim this, I am signing this object:

@greatislander
greatislander / morse.py
Last active October 1, 2015 04:29
Morse Code for Raspberry Pi + Sense Hat
#!/usr/bin/python
import time
from sense_hat import SenseHat
sense = SenseHat()
duration = 0.3 # length of the dot duration in seconds
on = (255, 255, 255) # on state colour
@greatislander
greatislander / pressbooks-google-scholar.php
Created April 27, 2016 12:50
Extra metadata for Book Information
<?php
function pb_gs_add_meta_boxes() {
x_add_metadata_group( 'google-scholar-metadata', 'metadata', array(
'label' => __( 'Google Scholar Metadata', 'pressbooks-google-scholar' )
) );
x_add_metadata_field( 'citation_title', 'metadata', array(
'group' => 'google-scholar-metadata',
'label' => __( 'Citation Title', 'pressbooks-google-scholar' )
@greatislander
greatislander / pressbooks-lumen-logo.php
Last active May 10, 2016 14:26
Demo override of Pressbooks login logo using new filter hook.
<?php
/* Plugin Name: Lumen Logo */
function lumen_logo() {
$html = "<style type='text/css'>
.login h1 a {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACKCAYAAAAQT3cyAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//U
@greatislander
greatislander / word.php
Last active January 9, 2017 16:37
Custom theme options in a new tab for Pressbooks.
<?php
/*
Plugin Name: Word
Description: Options for Word exports.
Version: 1.0.0
License: GPLv2
*/
namespace Word;
@greatislander
greatislander / hypothesis.php
Created September 16, 2016 17:58
Hypothesis support for custom post types (rough draft)
<?php
$posttypes = apply_filters('hypothesis_supported_posttypes', array(
'post' => 'posts',
'page' => 'pages'
) );
foreach ( $posttypes as $posttype => $name ) {
add_settings_field(
"allow-on-$posttype",
<?php
// Check for the Pressbooks plugin.
if ( ! @include_once( WP_PLUGIN_DIR . '/pressbooks/compatibility.php' ) ) {
add_action( 'admin_notices', function () {
echo '<div id="message" class="error fade"><p>' . __( 'Cannot find Pressbooks install.', 'pressbooks' ) . '</p></div>';
} );
return;
} elseif ( ! pb_meets_minimum_requirements() ) {