Skip to content

Instantly share code, notes, and snippets.

View morganestes's full-sized avatar

Morgan Estes morganestes

View GitHub Profile
@morganestes
morganestes / Original PHP.tmLanguage
Last active December 23, 2015 01:09
Single-line PHPDocumentor comment highlighting
/\*\*(?:#@\+)?\s*$
@morganestes
morganestes / aliases
Created September 18, 2013 02:19
Aliases used in bash prompts.
alias attrib='chmod'
alias chdir='cd'
alias copy='cp'
alias d='dir'
alias del='rm'
alias deltree='rm -r'
alias dir='/bin/ls $LS_OPTIONS --format=vertical'
alias edit='pico'
alias ff='whereis'
alias l.='ls -d .* --color=auto'
<?php
/**
* Plugin Name: Mdub Cheatahs
* Plugin URI: https://gist.github.com/morganestes/6788575
* Description: Set standard settings to standardize settings sets.
* Version: 0.1.0
* Author: Morgan Estes
* Author URI: http://morganestes.me
* License: GPLv3
*/
@morganestes
morganestes / phptidy-removed-if.php
Created October 2, 2013 18:32
PHPTidy bug report for switches
<?php
// Starting at line 1577 in v2.11
// Remove lines 1577-1593 to get result in switch-modified.php
if (
isset($tokens[$key+1]) and
is_array($tokens[$key+1]) and (
$tokens[$key+1][0] === T_CASE or
$tokens[$key+1][0] === T_DEFAULT or (
isset($tokens[$key+2]) and
is_array($tokens[$key+2]) and (

Financial Times Labs string compression

The first image was converted to base64 using http://www.fourmilab.ch/webtools/base64/. It was then compressed using the C# port of the Financial Times Labs tool. Read more about that process at http://www.codeproject.com/Tips/665467/Porting-the-Financial-Times-JavaScript-String-Comp.

The second image is the decompressed string re-injected as base64.

Both images use http://en.wikipedia.org/wiki/Data_URI_scheme to display the image.

A Pen by Morgan Estes on CodePen.

string 'debug-bar-console/debug-bar-console.php' (length=39)
array
'akismet/akismet.php' =>
array
'Name' => string 'Akismet' (length=7)
'PluginURI' => string 'http://akismet.com/?return=true' (length=31)
'Version' => string '2.5.9' (length=5)
'Description' => string 'Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.' (length=433)
'Author' => string 'Automattic' (length=10)
'AuthorURI' => string 'http://automattic.com/wordpress-plugins/' (length=40)
@morganestes
morganestes / wp-deprecated.php
Last active August 29, 2015 13:56
How to include deprecated functions in older versions of WordPress but not in newer ones.
<?php
/* screen_icon was deprecated in 3.8 */
if ( version_compare( $GLOBALS['wp_version'], '3.8', '<' ) ) {
screen_icon();
}
@morganestes
morganestes / .instructions.md
Last active August 29, 2015 13:57
Navigation based on the page used
  • Create a new PHP file named page-yourcustomnamehere.php.
  • Add /* Template Name: Your Custom Name */ in the top. This name is what you look for in the editor.
  • Add your code (feel free to copy from page.php or index.php and change it to what you need.
  • Create your nav menu and add it to nav.php
  • Create a custom menu and add it to nav-yourcustomnamehere.php
  • Add the code in custom-nav-caller.php example file to where you want your nav to go inside page-yourcustomnamehere.php.

The code looks for a file named nav-{$whatever}.php, where $whatever is the slug of your file. If it exists, it'll include that file. If not, it falls back to nav.php, so it's important that that file exists.

@morganestes
morganestes / me-add-svg-support.php
Last active August 29, 2015 13:58
Add SVG support to a WordPress installation so images display properly in admin pages. https://core.trac.wordpress.org/ticket/26591
<?php
/**
* Plugin Name: Add SVG Support
* Plugin URI: https://gist.github.com/morganestes/10066447
* Description: Adds SVG support to the `.htaccess` file so Chrome displays images in Admin correctly.
* Version: 0.1.0
* Author: Morgan Estes
* Author URI: http://www.morganestes.me
* License: GPLv2
*/
@morganestes
morganestes / heartbleed-version-check.php
Last active January 23, 2020 03:32
Check for Heartbleed vulnerable versions of OpenSSL
<?php
// Version number for 1.0.1g from http://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff;f=crypto/opensslv.h;h=ebe718072333c048a91bdb1f4a295ff84691ba09;hp=aeb40f5e6cd82eb560e4d13b9f4466f01f8d4365;hb=b2d951e4232d2f90168f9a3dd0b7df9ecf2d81a8;hpb=c5993d10a8f28d4448c6161c3a4ca91b68eea78c
if( defined( 'OPENSSL_VERSION_NUMBER' ) && OPENSSL_VERSION_NUMBER < '0x1000107fL' ) {
echo OPENSSL_VERSION_TEXT . ' is out of date and vulnerable to The Heartbleed Bug.' . PHP_EOL;
echo 'Update to version 1.0.1g as soon as possible.';
}