Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / unfollow.js.md
Created April 26, 2024 19:31 — forked from JamieMason/unfollow.js.md
Unfollow everyone on twitter.com

Unfollow everyone on twitter.com

  1. Go to https://twitter.com/YOUR_USER_NAME/following
  2. Open the Developer Console. (COMMAND+ALT+I on Mac)
  3. Paste this into the Developer Console and run it
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
@ziadoz
ziadoz / dom-props.html
Created April 24, 2024 18:06
DOM Properties
<div id="app"></div>
<script>
const option = document.createElement('option');
option.value = 'Foo Bar';
const datalist = document.createElement('datalist');
datalist.id = 'foo-bar';
datalist.appendChild(option);
@ziadoz
ziadoz / Handler.php
Created April 5, 2024 15:08
Laravel - Report All Exceptions
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
public function register(): void
@ziadoz
ziadoz / record-chrome.sh
Created March 28, 2024 21:47
macOS Screen Record Google Chrome
#!/usr/bin/env bash
screencapture -R$(osascript -e 'tell app "Google Chrome" to get the bounds of the front window' | tr -d '[:space:]') -C -o -x -k -v ~/Desktop/chrome.mov
@ziadoz
ziadoz / phpstorm.sh
Created March 25, 2024 17:21
PhpStorm - Compare Files
#!/usr/bin/env bash
# @see: https://www.jetbrains.com/help/phpstorm/working-with-the-ide-features-from-command-line.html
# @see: https://www.jetbrains.com/help/phpstorm/comparing-files-and-folders.html#comparing_folders
# Usage: phpstorm diff [a] [b]
# View > Compare With
open -na "PhpStorm.app" --args "$@"
@ziadoz
ziadoz / chrome-headless.sh
Created March 25, 2024 16:18
Chrome Headless - Screenshot, Snapshot and PDF
#!/usr/bin/env bash
# Slugify a string
# @see: https://duncanlock.net/blog/2021/06/15/good-simple-bash-slugify-function/
# @see: https://gist.github.com/oneohthree/f528c7ae1e701ad990e6
function slugify() {
iconv -t ascii//TRANSLIT \
| tr -d "'" \
| sed -E 's/[^a-zA-Z0-9]+/-/g' \
| sed -E 's/^-+|-+$//g' \
@ziadoz
ziadoz / min-max-array.php
Last active March 22, 2024 16:02
PHP - Find Min/Max Count in Multi-Dimensional Array
<?php
// @see: https://stackoverflow.com/questions/21861825/quick-way-to-find-the-largest-array-in-a-multidimensional-array
$array = [
['foo', 'bar'],
['foo'],
['foo', 'bar', 'baz'],
];
echo count(max($array)) . PHP_EOL;
echo count(min($array)) . PHP_EOL;
@ziadoz
ziadoz / FakesJavaScriptFetch.php
Last active March 7, 2024 11:05
Plain JS - Fake JSON Response From fetch()
<?php
namespace Tests;
use Laravel\Dusk\Browser;
trait FakesJavaScriptFetch
{
// Usage: $browser->script($this->fakeFetchResponse(['foo' => 'bar']));
public function fakeFetchResponse(array $data): string
{
@ziadoz
ziadoz / example.php
Last active February 23, 2024 13:26
Hypothetical PHP Getter/Setter Attribute Syntax
<?php
class Example
{
// By default the attribute binds a getter to `getName()`and setter to `setName()`.
#[Accessor]
protected string $name;
// Custom getter and setter method names can be passed.
#[Accessor(getter: 'customGetter, setter: 'customSetter')]
protected string $name;
@ziadoz
ziadoz / PreventMaxInputVarTruncation.php
Created February 2, 2024 15:17
Laravel 10.x - max_input_var INI Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
class PreventMaxInputVarTruncation