Skip to content

Instantly share code, notes, and snippets.

View jerclarke's full-sized avatar
🌿

Jer Clarke they/them jerclarke

🌿
View GitHub Profile
@jerclarke
jerclarke / Jer-dnd-combat-notes.md
Last active February 3, 2020 14:52
Jer's reference notes on D&D 5e combat

Jer's reference notes on D&D 5e combat

Surprise

  • The DM determines who might be surprised for the first round of combat
  • If neither side tries to be stealthy, they automatically notice each other.
  • Notice check: DM compares the Dexterity (Stealth) checks of anyone hiding with the passive Wisdom (Perception) score of each creature on the opposing side.
  • Any character or monster that doesn't notice a threat is surprised at the start of the encounter.
  • If you're surprised, you can't move or take an action on your first turn of the combat, and you can't take a reaction until that turn ends.
  • A member of a group can be surprised even if the other members aren't.
@jerclarke
jerclarke / love-poem.php
Last active July 25, 2017 02:16
PHP Love Poem
<?php
try_love();
function try_love() {
echo "<div class='this-world'>";
$me = new Lover ( 'Me' );
@jerclarke
jerclarke / wp_admin_post_thumbnail_html_example.php
Created March 1, 2017 15:38
Demo using WP's admin_post_thumbnail_html filter to insert content in featured image metabox
<?php
/**
* Adds a detailed UI to WP's thumbnail HTML markup used in the Feature Image metabox.
*
* Adds a description of featured images, a listing of the formats used by GV and
* previews of how the images will appear in features slider and thumbnails.
*
* Note that $thumbnail_id is only saved when the post is saved. Immediately after the featured image is changed
* this value is updated, but not the postmeta field in the database (nor OUR fields which are tied to it)
* SO:
@jerclarke
jerclarke / fb-ia-transformation-puzzle.html
Created October 17, 2016 18:49
Facebook iA confounding source markup for transformations
<div class="alignright factbox">
FACTBOX!
<h4>H4 IN A FACTBOX</h4>
NORMAL TEXT WITH A <a href="https://test.com">LINK</a> IN FACTBOX.
<ul>
<li>UL &gt; LI IN FACTBOX</li>
<li>SECOND LI JUST IN CASE</li>
</ul>
</div>
@jerclarke
jerclarke / edit-flow-autosave-comments-not-a-real-plugin.php
Created October 6, 2016 20:55
Edit Flow "plugin" (hack) to autosave unsubmitted Editorial Comment text when post is saved
<?php
/**
* EDIT FLOW: wp_insert_post action to autosave "draft" editorial comments in post meta field
*
* Currently (2016-10-06) Edit Flow has no handling of unsubmitted editorial comments in the textarea
* when the post is saved, so saving your post deletes your comment unless you submitted it, which is awful.
*
* This function hooks into wp_insert_post where the value of the textarea is present (but ignored by default)
* and if found, saves the text (and ID of parent comment if it was a specific reply) to a postmeta field
* keyed on the user who saves the post.
<?php
/*
* Simple function to intentionally crash HHVM and trigger our PHP-FPM fallback
*
* For whatever reason having two "default:"" clauses in a switch statement crashes HHVM but not PHP-FPM
* In HHVM error logs it causes: Fatal error: Switch statements may only contain one default: clause in /var/www/sites/monittest/index.php on line XX
*
* This can be used to intentionally trigger a fallback from HHVM to PHP-FPM in our system, which normally happens
* to avoid scripts with rare HHVM bugs from crashing completely to WSOD, and to keep the server mostly working
* if HHVM failed completely, which has happened a couple of times.
@jerclarke
jerclarke / php-error-test.php
Created March 30, 2016 17:41
Simple PHP script to test display of errors including a fix for displaying inline errors in HHVM
<?php
/*
* Test display of errors in HHVM/PHP
*
* In HHVM and often in normal PHP I want to see notices and errors inline to the
* document. This script tests the ability to make errors visible and has a solution
* that so far works in all the modern PHP and HHVM versions I tried.
*/
echo "<h1>Error test document for PHP</h1>";
@jerclarke
jerclarke / gist:6d5b5bd8179499d12dcc
Created June 15, 2015 12:41
WTF Facebook OG tags that don't work and the meta tags that do
<?php
/**
* Insert site_name meta tag
*/
$site_name = gv_get_site_name();
$site_name_escaped = esc_attr($site_name);
$output .= "<meta property=\"og:site_name\" content=\"$site_name_escaped\" />\n";
// WTF: Also add meta name=cre as site name because NYT uses it and facebook seems to pick it up from them despite it not being in the docs
$output .= "<meta name='cre' content='$site_name_escaped' />\n";
@jerclarke
jerclarke / gist:380897120a928862d93e
Created April 30, 2015 20:00
Filter Geo Mashup to include 'inherit' status when querying for 'attachment' posts
<?php
/**
* Filter geo mashup 'where' clause to insert 'inherit' as a valid status when attachments are being queried
*
* By default geo mashup locations queries (i.e. posts queried inside the map) include the 'attachment' post type
* along with posts when post_type=all BUT it only checks for post_status=publish, so attachments are never part
* of the returned results.
*
* This function filters the 'where' clause of the locations query to add 'inherit' as a valid post status when
* attachments are a valid post type. It won't do anything if attachments aren't already part of the query and
@jerclarke
jerclarke / gist:213de46aa04c95592d3e
Created April 21, 2015 16:32
WordPress: Enable [shortcode] shortcode (real thing) in core WP image captions
<?php
/**
* Filter Caption shortcode attributes to enable the [shortcode] shortcode inside caption text
*
* WP doesn't run do_shortcode on the 'caption' text value parsed out of [caption], which means
* the [shortcode] shortcode doesn't work.
*
* We want [shortcode] to work but not necessarily any other shortcodes, so we will run do_shortcode()
* only if [shortcode] is present. Running do_shortcode() this way will process all shortcodes
* so beware any captions that for some reason also have a bad shortcode that will break formatting.