View random-files.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate Random Files | |
# @see: https://support.google.com/elastifile-support/answer/9899027?hl=en | |
# Usage: ./random-files.sh -d /path/to/ouput -s 10 -m 20 - l 5 | |
# Large: <2GB | |
# Medium: <200MB, <8MB each | |
# Small: <1MB | |
DEST="$PWD" | |
SMALL=0 | |
MEDIUM=0 |
View resize-llm-volume.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# @see: https://chasingcode.dev/blog/fix-vagrant-homestead-cant-create-database/ | |
# @see: https://github.com/laravel/homestead/issues/1189#issuecomment-787935903 | |
# @see: https://laracasts.com/discuss/channels/guides/a-guide-to-extending-homestead-storage-capacity | |
# @see: https://www.thegeekdiary.com/how-to-enable-thin-lvm-automatic-extension/ | |
# @see: https://laracasts.com/discuss/channels/guides/a-guide-to-extending-homestead-storage-capacity | |
# @see: https://askubuntu.com/questions/433705/dev-mapper-ubuntu-vg-root-is-full | |
# Default LVM volume size is 64GB, this will add 50% of the available disk space (512GB) to it, making it 256GB: |
View extract-vmdk.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Unzip Vagrant .box file: | |
tar -xf <box> -C <destination> | |
# Install 7 Zip: | |
brew install p7zip | |
# Extract VMDK: | |
7z x -y -o<destination> <vmdk> |
View php80_attributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
View php8.0-install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
View homestead.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View example.com.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTTP to HTTPS | |
server { | |
listen 80; | |
listen [::]:80 ipv6only=on; | |
server_name example.com; | |
return 301 https://example.com$request_uri; | |
} |
View Caddyfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example.com { | |
root * /var/www/vhosts/example.com/public | |
php_fastcgi unix//var/run/php/php7.4-fpm.sock | |
file_server | |
encode zstd gzip | |
} |
View mysql_install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)" |
View closure_mock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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') |