Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / docker-compose.yml
Created March 21, 2023 23:23
Miniflux Docker Compose
version: '3.4'
services:
miniflux:
image: miniflux/miniflux:latest
ports:
- "80:8080"
depends_on:
- db
environment:
- DATABASE_URL=postgres://miniflux:secret@db/miniflux?sslmode=disable
@ziadoz
ziadoz / FooTest.php
Last active August 4, 2023 10:41
PHPUnit 10 - Replacement for deprecated withConsecutive() method
<?php
// @see: https://github.com/sebastianbergmann/phpunit/issues/4026
// Use `$this->with(...$this->consecutiveParams($args1, $args2))` instead of `$this->withConsecutive($args1, $args2)`.
use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
{
use ConsecutiveParams;
@ziadoz
ziadoz / Dockerfile
Created January 10, 2023 14:33
Tideways PHP Extension on ARM64 Alpine Linux
FROM php:8.1-fpm-alpine
ARG TIDEWAYS_EXTENSION_VERSION=5.5.12
ARG TIDEWAYS_PHP_VERSION=8.0
ARG TIDEWAYS_PHP_EXTVER=20200930
RUN wget "https://tideways.s3-eu-west-1.amazonaws.com/extension/${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}/tideways.so && \
rm -rf tideways-php-${TIDEWAYS_EXTENSION_VERSION}-alpine-arm64.tar.gz ./build
@ziadoz
ziadoz / AppServiceProvider.php
Created December 20, 2022 11:27
Replace Laravel Artisan Command Output With Custom Implementation
<?php
namespace App\Providers;
use App\YourCustomOutputStyle;
use Illuminate\Console\OutputStyle;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@ziadoz
ziadoz / refresh_tab.js
Last active December 8, 2022 22:24
Refresh Browser Tab At Specific Time
// Resources
// @see: https://www.technipages.com/how-to-auto-refresh-chrome-tabs-without-an-extension
// @see: https://stackoverflow.com/questions/1217929/how-to-automatically-reload-a-web-page-at-a-certain-time
// 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
ziadoz / mysql8_indexed_json_arrays.sql
Created December 8, 2022 14:34
MySQL 8 - Search Indexed JSON Arrays
-- DB Fiddle: https://www.db-fiddle.com/f/3TSbU9ZnpSMkCRgnWYeBep/1
-- 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
ziadoz / s3-presigned-upload-sse.php
Last active November 24, 2022 14:11
AWS S3 Presigned Upload URL with SSE
<?php
// The X-Amz-Server-Side-Encryption header must be set in formInputs and options, with the correct case.
new PostObjectV4(
$client,
$bucket,
[
'key' => $key,
'acl' => 'private',
'X-Amz-Server-Side-Encryption' => 'AES256',
],
@ziadoz
ziadoz / awesome-bot.sh
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 igor.io,symfony,toranproxy.com,vagrantup.com,3v4l.org,voicesoftheelephpant.com,drupal.org,oreilly.com README.md
@ziadoz
ziadoz / LaravelToSlimController.php
Created October 27, 2022 10:33
Convert Laravel 9 HTTP Requests to Slim 4
<?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
ziadoz / ExampleTest.php
Last active October 18, 2022 16:14
Refresh Database Using Specific Database Connection In Laravel Tests
<?php
namespace Tests\Feature;
use Tests\RefreshesDatabase;
class ExampleTest
{
use RefreshesDatabase;
public string $connectionToMigrate = 'mysql-elevated';