Skip to content

Instantly share code, notes, and snippets.

Avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / sample.html
Created Nov 25, 2020
Sample HTML for benchmarking
View sample.html
<!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 Oct 15, 2020
Ticket 50787 WordPress Core
View 50787.php
/**
* 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 Aug 16, 2020
Making Debug Toolkit plugin a must-use.
View mu_autoloader.php
<?php
require_once __DIR__ . '/debug-toolkit/debug-toolkit.php';
@hellofromtonya
hellofromtonya / longest_consecutive_subsequence_algorithm.py
Created Jun 8, 2019
Algorithm to get the longest sequential (consecutive set of numbers from the given unsorted list.
View longest_consecutive_subsequence_algorithm.py
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 Jun 7, 2019
Finding the Height and Diameter in a Binary Search Tree
View binary_tree.md

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 Mar 19, 2019
Show Custom Taxonomy Panel in the Gutenberg Editor
View books.php
<?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 Mar 19, 2019
Exploring PHP Variables, recount, and copy on write.
View variable-refcount.php
<?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 Mar 5, 2019
Example of unnecessarily calling get_template_directory() over and over again.
View functions.php
<?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 Nov 27, 2018
Allow turning off native AMP when the URL includes a `non-amp` query string.
View non-amp.php
<?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 Jun 24, 2019
UpDevTools must-use autoloader.php file
View mu_autoloader.php
<?php
require_once __DIR__ . '/UpDevTools/bootstrap.php';
You can’t perform that action at this time.