Skip to content

Instantly share code, notes, and snippets.

View ZachWatkins's full-sized avatar

Zachary K. Watkins ZachWatkins

View GitHub Profile
@ZachWatkins
ZachWatkins / WorkbookReadService.php
Last active June 26, 2025 19:45
Service class for using PHPSpreadsheet to read workbooks with low memory use
<?php
namespace App\Services;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class WorkbookReadService
@ZachWatkins
ZachWatkins / PythonProvider.php
Created May 20, 2025 20:52
Laravel Python Service Class
<?php
namespace App\Contracts;
interface PythonProvider
{
public function run(string $filename, array $options): string;
public function install(): void;
}
@ZachWatkins
ZachWatkins / index.js
Created April 16, 2024 03:28
Convert text to scripting cases
/**
* Change case of text to common programming language cases.
* @param {string} text - Text to change case. May contain spaces, special characters, etc.
* @param {string} caseType - Type of case to change to. Possible values are:
* - camelCase
* - PascalCase
* - snake_case
* - kebab-case
* - CONSTANT_CASE
* - TitleCase
@ZachWatkins
ZachWatkins / vite-plugin-include-html.js
Created January 1, 2024 21:51
Vite plugin for including HTML files like Apache SSI
import fs from 'fs';
export default function includeHtml(mode) {
return {
name: 'insert-views',
/**
* Replace HTML include comments with the content of the included file.
* @param {string} html
* @returns {string}
* @example <!--#include file="header.html" -->
@ZachWatkins
ZachWatkins / README.md
Last active April 17, 2023 15:24
Composer CLI for PHP

Composer CLI for PHP

This is a list of commands or command sets to perform the given task with PHP's package manager.

Upgrade Composer

composer clearcache
composer selfupdate
@ZachWatkins
ZachWatkins / install-on-windows.md
Last active February 9, 2023 04:24
New Laravel and Vue App

Installing on Windows

Open a new Windows Subsystem for Linux session.

$ wsl

Create a new Laravel application. This will take a while so go do something else and come back in about 10 minutes.

$ curl -s "https://laravel.build/laravel-vue-docker?with=mysql,redis,mailpit&devcontainer" | bash

@ZachWatkins
ZachWatkins / .gitignore
Last active November 4, 2022 15:13
WordPress Docker setup for NGINX
/secrets
/persist
@ZachWatkins
ZachWatkins / .editorconfig
Last active November 2, 2022 19:38
Improve VSCode for WordPress Development
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/
root = true
[*]
charset = utf-8
@ZachWatkins
ZachWatkins / 00-repository.php
Created November 14, 2021 06:07 — forked from tommcfarlin/00-repository.php
[Software Development] Using The Repository Pattern in WordPress
<?php
/**
* Serves as a registry for all objects that need to be accessed globally throughout the
* plugin.
*/
class Registry
{
/**
@ZachWatkins
ZachWatkins / remove-user-fields.php
Last active September 1, 2021 16:46
WordPress - Remove User Profile fields
if ( ! function_exists( 'remove_unneeded_account_options' ) ) {
/**
* Removes user settings sections by their heading element pattern.
*/
function remove_unneeded_account_options( $subject ) {
$subject = preg_replace( '#<h2>Personal Options</h2>.+?/table>#s', '', $subject, 1 );
$subject = preg_replace( '#<h2>About Yourself</h2>.+?/table>#s', '', $subject, 1 );
$subject = preg_replace( '#<h2>Author Archive Settings</h2>.+?/table>#s', '', $subject, 1 );
$subject = preg_replace( '#<h2>Author Archive SEO Settings</h2>.+?/table>#s', '', $subject, 1 );
$subject = preg_replace( '#<h2>Layout Settings</h2>.+?/table>#s', '', $subject, 1 );