Skip to content

Instantly share code, notes, and snippets.

View geraldurbas's full-sized avatar

Gerald Urbas geraldurbas

View GitHub Profile
@geraldurbas
geraldurbas / psql-with-gzip-cheatsheet.sh
Created December 16, 2024 12:06 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
@geraldurbas
geraldurbas / gist:0af131713416e40cdfa3bc363c63a344
Created November 8, 2024 22:26
SQL: replace Lightspeed Webshop URLs in WooCommerce Exported Products
SELECT post_content,
REGEXP_REPLACE(post_content, 'https://static\\.webshopapp\\.com/shops/1234/files/[0-9]+/', 'https://new-url.com/fixed/path/')
FROM `db606006_1`.`eucph_posts`
WHERE
post_content REGEXP 'https://static\\.webshopapp\\.com/shops/1234/[^\"\\s]*';
EXPLAIN UPDATE eucph_posts
SET post_content = REGEXP_REPLACE(post_content, 'https://static\\.webshopapp\\.com/shops/1234/files/[0-9]+/', 'https://rechtwp.de/wp-content/uploads/2024/11/')
@geraldurbas
geraldurbas / gist:fe7702527be806e7da67be0d725b5341
Last active October 25, 2024 13:36
Fast PDF Conversion on Windows with Libreoffice
"C:\Program Files\LibreOffice\program\soffice.exe" --headless --convert-to pdf *.ods
@geraldurbas
geraldurbas / zfs_cleanup.sh
Last active October 15, 2024 22:40 — forked from jstutters/zfs_cleanup.sh
Find and delete multiple ZFS snapshots
zfs list -t snapshot -H -o name | grep "201509[0-9].*" | xargs -n1 echo
# zfs list -t snapshot -H -o name | grep "201509[0-9].*" | xargs -n1 zfs destroy
zfs list -r -t snapshot -o name BusinessData/Strato-varwww | grep "2024-07" | xargs -n1 echo
zfs list -r -t snapshot -o name BusinessData/Strato-varwww | grep "2024-07" | xargs -n1 zfs destroy
from datetime import datetime, timedelta
import calendar
# Start- und Enddatum festlegen
start_datum = datetime(2019, 12, 1) # 1. Januar 2023
end_datum = datetime(2024, 12, 1) # 1. Juli 2024
# Basis-URL festlegen
base_url = '<a href="https://irgendwo.com/admin/index.php/sell/orders/?order%5Bfilters%5D%5Bdate_add%5D%5Bfrom%5D={start_datum}&order%5Bfilters%5D%5Bdate_add%5D%5Bto%5D={end_datum}">{start_datum} - {end_datum}</a><br />'
@geraldurbas
geraldurbas / gist:a6b860bd9292219c826edfcd60b079fa
Created July 26, 2024 08:45
ZFS Reclaim space used by too many or often changed snapshots
zfs list -t snapshot -o name -S creation Pool/FSName | tail -n +16 | xargs -n 1 zfs destroy -vr
via
https://serverfault.com/questions/340837/how-to-delete-all-but-last-n-zfs-snapshots
@geraldurbas
geraldurbas / gist:6847fd064106f4e425290b15c2e1488c
Last active July 5, 2024 09:44
Open SSH Update für Ubuntu 18
sudo apt update
sudo apt install build-essential zlib1g-dev libssl-dev
sudo mkdir /var/lib/sshd
sudo chmod -R 700 /var/lib/sshd/
sudo chown -R root:sys /var/lib/sshd/
wget -c https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.7p1.tar.gz
tar -xzf openssh-9.7p1.tar.gz
cd openssh-9.7p1/
sudo apt install libpam0g-dev libselinux1-dev libkrb5-dev
./configure --with-kerberos5 --with-md5-passwords --with-pam --with-selinux --with-privsep-path=/var/lib/sshd/ --sysconfdir=/etc/ssh
@geraldurbas
geraldurbas / HowtoDeleteZnuny-OTRSTickets.md
Created January 29, 2024 12:31
Znuny / OTRS - Aproach to delete Tickets and Attachments reported from malware Scanners.

Delete Znuny Tickets and Attachments in Filesystem

Nice commands to know:

su -c "/opt/otrs/bin/otrs.Console.pl" -s /bin/bash otrs = show all options su -c "/opt/otrs/bin/otrs.Console.pl Maint::Ticket::Dump #Ticket_id " -s /bin/bash otrs = Show ticket

su -c "/opt/otrs/bin/otrs.Console.pl Maint::Ticket::Delete --ticket-id #Ticket_id " -s /bin/bash www-data