Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / sample.html
Created November 25, 2020 18:46
Sample HTML for benchmarking
<!DOCTYPE html>
<html lang="en-US" class="js svg background-fixed">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>
<title>Blog - Testing page</title>
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link href="https://fonts.gstatic.com" crossorigin="" rel="preconnect">
@hellofromtonya
hellofromtonya / 50787.php
Last active October 15, 2020 11:43
Ticket 50787 WordPress Core
/**
* Return compatibility strings.
*
* @since 5.6.0
*
* @param string $key The key for the particular string.
* Default is false.
* @param string $name Plugin or theme name.
*
* @return string The appropriate compatibilty string.
@hellofromtonya
hellofromtonya / mu_autoloader.php
Created August 16, 2020 19:40
Making Debug Toolkit plugin a must-use.
<?php
require_once __DIR__ . '/debug-toolkit/debug-toolkit.php';
@hellofromtonya
hellofromtonya / longest_consecutive_subsequence_algorithm.py
Created June 8, 2019 02:21
Algorithm to get the longest sequential (consecutive set of numbers from the given unsorted list.
def longest_consecutive_subsequence(input_list):
"""
Gets the longest sequential (consecutive set of numbers from the given unsorted list.
Time complexity is O(n) and space complexity is O(n).
This design uses Python's `range()` function to generate the list of sequential numbers. To accomplish this,
we iterate through the input list to find the least starting number and the number of sequential numbers.
It works on all integers.
@hellofromtonya
hellofromtonya / binary_tree.md
Last active June 7, 2019 17:26
Finding the Height and Diameter in a Binary Search Tree

Finding the Diameter of a Binary Tree

What is the diameter?

The diameter of a binary tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the binary tree.

Edge Cases

The diameter can occur through:

@hellofromtonya
hellofromtonya / books.php
Last active March 19, 2019 19:07
Show Custom Taxonomy Panel in the Gutenberg Editor
<?php
/**
* Adds Books to your website.
*
* @package KnowTheCode\Books
* @author hellofromTonya
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: Books
@hellofromtonya
hellofromtonya / variable-refcount.php
Created March 19, 2019 17:15
Exploring PHP Variables, recount, and copy on write.
<?php
add_action( 'init', function() {
/**
* 1. PHP adds the variable into the symbols table.
* 2. PHP adds the value into the data table, which is called zval.
* 3. PHP points the value location to the variable location, binding them together.
* 4. refcount is incremented to 1.
*/
@hellofromtonya
hellofromtonya / functions.php
Created March 5, 2019 23:26
Example of unnecessarily calling get_template_directory() over and over again.
<?php
// Start the engine.
include_once( get_template_directory() . '/lib/init.php' );
// Setup Theme.
include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
// Set Localization (do not remove).
add_action( 'after_setup_theme', 'altitude_localization_setup' );
@hellofromtonya
hellofromtonya / non-amp.php
Created November 27, 2018 19:50
Allow turning off native AMP when the URL includes a `non-amp` query string.
<?php
/**
* Allow turning off native AMP when the URL includes a `non-amp` query string.
*
* @package Non_AMP
* @author XWP, Google, StudioPress, and contributors
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: Non-AMP
@hellofromtonya
hellofromtonya / mu_autoloader.php
Last active June 24, 2019 14:36
UpDevTools must-use autoloader.php file
<?php
require_once __DIR__ . '/UpDevTools/bootstrap.php';