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 / 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
@mrl22
mrl22 / main.go
Last active July 21, 2024 21:54
Connect to Laravel Reverb from Golang for two-way communication
package main
import (
"encoding/json"
"github.com/gorilla/websocket"
"log"
"net/url"
"os"
"os/signal"
"syscall"
@mrl22
mrl22 / searchNumber.sql
Created July 2, 2024 14:05
3CX CRM MySQL Query for WHMCS Contacts
select id as contactid, firstname, lastname, email, phonenumber as phonebusiness from tblcontacts where CONCAT('44',TRIM(LEADING '0' FROM TRIM(LEADING '+44.' FROM REPLACE(phonenumber, ' ', '')))) = '@Number';
@mrl22
mrl22 / README.md
Last active September 17, 2025 10:35
PHP 8.3 Support for Apache and NGINX (OpenResty) on Moss.sh

NO LONGER WORKS DUE TO PHP 8.3 BEING REMOVED FROM PPA:ONDREJ/PHP

Do not copy and paste this code, it requires changes

Other PHP versions available here: https://gist.github.com/search?q=user%3Amrl22+moss

As of writing this, Moss.sh STILL does not support anything above PHP 7.4 via the control panel even though Ubuntu does.

Set up your website using Moss.sh and select Apache with PHP 7.4.