Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dougwollison's full-sized avatar

Doug Wollison dougwollison

View GitHub Profile
/**
* Proxy for the `wp` object, with fallback
* to experimental names and error throwing
* when accessing a non-existent item (intended
* for debugging purposes).
*/
export default new Proxy( {}, {
get( cache, moduleName, reciever ) {
if ( typeof cache[ moduleName ] === 'undefined' ) {
if ( typeof wp[ moduleName ] === 'undefined' ) {
@dougwollison
dougwollison / _map.scss
Last active July 8, 2019 13:26
Google Maps Gutenberg Block
.wp-block-premise-map {
.google-map-canvas {
height: 400px;
background: $color-grey;
}
.google-map-search {
font-size: 16px;
padding: 10px 80px 0 0;
input {
@dougwollison
dougwollison / _menu-icon.scss
Created February 5, 2019 16:21
Transforming Menu Icon
@mixin menu-icon( $width, $height, $thickness ) {
$width: $width * 1px;
$height: $height * 1px;
$thickness: $thickness * 1px;
$margin: (($height - ($thickness * 3)) / 2);
$shift: $margin + $thickness;
.bar {
display: block;
@dougwollison
dougwollison / jquery.regexRemvoeClass.js
Created January 17, 2019 16:17
jQuery removeClass regex support
( function( $ ) {
// Store the original method for all other uses
var oldRemoveClass = $.fn.removeClass;
// Replace existing method iwth new version
$.fn.removeClass = function( className ) {
if ( className instanceof RegExp ) {
// Run a regex replace on each element's class name list
return $( this ).each( function() {
var classes = $( this ).attr( 'class' ) || '';
@dougwollison
dougwollison / nlingual-localize_here-fix.php
Last active March 24, 2018 14:00
A fix for nLingual to ensure localized URLs have any extras on the end preserved.
<?php
/*
Plugin Name: nLingual localize_here() fix
Description: A fix for nLingual to ensure localized URLs have any extras on the end preserved.
Version: 1.0.0
Author: Doug Wollison
Author URI: http://dougw.me
License: GPL2
*/

PGP Public Key Decoding Worksheet

A novice's attempt to understand binary formatting.

Because I was really fucking curious.

The following is a batshit-insane attempt to manually decode a PGP key file, based on the logic used in OpenPGP.js

Keybase proof

I hereby claim:

  • I am dougwollison on github.
  • I am dougwollison (https://keybase.io/dougwollison) on keybase.
  • I have a public key ASBdFwu0vTnNm_o6zyh2Ey8TMn3kWIwX5oU4W77nAWJ_wQo

To claim this, I am signing this object:

@dougwollison
dougwollison / jquery.maxDimension.js
Created January 21, 2016 20:14
Get max width/height of a collection of objects.
jQuery.fn.maxDimension = function( property ) {
var max = 0;
jQuery( this ).each( function() {
var value = jQuery( this )[ property ]();
if ( value > max ) {
max = value;
}
});
@dougwollison
dougwollison / shortcodes.php.patch
Last active January 21, 2016 00:24
Patch unsupported shortcode tags for WordPress 4.4
add_filter('the_content', function($content){
global $shortcode_tags;
$tagnames = array_keys($shortcode_tags);
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
// Convert [tagname="mainproperty" to [tagname "mainproperty" (still accessible by $atts[0])
$content = preg_replace("/\\[($tagregexp)=/s", '[$1 ', $content);
return $content;
@dougwollison
dougwollison / jquery.cssAnimateTransition.js
Last active February 23, 2016 16:13
jQuery cssAnimate and cssTransition plugins.
(function( $ ) {
// Convert a className string into a classList array
function makeList( string ) {
// trim whitespace
string = ( string || '' ).replace( /^\s+|\s+$/g,'' );
if ( string ) {
return string.split( /\s+/ );
} else {
return [];
}