Skip to content

Instantly share code, notes, and snippets.

View greatislander's full-sized avatar
🪿

Ned Zimmerman greatislander

🪿
View GitHub Profile
@greatislander
greatislander / hypothesis-test.php
Created October 29, 2016 17:45
Test for Hypothesis custom post type support.
<?php
function hypothesis_test_init() {
register_post_type( 'hypothesis-test', array(
'labels' => array(
'name' => __( 'Hypothesis Tests', 'hypothesis-test' ),
'singular_name' => __( 'Hypothesis Test', 'hypothesis-test' ),
'all_items' => __( 'All Hypothesis Tests', 'hypothesis-test' ),
'new_item' => __( 'New Hypothesis Test', 'hypothesis-test' ),
'add_new' => __( 'Add New', 'hypothesis-test' ),
wp core download
wp core config --dbname="dbname" --dbuser="dbuser" --dbpass="dbpass" --extra-php <<PHP
/* Pressbooks */
define( 'WP_DEFAULT_THEME', 'pressbooks-book' );
define( 'PB_PRINCE_COMMAND', '/usr/bin/prince' );
define( 'PB_KINDLEGEN_COMMAND', '/opt/kindlegen/kindlegen' );
define( 'PB_EPUBCHECK_COMMAND', '/usr/bin/java -jar /opt/epubcheck-3.0.1/epubcheck-3.0.1.jar' );
define( 'PB_XMLLINT_COMMAND', '/usr/bin/xmllint' );
PHP
wp core install --url="http://domain.com" --title="Pressbooks" --admin_user="username" --admin_password="password" --admin_email="[email protected]"
<?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() ) {
@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",
@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 / 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 / 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 / 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 / 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 / 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 = [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: