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 / 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
@mrl22
mrl22 / ColorHelper.php
Created October 23, 2023 16:38
Laravel / PHP - Check if a hexidecimal colour is dark
<?php
namespace App\Helpers;
class ColorHelper
{
// This function tell you if a color is dark or light.
// It is useful when you want to change the text color to white or black depending on the background color.
public static function isColorDark($hexColor = '#ffffff') {
@mrl22
mrl22 / TimeHelper.php
Created October 23, 2023 16:31
Laravel / PHP / Carbon - Round time to the nearest X minutes.
<?php
namespace App\Helpers;
use Carbon\Carbon;
class TimeHelper
{
public static function round($time = null, $nearestMinutes = 15)
@mrl22
mrl22 / README.md
Last active January 31, 2024 18:43
Backup your Synology to Linux with Encryption using Hyper Backup

How to Backup Your Synology to Linux with Encryption Using Hyper Backup

This guide has been created to assist those seeking a solution for backing up their Synology NAS to an offsite Ubuntu 22.04 server. Many guides are available for achieving this without encryption, but this guide focuses on incorporating encryption for added security.

Configuring Linux

  1. Setting Up Your Ubuntu Server
    • Begin by configuring your Ubuntu server in the usual manner.
    • Ensure that SSHD is running on a port of your choice, making sure the chosen port is open in the firewall or, for enhanced security, allow access from the public IP of your Synology NAS.
  • It's recommended to disable PasswordAuthentication for improved security.
SELECT tblhosting.billingcycle, tblhosting.nextduedate, tblhosting.*
FROM tblhosting
LEFT JOIN tblinvoiceitems
ON tblinvoiceitems.`type` IN ('Hosting') AND tblhosting.id = tblinvoiceitems.relid
and (
(tblhosting.billingcycle='Monthly' AND date_add(tblinvoiceitems.duedate, INTERVAL 1 month) >= tblhosting.nextduedate)
OR (tblhosting.billingcycle='Quarterly' AND date_add(tblinvoiceitems.duedate, INTERVAL 3 month) >= tblhosting.nextduedate)
OR (tblhosting.billingcycle='Semi-Annually' AND date_add(tblinvoiceitems.duedate, INTERVAL 6 month) >= tblhosting.nextduedate)
OR (tblhosting.billingcycle='Annually' AND date_add(tblinvoiceitems.duedate, INTERVAL 12 month) >= tblhosting.nextduedate)
OR (tblhosting.billingcycle='Biennially' AND date_add(tblinvoiceitems.duedate, INTERVAL 24 month) >= tblhosting.nextduedate)