Skip to content

Instantly share code, notes, and snippets.

View GhostToast's full-sized avatar

Gustave F. Gerhardt GhostToast

View GitHub Profile
@GhostToast
GhostToast / menu_loader_exploder.php
Last active December 19, 2015 03:09
Creates a dropdown menu from a WordPress Nav Menu. Useful for sitting alongside regular menu for use in responsive designs, or where there's no room for a regular menu. Gracefully nests.
<?php
$menu_name = 'topnav'; // or whatever menu you want
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id, array( 'order' => 'DESC' ));
?>
<select class="the-selectors" onChange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">Please Select</option>
<?php
@GhostToast
GhostToast / mstar-menu-limit.php
Created December 3, 2013 17:15
Increase the posts per page in WordPress menu panel
<?php
/*
Plugin Name: Mstar Menu Limit
Description: Increase the posts per page in menu panel
Plugin URI: http://ghosttoa.st
Author: Gustave F. Gerhardt
Author URI: http://ghosttoa.st
License: GPL2
Version: .9
*/
@GhostToast
GhostToast / optimization_test.php
Last active December 30, 2015 11:59
micro optimization!! each test now involves many tests, so average is calculated and indicated in comments. one test was run at a time.
<?php
$foo = 'foo';
$bar = 'bar';
$foobar = 'foobar';
$string = '';
$tests = array();
for ($z = 0; $z<1000; $z++){
$startTime = microtime(true);
@GhostToast
GhostToast / hex-tint.php
Last active August 29, 2015 13:57
Change a hex value by a positive or negative percentage, whether it is 3 or 6 characters in length. Percentage based on max (255), not self. So 100% will always be "#FFFFFF", -100% will always be "#000000"
<?php
/**
* Tint hex color by a percentage
*
* @param string $hex - #FFFFFF or #FFF
* @param int $percentage - Positive or negative
*
* @return string Returns modified $hex, lighter or darker
*/
function hex_tint( $hex, $percentage=0 ) {
@GhostToast
GhostToast / hex2dec.php
Last active August 29, 2015 14:04
Hex Conversions and Comparisons
/**
* Convert hex to decimal, taking care of '#' and length, for comparing hex values
*
* @param $hex
*
* @return number
*/
public function hex2dec( $hex ) {
if ( empty( $hex ) ) {
return $hex;
@GhostToast
GhostToast / cache.php
Created July 26, 2017 15:30
pagely purge path not working
<?php
/**
* Cache functions.
*/
namespace SLC;
use PagelyCachePurge;
/**
@GhostToast
GhostToast / areBarnaclesMollusks.js
Created February 9, 2018 19:49
Function to determine whether Baracles are Mollusks.
function areBarnaclesMollusks() {
return false;
}
@GhostToast
GhostToast / darklight.xml
Created September 28, 2018 13:36
Wear OS watch face switching for Pujie Black with Tasker
<TaskerData sr="" dvi="1" tv="5.2.bf1">
<Task sr="task5">
<cdate>1534903890379</cdate>
<edate>1535060872098</edate>
<id>5</id>
<nme>DarkLight</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>37</code>
<ConditionList sr="if">
Arduino: 1.8.8 (Linux), TD: 1.45, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"
simpleneopixeldemo: In function 'void sendBit(bool)':
simpleneopixeldemo:68: error: '_SFR_IO_ADDR' was not declared in this scope
[port] "I" (_SFR_IO_ADDR(PIXEL_PORT)),
^
simpleneopixeldemo:92: error: '_SFR_IO_ADDR' was not declared in this scope
[port] "I" (_SFR_IO_ADDR(PIXEL_PORT)),
^
simpleneopixeldemo: In function 'void show()':

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: