Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / readme.txt
Created August 27, 2023 12:58
Call Of Duty - Broken Communication Opt Out Form
Visit communication opt Out website: https://profile.callofduty.com/cod/optOut
Check all unsubcribe checkboxes and click "Submit" button.
A 500 error appears in the JavaScript console to the URL: https://profile.callofduty.com/cod/updatePreferences
Error:
{"requestURL":"http://profile.callofduty.com/cod/updatePreferences","errorMessage":"org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [{\"error\": {\"name\": \"Error:ClientError:InvalidRequest:QueryStringInvalid\", \"msg\": \"Request parameters validation failed, see context for more details.\", \"context\": [{\"name\": \"Error:ClientError:InvalidRequest:ParameterInvalid\", \"msg\": \"Either the 'emails', 'phones', 'unoIDs', 'userNames', 'firstNames', 'lastNames' or 'fullNames' parameter must be provided\", \"code\": 212000}], \"code\": 211000}}]","exceptionClass":"UnoRuntimeException","stackTrace":"com.activision.webapps.sso.services.uno.UnoRuntimeException: org.springframework.web.client.HttpClientErrorException$BadRe
@ziadoz
ziadoz / menu-icons.txt
Created July 25, 2023 15:53
Menu Icons
Hamburger Menu (☰)
Meatball Menu (⋯)
@ziadoz
ziadoz / readme.txt
Last active July 25, 2023 15:54
Register UT99 UMod Extension
Replace path to UT99 with your install path, then run the .reg file.
https://steamcommunity.com/sharedfiles/filedetails/?id=272924930
https://ut99.org/viewtopic.php?t=6020
@ziadoz
ziadoz / raw_sql.php
Last active September 21, 2023 09:41
Laravel - QueryExecuted To Raw SQL
<?php
// Before Laravel 10.15.0
function prepareQuery(QueryExecuted $query): string
{
return count($query->bindings) > 0
? vsprintf(str_replace(['%', '?'], ['%%', '%s'], $query->sql), array_map(fn ($value) => (is_numeric($value) ? $value : "'" . $value . "'"), $query->bindings))
: $query->sql;
}
prepareQuery($query);
@ziadoz
ziadoz / MyCommand.php
Created July 5, 2023 13:58
Laravel - Keep Database Connection Alive in Artisan Commands
<?php
namespace App\Console\Commands;
class MyCommand extends Command
{
protected $signature = 'app:my-command';
public function handle(): int
{
@ziadoz
ziadoz / enum-next-prev.php
Last active July 3, 2023 15:01
PHP Enum Next/Previous Case
<?php
enum Foo: string
{
case A = 'A';
case B = 'B';
case C = 'C';
public function next(): self
{
@ziadoz
ziadoz / regexp-primes.php
Last active June 21, 2023 10:28
PHP - Regular Expression Prime Numbers
<?php
// @see: https://www.noulakaz.net/2007/03/18/a-regular-expression-to-check-for-prime-numbers/
// @see: https://web.archive.org/web/20220522073029/http://montreal.pm.org/tech/neil_kandalgaonkar.shtml#this_vs_mine
// @see: https://web.archive.org/web/20220513113609/http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/
// @see: https://web.archive.org/web/20080111215127/http://www.mit.edu:8008/bloom-picayune.mit.edu/perl/10138
// @see: https://news.ycombinator.com/item?id=36413260
function regexp_prime(int $num): bool
{
return preg_match('/^1?$|^(11+?)\1+$/x', str_repeat('1', $num), $matches) !== 1;
@ziadoz
ziadoz / sort-assoc.php
Created June 6, 2023 12:09
PHP Sort Associative Array
<?php
final class SortAssoc
{
public function __construct(private readonly array $array, private readonly array $columns = [])
{
}
public function __invoke(): array
{
$array = $this->array;
@ziadoz
ziadoz / 15mins.sql
Last active May 22, 2023 14:58
MySQL Select 15 Minute Time Series
with recursive 15min_windows as (
select
curdate() + interval 8 hour as start,
curdate() + interval 8 hour + interval 15 minute as end
union
select
end,
end + interval 15 minute
from 15min_windows
where end < curdate() + interval 16 hour
@ziadoz
ziadoz / test.sh
Created March 22, 2023 13:52
Laravel - Install Composer dependencies via Docker for testsuite
# Put this inside /bin/test.sh to install Laravel's dependencies before running testsuite in Docker.
docker run \
-it \
--rm \
-w /data \
-v ${PWD}:/data:delegated \
--entrypoint /bin/sh \
registry.gitlab.com/grahamcampbell/php:8.1-base -c 'curl -o /tmp/composer-setup.php https://getcomposer.org/installer && php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && composer install'