Skip to content

Instantly share code, notes, and snippets.

View mrl22's full-sized avatar
πŸ’­
Always coding

Richard Leishman mrl22

πŸ’­
Always coding
View GitHub Profile
@mrl22
mrl22 / DbExportCommand.php
Created February 5, 2026 17:35
php artisan db:export - Very similar function to wp-cli db:export but for Laravel - Support MySQL and SQLite
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class DbExportCommand extends Command
{
/**
* The name and signature of the console command.
@mrl22
mrl22 / tailwindsize.html
Created January 29, 2026 17:27
Tailwindcss - Display what size you are in
<div class="fixed bottom-0 left-0 z-9999 p-2 text-xs font-mono bg-black text-white">
<div class="block sm:hidden">BASE</div>
<div class="hidden sm:block md:hidden">SM</div>
<div class="hidden md:block lg:hidden">MD</div>
<div class="hidden lg:block xl:hidden">LG</div>
<div class="hidden xl:block 2xl:hidden">XL</div>
<div class="hidden 2xl:block">2XL</div>
</div>
@mrl22
mrl22 / wireguard.sh
Created January 27, 2026 15:11
Start a wg-easy docker server
mkdir -p /root/docker/wireguard
docker run -d \
--name=wg-easy \
-e WG_HOST=<public_ip> \
-e PASSWORD=<password> \
-v /root/docker/wireguard:/etc/wireguard \
-p 51820:51820/udp \
-p 51821:51821/tcp \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
@mrl22
mrl22 / README.md
Created January 13, 2026 16:34
s5cmd sync script for very large buckets with little to no ram

Low-Memory S3 Backup Script

Why I wrote this

I needed to back up a large S3-compatible bucket on a small VPS without running out of memory.

While tools like s5cmd sync work very well in many cases, they can struggle with extremely large buckets when memory is limited. I wanted something that:

  • stays within a predictable memory limit
  • makes its decisions on disk rather than in RAM
  • can be inspected and resumed at any stage
@mrl22
mrl22 / sshh.sh
Created December 10, 2025 11:34
RoyalTSX SSH Wrapper for Mac Terminal - PasswordAuthentication only.
#!/usr/bin/env bash
# sshh - Royal TSX launcher wrapper
set -euo pipefail
port=""
target=""
# Parse args
while [ "$#" -gt 0 ]; do
@mrl22
mrl22 / README.md
Created December 16, 2024 10:18
Laravel 9+ Rollback previous up() migration

How to rollback to previous created migrations. This works on Laravel 8.37 and above, since anonymous migration classes were introduced.

@mrl22
mrl22 / deploy.sh
Created November 15, 2024 17:43
Deploy script for custom php application
#!/usr/bin/bash
BASE_DIR="/home/user/sites/site.com"
GIT_SSH=""
BRANCH="master"
SHARED=("failed" "temp" "uploads" "working") # root directories that will be moved into shared storage and symlinked on each deploy
# Dont forget to setup your SSH key in Github
##############################
@mrl22
mrl22 / script.sh
Created November 3, 2024 16:31
Multithreaded recursive upload to dropbox using dbxcli with resume
# Uploads everything in the current directory to Dropbox UPLOAD directory (change line 7)
# Configured for 2 threads, any more and you get api throttling errors
find . -type f -print0 | xargs -0 -n 1 -P 2 -I {} sh -c '
file="{}"
log_file="uploaded_files.log"
dropbox_path="UPLOAD${file#.}"
# Check if file is already in log
if grep -qxF "$file" "$log_file"; then
@mrl22
mrl22 / README.md
Last active June 5, 2025 16:48
Laravel Forge Zero-Downtime Deploy Script with Releases and Persistant Storage

Laravel Forge Zero-Downtime Deploy Script

Features

  • Zero Downtime - Gets everything ready, and then switches the current directory symbolic link
  • NPM Install
  • Composer Install
  • Persistant storage at /storage/
  • 5 most recent releases are stored in /releases/ for quick rollback
@mrl22
mrl22 / updatephp.sh
Last active July 23, 2024 12:38
Forge Recipe: Update PHP-FPM Settings - All Installed PHP Versions
#!/usr/bin/env bash
declare -A replacers
# Define the settings to be replaced or added
replacers[upload_max_filesize]=500M
replacers[post_max_size]=500M
replacers[max_input_vars]=5000
replacers[memory_limit]=512M
replacers[max_execution_time]=360