Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / php80_attributes.php
Last active Dec 4, 2020
Using PHP 8.0 Attributes/Annotations To Decorate Functions
View php80_attributes.php
<?php
// Attributes (AKA Annotations).
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_FUNCTION)]
class CharDecoratorAttribute
{
public function __construct(protected string $char) // Constructor Property Promotion
{
}
public function decorate(Closure $fn): Closure
@ziadoz
ziadoz / php8.0-install.sh
Last active Dec 4, 2020
Quick PHP 8.0 Install - Ubuntu 18.04
View php8.0-install.sh
#!/usr/bin/env bash
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y \
php8.0 php8.0-bcmath php8.0-bz2 php8.0-cgi php8.0-cli php8.0-common php8.0-curl php8.0-dba php8.0-dev \
php8.0-enchant php8.0-fpm php8.0-gd php8.0-gmp php8.0-imap php8.0-interbase php8.0-intl php8.0-ldap \
php8.0-mbstring php8.0-mysql php8.0-odbc php8.0-opcache php8.0-pgsql php8.0-phpdbg php8.0-pspell php8.0-readline \
php8.0-snmp php8.0-soap php8.0-sqlite3 php8.0-sybase php8.0-tidy php8.0-xml php8.0-xsl php8.0-zip
@ziadoz
ziadoz / homestead.sh
Last active Oct 14, 2020
Add and Remove Laravel Homestead Root CA to and from the macOS Keychain
View homestead.sh
sudo security delete-certificate -c "Homestead homestead Root CA" /Library/Keychains/System.keychain 2> /dev/null
sudo security add-trusted-cert -d -r trustRoot -p ssl -k /Library/Keychains/System.keychain ~/Projects/homestead/ca.homestead.homestead.crt 2> /dev/null
function homestead() {
( cd ~/Projects/homestead && vagrant $* )
if [[ "$1" == "destroy" ]]; then
sudo security delete-certificate -c "Homestead homestead Root CA" /Library/Keychains/System.keychain 2> /dev/null
fi
@ziadoz
ziadoz / example.com.conf
Last active Jul 5, 2020
PHP/Laravel Nginx HTTP2/SSL Configuration
View example.com.conf
# HTTP to HTTPS
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name example.com;
return 301 https://example.com$request_uri;
}
@ziadoz
ziadoz / Caddyfile
Created Jul 5, 2020
Laravel Caddy v2 Caddyfile
View Caddyfile
example.com {
root * /var/www/vhosts/example.com/public
php_fastcgi unix//var/run/php/php7.4-fpm.sock
file_server
encode zstd gzip
}
@ziadoz
ziadoz / mysql_install.sh
Created Jun 8, 2020
MySQL 8 Installation - Ubuntu 18.04 / 20.04 LTS
View mysql_install.sh
#!/usr/bin/env bash
password="root"
echo PURGE | sudo debconf-communicate mysql-community-server
sudo apt purge mysql-client mysql-server
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $password"
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $password"
sudo debconf-set-selections <<< "mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)"
@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