Skip to content

Instantly share code, notes, and snippets.

View stephenfeather's full-sized avatar

Stephen Feather stephenfeather

View GitHub Profile
@stephenfeather
stephenfeather / parseFFL.php
Created June 28, 2023 14:37
A PHP function to parse a Federal Firearms License (FFL) number
/**
* Parses the FFL number and extracts relevant information.
*
* @param string $fflNumber The FFL number to parse.
* @return array An array containing the parsed FFL information or an error object.
* If parsing is successful, the array will have the following keys:
* - ffl_number: The full FFL number.
* - region: The region of the FFL.
* - irs_district: The IRS district of the FFL.
* - fips_code: The FIPS code of the FFL.
@stephenfeather
stephenfeather / parseFFL.js
Created June 28, 2023 14:40
A javascript function to parse a Federal Firearms License (FFL) number
/**
* Parses the FFL number and extracts relevant information.
*
* @param {string} fflNumber - The FFL number to parse.
* @returns {object} - An object containing the parsed FFL information or an error object.
* If parsing is successful, the object will have the following properties:
* - ffl_number: The full FFL number.
* - region: The region of the FFL.
* - irs_district: The IRS district of the FFL.
* - fips_code: The FIPS code of the FFL.
@stephenfeather
stephenfeather / cleanUpMaps.sh
Created June 28, 2023 19:52
Bash script to clean up sourceMappingURL references in web files.
#!/bin/bash
# Script: grep_and_remove.sh
# Author: Stephen Feather
# Co-author: OpenAI (ChatGPT)
# Copyright (c) 2023
# All rights reserved.
# License: CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/)
@stephenfeather
stephenfeather / pw-bulk-edit-category-count.php
Created July 3, 2023 23:16
Modification to allow the filtering of products in PW Bulk Edit based upon the number of categories a product is in. (Wordpress, Woocommerce, Pimwick)
<?php
/**
* Modification to allow the filtering of products in PW Bulk Edit based
* upon the number of categories a product is in.
*
* REF: https://www.pimwick.com/pw-bulk-edit/
*
* @author Stephen Feather
* @copyright Copyright (c) 2023
*/
@stephenfeather
stephenfeather / class-delete-schema-command.php
Created July 6, 2023 21:04
This is a quick and dirty fix for Rank Math de-scheming over 60k products on a live site. Shared because Rank Math is too slow to respond. Wordpress, Woocommerce, Rank Math SEO
<?php
/**
* Plugin Name: Delete Schema WP-CLI Command
* Description: Deletes 'rank_math_rich_snippet' meta key and runs delete_schema function for WooCommerce products with 'rank_math_schema_Off' value.
* Version: 1.0.0
* Author: Stephen Feather
* Copywrite: 2023 Stephen Feather
* License: GPL2
*
* @comment As a Rank Math Pro customer we were pretty pissed to find over 60k products with schema disabled. This plugin is a one-off to fix that.
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);