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 / 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 May 22, 2024 17:56
PHP 8.3 Support for Apache and NGINX (OpenResty) on Moss.sh

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.

Once complete, we need to install PHP 8.3 with all the packages moss installs for 7.4.

@mrl22
mrl22 / battery.sh
Created February 2, 2024 20:50
APCUPSD / APCACCCESS - Get power consumption in Watts.
#!/usr/bin/sh
APC=$(apcaccess status)
NOMPOWER=$(echo "$APC"|grep NOMPOWER|cut -d' ' -f3)
LOADPCT=$(echo "$APC"|grep LOADPCT|cut -d' ' -f4)
WATTS=$(echo "$NOMPOWER / $LOADPCT"|bc)
echo "$WATTS Watts"
@mrl22
mrl22 / SimpleCacheBridge.php
Last active February 25, 2024 14:48
Psr\SimpleCache\CacheInterface implementation for Laravel - Tested on Laravel 10 with PHP 8.2
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2017/8/14
* Time: 15:44
*
* Updated by Richard Leishman to support PHP 8.2
*/
@mrl22
mrl22 / DialogUserDelete.php
Created January 12, 2024 17:21
Delete User Modal
<?php
namespace App\Http\Livewire\Modals;
use App\Http\Controllers\UserController;
use App\Models\User;
use App\View\Components\Modal;
use Livewire\Component;
class DialogUserDelete extends Component
@mrl22
mrl22 / nginx.conf
Created December 25, 2023 14:05
Nginx Proxy, Hide the real server
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name myrealdomain.com;
ssl_certificate_by_lua_block {
auto_ssl:ssl_certificate()
}
ssl_certificate /etc/ssl/resty-auto-ssl-fallback.crt;
ssl_certificate_key /etc/ssl/resty-auto-ssl-fallback.key;
@mrl22
mrl22 / README.md
Created November 28, 2023 11:26
QNAP HBS Hybrid Backup Sync missing 'home' 'homes' directory on remote rsync server.

QNAP HBS Hybrid Backup Sync missing 'home' 'homes' directory on remote rsync server.

If you are reading this, you have probably ran into the same issue that I have that when using QNAP HBS and you browse the remote backup server, the home or /home.

Through the research I have done, unfortunately, there is no quick fix for this.

It seems that QNAP have a rule across the board that all root folders containing the word home are hidden from view. This is quite a big issue when it comes to backing up to remote rsync servers over SSH as Linux users are typically stored in the /home

@mrl22
mrl22 / imapsync.md
Created November 9, 2023 14:34 — forked from nosmall/imapsync.md
Imapsync on Ubuntu 20.04 (lazy guide)

Imapsync on Ubuntu 20.04 (lazy guide)

sudo apt install -y libauthen-ntlm-perl libclass-load-perl libcrypt-ssleay-perl libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl libencode-imaputf7-perl libfile-copy-recursive-perl libfile-tail-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libmail-imapclient-perl libmodule-scandeps-perl libnet-dbus-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libregexp-common-perl libsys-meminfo-perl libterm-readkey-perl libtest-fatal-perl libtest-mock-guard-perl libtest-mockobject-perl libtest-pod-perl libtest-requires-perl libtest-simple-perl libunicode-string-perl liburi-perl libtest-nowarnings-perl libtest-deep-perl libtest-warn-perl make cpanminus && \
cd ~/ && \
git clone https://github.com/imapsync/imapsync.git && \
cd ~/imapsync/ && \
sudo ln -s ~/imapsync/imapsync /usr/bin/imapsync && \
imapsync --testslive