Skip to content

Instantly share code, notes, and snippets.


Jamie York ziadoz

View GitHub Profile
ziadoz / FooTest.php
Last active March 21, 2023 17:27
PHPUnit 10 - Replacement for deprecated withConsecutive() method
View FooTest.php
// @see:
// Use `$this->with(...$this->consecutiveParams($args1, $args2))` instead of `$this->withConsecutive($args1, $args2)`.
use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
use ConsecutiveParams;
ziadoz / Dockerfile
Created January 10, 2023 14:33
Tideways PHP Extension on ARM64 Alpine Linux
View Dockerfile
FROM php:8.1-fpm-alpine
RUN wget "${TIDEWAYS_EXTENSION_VERSION}/tideways-php-${TIDEWAYS_EXTENSION_VERSION}-alpine-arm64.tar.gz" && \
tar xvzf tideways-php-${TIDEWAYS_EXTENSION_VERSION}-alpine-arm64.tar.gz && \
cp ./build/dist/tideways-php-alpine-${TIDEWAYS_PHP_VERSION}.so /usr/local/lib/php/extensions/no-debug-non-zts-${TIDEWAYS_PHP_EXTVER}/ && \
rm -rf tideways-php-${TIDEWAYS_EXTENSION_VERSION}-alpine-arm64.tar.gz ./build
ziadoz / AppServiceProvider.php
Created December 20, 2022 11:27
Replace Laravel Artisan Command Output With Custom Implementation
View AppServiceProvider.php
namespace App\Providers;
use App\YourCustomOutputStyle;
use Illuminate\Console\OutputStyle;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
ziadoz / refresh_tab.js
Last active December 8, 2022 22:24
Refresh Browser Tab At Specific Time
View refresh_tab.js
// Resources
// @see:
// @see:
// Paste this into the Web Inspector on the browser tab you want to refresh and hit Enter.
// Change this to the exact time you want to refresh the page at:
let then = new Date('2022-12-09 01:01:00');
window.setTimeout(() => window.location.reload(true), then.getTime() - new Date().getTime());
ziadoz / mysql8_indexed_json_arrays.sql
Created December 8, 2022 14:34
MySQL 8 - Search Indexed JSON Arrays
View mysql8_indexed_json_arrays.sql
-- DB Fiddle:
-- Create a customers table with an array JSON column containing their favourite numbers.
create table `customers` (
`id` bigint unsigned auto_increment,
`name` varchar(222),
`numbers` json not null,
primary key (`id`),
key `customers_numbers_index` ((cast(json_extract(`numbers`,_utf8mb4'$[*]') as unsigned array)))
) engine=InnoDB default charset=utf8mb4 collate=utf8mb4_unicode_ci;
ziadoz / s3-presigned-upload-sse.php
Last active November 24, 2022 14:11
AWS S3 Presigned Upload URL with SSE
View s3-presigned-upload-sse.php
// The X-Amz-Server-Side-Encryption header must be set in formInputs and options, with the correct case.
new PostObjectV4(
'key' => $key,
'acl' => 'private',
'X-Amz-Server-Side-Encryption' => 'AES256',
ziadoz /
Created November 19, 2022 23:49
Awesome Bot Docker Command
#!/usr/bin/env bash
docker run -ti --rm -v $PWD:/mnt dkhamsing/awesome_bot --allow-dupe --white-list,symfony,,,,,,
ziadoz / LaravelToSlimController.php
Created October 27, 2022 10:33
Convert Laravel 9 HTTP Requests to Slim 4
View LaravelToSlimController.php
use Illuminate\Foundation\Application;
use Illuminate\Http\Request as LaravelRequest;
use Illuminate\Http\Response as LaravelResponse;
use Slim\Factory\ServerRequestCreatorFactory;
use Slim\Http\Response as SlimResponse;
use Slim\Http\ServerRequest as SlimServerRequest;
class LaravelToSlimController
ziadoz / ExampleTest.php
Last active October 18, 2022 16:14
Refresh Database Using Specific Database Connection In Laravel Tests
View ExampleTest.php
namespace Tests\Feature;
use Tests\RefreshesDatabase;
class ExampleTest
use RefreshesDatabase;
public string $connectionToMigrate = 'mysql-elevated';
ziadoz / token.php
Created October 11, 2022 16:41
Generate Laravel Password Reset Token For Testing
View token.php
use Illuminate\Auth\Passwords\PasswordBroker;
$token = app()->get(PasswordBroker::class)->createToken(
User::query()->where('email', '=', '')->first()