Skip to content

Instantly share code, notes, and snippets.

View ericandrewlewis's full-sized avatar

Eric Lewis ericandrewlewis

View GitHub Profile
@ericandrewlewis
ericandrewlewis / a.md
Last active October 27, 2020 18:44
The WordPress Customizer

The WordPress Customizer

The WordPress Customizer is an interface for drafting changes to content while previewing the changes before they are saved. This is an alternative to the "save and suprise" model of changing settings without knowing what exactly will happen.

The customizer can be accessed in the admin interface under Appearance > Customize.

A screenshot of the customizer

#19909 is the trac ticket that introduced the Customizer during the 3.4 release cycle.

@ericandrewlewis
ericandrewlewis / gist:f40a7d33729afd787738
Last active June 7, 2019 13:13
Notes On Digital Analytics Fundamentals

Notes On Digital Analytics Fundamentals

Segments1 isolate subsets of your data for analysis. For example, you may want to view trends in how mobile users are interacting with the site. Segments are persistent throughout the Google Analytics interface — they travel with you through each screen. Google Analytics comes with default segments, e.g. Bounced Sessions, Direct Traffic, returning users, tablet users. Custom segments can be created as well, such as NYT web subscribers, NYT home delivery subscribers, etc.

Context compares recorded metrics against either external data (e.g. industry averages) or internal data (e.g. expected unique sessions).

Conversions are desirable user behaviors. A macro-conversion is a heavily desired behavior, e.g. buying a product. A micro-conversion is a behavior that is on the way towards making a macro-conversion, e.g. clicking to read the specs on a product.

Attribution is assi

@ericandrewlewis
ericandrewlewis / gist:4db82d6d3db17bdf9391
Created May 6, 2015 03:08
Every WP plugin file that references wp.media
./2048-number-game/js/settings.js
./2bc-image-gallery/includes/js/2bc-image-gallery-admin.js
./3d-coming-soon-page/admin-folder/admin/redux-framework/ReduxCore/assets/js/media/media.js
./3d-coming-soon-page/admin-folder/admin/redux-framework/ReduxCore/assets/js/media/media.min.js
./3d-coming-soon-page/admin-folder/admin/redux-framework/ReduxCore/inc/fields/gallery/field_gallery.js
./3d-coming-soon-page/admin-folder/admin/redux-framework/ReduxCore/inc/fields/gallery/field_gallery.min.js
./a3-portfolio/assets/js/a3.portfolio.metabox.admin.js
./a3-portfolio/assets/js/a3.portfolio.metabox.admin.min.js
./about-me-page/js/admin.js
./aboutimizer/js/scripts.js
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'subscription_order_payment_onhold_order_status', 10, 2 );
/**
* Catch new subscription orders, and put the order on-hold by default.
*/
function subscription_order_payment_onhold_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( 'processing' != $order_status || ( 'on-hold' != $order->status && 'pending' != $order->status && 'failed' != $order->status ) )
@ericandrewlewis
ericandrewlewis / gist:6664486
Created September 22, 2013 22:30
Good + Bad hook descriptions
<?php
// Bad action description
/**
* Allows you to register custom post types, custom taxonomies, and other general housekeeping tasks after a lot of WordPress core has loaded.
*/
do_action( 'init' );
// Good action description
$welcome_email = 'Dear User,
Your new SITE_NAME site has been successfully set up at:
BLOG_URL
You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
Set your password and log in here: PW_SET_URL
@ericandrewlewis
ericandrewlewis / index.md
Last active February 6, 2019 21:36
PHP Cheat Sheet

PHP is a general purpose programming language with a focus on web programming.

PHP is a dynamically typed language; the type of variables is not known and type-checking occurs at run-time.

function takes_anything($anything) {
	// ...
}

takes_anything( 12345 );
@ericandrewlewis
ericandrewlewis / index.md
Last active January 27, 2019 00:47
Scroll to the rock bottom of a website

Scroll to the rock bottom of a website

Throw the script below in the browser's JS console.

It moves the viewport to the bottom of the page repeatedly with a delay in between. This is useful when the page loads data via infinite scroll and you want to do something with all the data.

const atPageBottom = () => {
  const scrolled = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
  const documentHeightMinusOneViewport =
@ericandrewlewis
ericandrewlewis / gist:a1b127aefbd58c210666
Last active January 19, 2019 00:02
Towards a data model for scalable queries against rich WordPress post attribute data

Towards a data model for scalable queries against rich WordPress post attribute data

This document is in draft status, and is being made available for peer review. If you have feedback, comment on this gist or email me.

Let's say you're a web developer. A client of yours is a gemstone dealer in Manhattan. This dealer has an inventory of gemstones that they'd like to put on their website.

Gemstones have a plethora of attributes: type of gemstone (e.g. sapphire or emerald), price, weight, width, height, depth, color, shape, country of origin, treatment (if it's heat treated), who certified these details, whether the stone is a single stone or a pair.

You're offered the task to make a website to display the gemstone inventory, which will include a search interface. So a user can say "I want to see sapphires that are no heavier than 1.33 karats that are oval, between $750 and $1250, between 1.11mm and 1.20mm that weren't heat treated, because heat treatment is cheap."

@ericandrewlewis
ericandrewlewis / gist:cd95f926a86dab93c22375a863539f9e
Last active December 20, 2018 23:15
Waveforms and timbre "article" outline

Thanks for offering to look at this! Any feedback you have is appreciated.

I've been making snack-sized articles that run code, and considering writing one for introductory synthesizer concepts of oscillator waveforms and timbre.

The Web Audio API is super cool. I've been playing around with it, mostly with the nice and "declarative" wrapping library Tone.js.

I'm planning on using it to include visualizations and offer readers a synth they can play with in the zxcvbn neighborhood of their keyboard.

Some things in my mind:

  • This is an opportunity to make a really different experience rather than a straight-reading article, and I'm not sure my plan is weird enough yet.