Skip to content

Instantly share code, notes, and snippets.

Jamie York ziadoz

Block or report user

Report or block ziadoz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ziadoz
ziadoz / closure_mock.php
Created May 22, 2020
PHPUnit Mocking Closures
View closure_mock.php
<?php
// Closure can't be mocked because it's a final class.
// Mock another class instead and add __invoke to it.
$mockClosure = $this->getMockBuilder(\stdClass::class)
->addMethods(['__invoke'])
->getMock();
$mockClosure->expects($this->exactly(1))
->method('__invoke')
@ziadoz
ziadoz / VBoxHardening.log
Created May 18, 2020
WSL Vagrant Issues
View VBoxHardening.log
3f80.3c98: Log file opened: 6.1.8r137981 g_hStartupLog=0000000000000088 g_uNtVerCombined=0xa047bb00
3f80.3c98: \SystemRoot\System32\ntdll.dll:
3f80.3c98: CreationTime: 2020-05-12T19:15:35.370039500Z
3f80.3c98: LastWriteTime: 2020-05-12T19:15:35.406940600Z
3f80.3c98: ChangeTime: 2020-05-12T20:48:51.077790500Z
3f80.3c98: FileAttributes: 0x20
3f80.3c98: Size: 0x1e8460
3f80.3c98: NT Headers: 0xd8
3f80.3c98: Timestamp: 0xb29ecf52
3f80.3c98: Machine: 0x8664 - amd64
@ziadoz
ziadoz / icloud_tabs_to_csv.sh
Last active May 26, 2020
Export iCloud Tabs/URLs to CSV
View icloud_tabs_to_csv.sh
#!/usr/bin/env bash
alias icloud_tabs='sqlite3 -header -csv ~/Library/Safari/CloudTabs.db "select ctd.device_name, ct.title, ct.url from cloud_tabs as ct inner join cloud_tab_devices as ctd on ctd.device_uuid = ct.device_uuid order by device_name asc, position asc"'
# Output to CSV file:
icloud_tabs > icloud_tabs.csv
# Unique CSV:
sort -u icloud_tabs.csv -o icloud_tabs_unique.csv
# Merge CSVs:
@ziadoz
ziadoz / ut3_bonus_packs.txt
Last active Apr 7, 2020
Unreal Tournament 3 - Community Bonus Pack (CBP) 1 - 5 Downloads
View ut3_bonus_packs.txt
Community Bonus Pack
--------------------
Homepage Download Links: https://web.archive.org/web/20150707182232/http://cbp.beyondunreal.com/download
CBP 1 - 4 Installer, Zip, PS3 : http://www.mapraider.com/profiles/CommunityBonusPack/maps
CBP 1 Installer, Zip, PS3: http://www.mapraider.com/maps/unreal-tournament-3/capture-the-flag/4322/Community-Bonus-Pack-3-Volume-1
CBP 1 Installer: http://www.fileplanet.com/188272/180000/fileinfo/Unreal-Tournament-3---Community-Bonus-Pack-3:-Volume-1
CBP 2 Installer, Zip, PS3: http://www.mapraider.com/maps/unreal-tournament-3/capture-the-flag/4343/Community-Bonus-Pack-3-Volume-2
@ziadoz
ziadoz / pdf-img.sh
Created Mar 11, 2020
Extract Images From PDF / Build PDF From Images / Remove PDF White Margins (Ubuntu)
View pdf-img.sh
#!/usr/bin/env bash
# Extract images from a PDF: https://askubuntu.com/questions/117143/command-line-tool-to-bulk-extract-images-from-a-pdf
sudo apt-get install poppler-utils
pdfimages -all input.pdf images/image
# Build PDF from images: https://stackoverflow.com/questions/8955425/how-can-i-convert-a-series-of-images-to-a-pdf-from-the-command-line-on-linux
sudo apt install img2pdf
img2pdf --output d.pdf images/image*.jpg
@ziadoz
ziadoz / extract-favicon-images.php
Created Mar 4, 2020
Extract PNG Images From Favicon ICO Images in PHP Using ImageMagick
View extract-favicon-images.php
<?php
// Extract favicon images from file path.
$faviconFile = __DIR__ . '/bbc.ico'
file_put_contents($faviconFile, file_get_contents('https://www.bbc.co.uk/favicon.ico'));
$imagick = new Imagick();
$imagick->readImage($faviconFile);
$imagick->writeImages(__DIR__ . '/bbc-extracted.png', false);
// Extract favicon images from string.
@ziadoz
ziadoz / Kernel.php
Last active Mar 3, 2020
Register Doctrine Mongo ODM Symfony Commands with Laravel (v6.0) Artisan
View Kernel.php
<?php
// app/Console/Kernel.php
namespace App\Console;
use Doctrine\ODM\MongoDB\Tools\Console\Command\ClearCache\MetadataCommand;
use Doctrine\ODM\MongoDB\Tools\Console\Command\{GenerateHydratorsCommand, GeneratePersistentCollectionsCommand, GenerateProxiesCommand, QueryCommand};
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\{CreateCommand, DropCommand, ShardCommand, UpdateCommand, ValidateCommand};
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ziadoz
ziadoz / artisan_db_open.php
Created Feb 4, 2020 — forked from calebporzio/artisan_db_open.php
An artisan command for opening the project's database in TablePlus
View artisan_db_open.php
<?php
Artisan::command('db:open {connection?}', function ($connection = null) {
if (! file_exists('/Applications/TablePlus.app')) {
$this->warn('This command uses TablePlus, are you sure it\'s installed?');
$this->line("Install here: https://tableplus.com/\n");
}
$driver = $connection ?: config('database.default');
$host = config("database.connections.{$driver}.host");
@ziadoz
ziadoz / composer-install.sh
Created Feb 4, 2020
Install Composer Locally Using Bash
View composer-install.sh
#!/bin/bash
mkdir -p ~/.bin
curl -sS https://getcomposer.org/installer | php -- --install-dir=~/.bin --filename=composer
@ziadoz
ziadoz / composer-latest.sh
Last active Feb 4, 2020
Check running Composer version is latest using Bash
View composer-latest.sh
#!/bin/bash
# Sometimes it's useful to know if Composer actually needs updating or if it was updated, for example for CI builds.
# 1) Check if you're running the latest version of Composer.
# - https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
# - https://superuser.com/questions/363865/how-to-extract-a-version-number-using-sed
LATEST_COMPOSER_VERSION="$(curl --silent "https://api.github.com/repos/composer/composer/tags" | jq -r '.[0].name')"
CURRENT_COMPOSER_VERSION="$(composer --version | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')"
if [ $LATEST_COMPOSER_VERSION != $CURRENT_COMPOSER_VERSION ]; then
You can’t perform that action at this time.