Skip to content

Instantly share code, notes, and snippets.

Tonya Mork hellofromtonya

View GitHub Profile
@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';
@hellofromtonya
hellofromtonya / gutenberg-amp-img.txt
Created Jul 24, 2018
Post Content -> Wide Image Alignments with Gutenberg Image Blocks
View gutenberg-amp-img.txt
<!-- wp:paragraph -->
<p>Welcome to image alignment! The best way to demonstrate the ebb and flow of the various image positioning options is to nestle them snuggly among an ocean of words. Grab a paddle and let's get started.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>On the topic of alignment, it should be noted that users can choose from the options of <em>None</em>, <em>Left</em>, <em>Right, </em>and <em>Center</em>. In addition, they also get the options of <em>Thumbnail</em>, <em>Medium</em>, <em>Large</em> &amp; <em>Fullsize</em>.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>The image below happens to be a full sized, <em><strong>centered</strong></em><strong> Gutenberg Image Block.</strong></p>
@hellofromtonya
hellofromtonya / classic-amp-img.html
Last active Jul 24, 2018
<amp-img> Wide Image HTML Comparison - classic image vs. Gutenberg image block
View classic-amp-img.html
<figure class="aligncenter amp-wp-b50f343">
<amp-img src="https://amp-wp.test/wp-content/uploads/2013/03/image-alignment-580x300.jpg" alt="Image Alignment 580x300" width="580" height="300" class="size-full wp-image-967 amp-wp-enforced-sizes amp-wp-c5a25c2 i-amphtml-element i-amphtml-layout-intrinsic i-amphtml-layout-size-defined i-amphtml-layout" srcset="https://amp-wp.test/wp-content/uploads/2013/03/image-alignment-580x300.jpg 580w, https://amp-wp.test/wp-content/uploads/2013/03/image-alignment-580x300-300x155.jpg 300w" sizes="(max-width: 580px) 100vw, 580px" layout="intrinsic" style="width: 580px;">
<i-amphtml-sizer class="i-amphtml-sizer">
<img class="i-amphtml-intrinsic-sizer" src="data:image/svg+xml;charset=utf-8,&lt;svg height=&quot;300px&quot; width=&quot;580px&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot;/&gt;">
</i-amphtml-sizer>
<img decoding="async" alt="Image Alignment 580x300" srcset="https://amp-wp.test/wp-content/uploads/2013/03/image-alignment-5
@hellofromtonya
hellofromtonya / class-wp-offline-page.php
Last active Jul 15, 2018
Remove Page Attributes from Specific Page.
View class-wp-offline-page.php
<?php
class WP_Offline_Page {
/**
* Initializes the instance.
*/
public function init() {
add_action( 'current_screen', array( $this, 'remove_page_attributes' ) );
// other code removed.
You can’t perform that action at this time.