Skip to content

Instantly share code, notes, and snippets.

View gsdefender's full-sized avatar
💭
I may be slow to respond.

Emanuele Cipolla gsdefender

💭
I may be slow to respond.
View GitHub Profile
//WooCommerce Email Customizations
add_filter( 'woocommerce_email_recipient_customer_note', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_completed_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_invoice', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
add_filter( 'woocommerce_email_recipient_customer_processing_order', array( $this, 'fka_parent_email_recipient_filter_function' ), 10, 2);
/**
* $recipient could be comma separated to send to additional people
* EX. $recipient .= ', $additonal_recipient';
*/
@gsdefender
gsdefender / better-rc-local.service
Created February 10, 2021 00:11
rc.local for systemd-based distro
# Put this file in /etc/systemd/system
[Unit]
Description=A better rc.local-service
[Service]
Type=idle
ExecStart=/etc/rc.local.better
[Install]
WantedBy=network.target
@gsdefender
gsdefender / kodi.service
Created February 10, 2021 00:13
Kodi systemd service
[Unit]
Description = Kodi Media Center
# if you don't need the MySQL DB backend, this should be sufficient
After = systemd-user-sessions.service network.target sound.target
# if you need the MySQL DB backend, use this block instead of the previous
# After = systemd-user-sessions.service network.target sound.target mysql.service
# Wants = mysql.service
@gsdefender
gsdefender / unbound-adhosts.sh
Created February 15, 2021 00:39
Unbound 8 blocked hosts downloader
#!/bin/ksh
#
# Using blacklist from pi-hole project https://github.com/pi-hole/
# to enable AD blocking in unbound(8)
#
# src: https://www.tumfatig.net/20190405/blocking-ads-using-unbound8-on-openbsd/
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
# Available blocklists - comment line to disable blocklist
_disconad="https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt"
@gsdefender
gsdefender / get-latest-moodle.sh
Last active April 23, 2023 14:22
Download and install latest Moodle
#!/bin/bash
# replace with latest moodle directory and filename from moodle.org
DIRECTORY="stable401"
FILENAME="moodle-4.1.1.tgz"
URL="https://download.moodle.org/download.php/direct/$DIRECTORY/$FILENAME"
pushd
rm -f moodle-latest.tgz
wget "$URL" -O moodle-latest.tgz
@gsdefender
gsdefender / restore-proxmox-vm.sh
Last active July 6, 2023 20:00
Restore Proxmox VM backup to another server
#!/bin/bash
# usage: ./restore-proxmox-vm backup.zst local:111 newlocal
tempdir=$(mktemp -d -u) # do not create directory or vma extract will fail
if [ -f "$1" ]; then zstd -d "$1"; fi
vma extract "$(basename $1 .zst)" "$tempdir"
vmid=$(($(ls -1 /etc/pve/qemu-server/*.conf | tr '\n' '\0' | xargs -0 -n 1 basename | sed -e 's:\.conf::g' | sort -n | tail -1)+1))
mv "$tempdir/qemu-server.conf" /etc/pve/qemu-server/$vmid.conf
newdisk="$3:$vmid"
sed -i -e "s:$2:$newdisk:g" /etc/pve/qemu-server/$vmid.conf
mkdir -p "$3/images/$vmid"