Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / pest_gherkin.php
Last active December 12, 2025 13:00
Pest - Gherkin Formatted Test Names
<?php
function feature(string $feature, callable $callable): void
{
group('Feature: ' . $feature, $callable); // Call Pest's group() method with the feature part of the Gherkin string.
}
function given(string $given)
{
return new class($given) implements Stringable {
@ziadoz
ziadoz / stripe-checkout.html
Last active December 9, 2025 10:07
Custom Stripe Checkout Button
<form action="." method="post">
<noscript>You must <a href="http://www.enable-javascript.com" target="_blank">enable JavaScript</a> in your web browser in order to pay via Stripe.</noscript>
<input
type="submit"
value="Pay with Card"
data-key="PUBLISHABLE STRIPE KEY"
data-amount="500"
data-currency="cad"
data-name="Example Company Inc"
@ziadoz
ziadoz / composer_path.json
Last active November 19, 2025 12:02
Composer Using Local Repositories and Branches
{
"repositories": [
{
"type": "path",
"url": "../relative/project/path"
}
],
"require": {
"${project}": "dev-${branch}"
}
@ziadoz
ziadoz / fix-osx-wifi-battery-drain.md
Last active November 19, 2025 10:35
Fix OSX battery draining on sleep due to wifi activity

Fix OSX battery draining on sleep due to wifi activity

Install SleepWatcher using Homebrew:

sudo chown -R $(whoami) /usr/local
brew update
brew install sleepwatcher

Start the SleepWatcher service:

@ziadoz
ziadoz / env-object.php
Last active October 22, 2025 09:10
PHP Read Only Env Var Object
<?php
declare(strict_types=1);
// A PHP library like Pydantic settings where a config object maps automatically to env vars.
// The object should be read-only. Super simple in scope.
// Attributes: Env\String(), Int, Float, Bool, ArrayList, ArrayMap, Laravel Collection OptionsMap (list of allowed values) DSN, JSONMap, JSONArray, Nullable* Enums, Constants (e.g. PDO_* etc.). Default parameter. Prefixed, Fallback. Callable(fn () => ...)
// Ability to read from $_ENV or getenv(). Need two "Reader" classes. Reader could handle PREFIX_ stuff more naturally.
// EnvReader::set(new ServerEnvReader()), EnvReader::get()
// new GetEnvReader(), new PrefixedEnvReader(new GetEnvReader()), new FallbackEnvReader(..., ...)
// new DotEnvReader(), loads using dot env package, then reads from vars rather than set in $_ENV.
@ziadoz
ziadoz / extension_versions.php
Created October 16, 2025 16:16
PHP Extension Versions
<?php
foreach (get_loaded_extensions() as $extension) {
echo "$extension: " . phpversion($extension) . "\n";
}
@ziadoz
ziadoz / DownloadController.php
Last active October 16, 2025 11:07
Laravel 12.x - Download Zip of Multiple Files
<?php
class DownloadController extends Controller
{
public function download(Request $request): StreamedResponse
{
$filename = 'unique-filename.zip';
$checksum = base64_encode(hash('xxh128', $filename, true));
if (in_array($checksum, $request->getETags())) {
@ziadoz
ziadoz / install.sh
Last active October 4, 2025 06:28
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
@ziadoz
ziadoz / macos-ms-teams-audio-driver-issues.txt
Last active September 24, 2025 01:43
macOS Microsoft Teams Audio Driver Issues
In the middle of a Zoom call my audio in/out devices changed to “Microsoft Teams Audio Devices”, despite no longer having Microsoft Teams installed.
It turns out Teams leaves its audio driver on your system running, and it occasionally decides to make itself the default.
I had to delete: /Library/Audio/Plug-Ins/HAL/MSTeamsAudioDevice.driver in the end to fix it:
sudo rm -rf /Library/Audio/Plug-Ins/HAL/MSTeamsAudioDevice.driver
https://forums.macrumors.com/threads/how-to-uninstall-core-audio-driver-msteamsaudiodevice-driver.2344450/
@ziadoz
ziadoz / download-unicode-db.php
Created September 20, 2025 15:48
Download Unicode Database
<?php
// Download Unicode database CSV:
$ch = curl_init();
curl_setopt_array($ch, $options = [
CURLOPT_URL => 'https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_FAILONERROR => true,