Skip to content

Instantly share code, notes, and snippets.

View richardtape's full-sized avatar

Richard Tape richardtape

View GitHub Profile
@richardtape
richardtape / halp.html
Created November 13, 2012 10:56
Workflow
I have a standalone git repo (which is on github) which contains my 'framework'. That framework is a
load of php/css/js/less files, in several subdirectories. I use that framework in all of my projects.
I have another standalone git repo which contains all of my projects.
At the moment, if I update the framework, I then have to copy and paste it into all of my projects,
overwriting the existing stuff in each project folder.
I know! The humanity. Think of the children. But we live in the 21st Century etc.
@richardtape
richardtape / sausage
Created February 1, 2013 13:19
Start of the world's simplest html/css editor, with syntax highlighting. Copy and paste this into your browser url box and hit enter. ToDo: Add a CSS box which then applies to the iframe below. ToDo: Remove the line numbers and spurious 'X' that appears in the iframe ToDo: ? ToDo: Profit.
data:text/html;charset=utf-8, <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/><title>TextEditor</title> <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/> <style> html{height: 100%;} body{background: -webkit-linear-gradient(#f0f0f0, #fff); padding: 3%; height: 94%;} .paper { font: normal 12px/1.5 "Lucida Grande", arial, sans-serif; width: 50%; height: 44%; margin: 0 auto; padding: 0; position: relative; color: #444; line-height: 20px; border: 1px solid #d2d2d2; background: #fff; background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px; background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; -webkit-background-size: 100% 20px; -moz-background-size: 100% 20px;
data:text/html;charset=utf-8, <title>TextEditor</title> <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/> <style> html{height: 100%;} body{background: -webkit-linear-gradient(#f0f0f0, #fff); padding: 3%; height: 94%;} .paper { font: normal 12px/1.5 "Lucida Grande", arial, sans-serif; width: 50%; height: 80%; margin: 0 auto; padding: 6px 5px 4px 42px; position: relative; color: #444; line-height: 20px; border: 1px solid #d2d2d2; background: #fff; background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px; background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; -webkit-background-size: 100% 20px; -moz-background-size: 100% 20px; -ms-background-size: 100% 20px; -o-background-size: 100% 20p
@richardtape
richardtape / how-to-set-up-stress-free-ssl-on-os-x.md
Created March 3, 2017 22:42 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@richardtape
richardtape / nginx-wpcommon.conf
Created July 24, 2014 23:30
nginx rewrite rules for composer-ised WordPress
# First two are for standard WordPress install (non-multisite)
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Remove need for /wp/
rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
@richardtape
richardtape / why-do-i-need-a-filename.hmm
Created September 14, 2017 01:06
wp-cli with sharded databases
# Be *very* careful with this.
# In your wp-config.php file
$db_name = getenv( 'WP_CLI_DB_NAME' );
define( 'DB_NAME', ( !empty( $db_name ) ? $db_name : 'default_global' ) ); # Default often 'wpmu_global'
# Then, when calling wp-cli, if the tables you want are in a shard called prefix_3f
# And you want to grab the comments table for a site with an ID of 10175
WP_CLI_DB_NAME=prefix_3f; export WP_CLI_DB_NAME; wp db export --tables=wp_10175_comments
// See richardtape.com/?p=348
/**
* Is the passed block name one which supports our custom field?
*
* @param {string} name The name of the block.
*/
function isValidBlockType( name ) {
const validBlockTypes = [
const { assign } = lodash;
const { __ } = wp.i18n;
const { Fragment } = wp.element;
const { addFilter } = wp.hooks;
const { TextControl, PanelBody } = wp.components;
const { createHigherOrderComponent } = wp.compose;
const { InspectorControls } = wp.editor;
@richardtape
richardtape / gutenberg-slot-and-fill.js
Created September 12, 2019 21:13
Gutenberg Slot and Fill
// Reduced Example. You'll need to do your imports.
// Add a custom control which contains a Slot
export const exampleAdditionalControl = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
return (
<Fragment>
<BlockEdit { ...props } />
@richardtape
richardtape / 1linenotepad.txt
Created January 30, 2013 18:15
A 1line notepad for in-browser copy and pasteyness
data:text/html;charset=utf-8, <title>TextEditor</title> <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/> <style> html{height: 100%;} body{background: -webkit-linear-gradient(#f0f0f0, #fff); padding: 3%; height: 94%;} .paper { font: normal 12px/1.5 "Lucida Grande", arial, sans-serif; width: 50%; height: 80%; margin: 0 auto; padding: 6px 5px 4px 42px; position: relative; color: #444; line-height: 20px; border: 1px solid #d2d2d2; background: #fff; background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px; background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; -webkit-background-size: 100% 20px; -moz-background-size: 100% 20px; -ms-background-size: 100% 20px; -o-background-size: 100% 20p