Skip to content

Instantly share code, notes, and snippets.

View williamdes's full-sized avatar
🚀
Catching up on GitHub notifications

William Desportes williamdes

🚀
Catching up on GitHub notifications
View GitHub Profile
@martin-rueegg
martin-rueegg / mysql_filter_tables.sh
Last active March 9, 2025 03:51
Remove tables from MySQL/MariaDB SQL dump
#!/bin/env bash
#
# Filter the given tables out of a MySQL/MariaDB dump file.
#
#
# The MIT License (MIT)
#
# Copyright © 2023 metaworx resonare rüegg, Martin Rüegg, Switzerland. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
@ivanlonel
ivanlonel / geohash12_int8.sql
Last active April 23, 2026 20:32
Converts geohash between text and integer formats in Postgres
-- Converts geohash (up to 12 characters) between text and bigint formats in Postgres
-- https://dbfiddle.uk/UzF6gQzu
-- The geohash length is stored in the 4 least significant bits,
-- so that the relative order of the resulting int8 is the same
-- as that of the the original text string:
-- gzzzzzzzzzzz < h < h0 < h00 < h01 < h1
-- -4 < 1 < 2 < 3 < 562949953421315 < 18014398509481986
@n3rdopolis
n3rdopolis / kerneltester.sh
Created April 29, 2023 01:42
Build a Linux kernel with a initrd, to test it and its modules in QEMU with a test script
#! /bin/bash
mkdir -p /var/cache/kerneltest
#Make a file system image for the VM, and mount it.
if [[ -e /var/cache/kerneltest/fs.img ]]
then
rm /var/cache/kerneltest/fs.img
fi
truncate -s 2G /var/cache/kerneltest/fs.img
mkfs.ext4 /var/cache/kerneltest/fs.img
@TheSkallywag
TheSkallywag / stretchoid-ips-to-block.txt
Created December 19, 2022 22:16
stretchoid.com IPs as of Dec 19, 2022
I used this handy one-liner to search ip ranges while looking up its PTR record.
The PTR record will have the string "stretchoid". This process took about an hour.
for N in {128..255}; do echo "Testing 192.241.$N.0 - 192.241.$N.255" >> stretchoid_ips.txt; for L in {0..255}; do host -t PTR "192.241.$N.$L" | grep -qF 'stretchoid.com.' && echo "192.241.$N.$L `host -t PTR \"192.241.$N.$L\"`" >> stretchoid_ips.txt; done; done
Credit goes to sissy for the idea:
https://forum.netgate.com/topic/169024/stretchoid-com-ip-list-for-use-in-blocking-their-port-scans?_=1671484145965&lang=en-US
I then opened up the text file in notepad++ and did a regular expressions Search/Replace (CTRL+H)
def pma_import_resubmit(br, sqlfile, target_dbname):
""" To be used in phpmyadmin dump.sql file imports using python-mechanize
as described in <https://github.com/phpmyadmin/phpmyadmin/issues/17423#issuecomment-1268271930>
Only call this function when you have already found a 'timeout_passed=' string in browser response
(so you are sure the page contains a resubmit link)
"""
# https://stackoverflow.com/questions/3569622/python-mechanize-following-link-by-url-and-what-is-the-nr-parameter/3569707#3569707
#link = br.find_link(url = resumeurl)
link = br.find_link(text = "resubmit the same file")
link.absolute_url = link.absolute_url.replace("&amp;","&").replace("?", "?db="+target_dbname+"&")
@siavash119
siavash119 / get_firehol.sh
Last active July 28, 2026 07:58
firehol sets to nftables
#!/bin/bash
trust="{1.1.1.1/32, 1.0.0.1/32, 8.8.8.8/32, 114.114.114.114/32, 114.114.115.115/32}"
declare -A sets
#sets["firehol2"]="https://iplists.firehol.org/files/firehol_level2.netset"
sets["blocklist_net_ua"]="https://iplists.firehol.org/files/blocklist_net_ua.ipset"
sets["firehol3"]="https://iplists.firehol.org/files/firehol_level3.netset"
table_name="sink"
@LVoogd
LVoogd / rector.php
Created June 14, 2022 09:48
Rector script to migrate annotations to attributes
<?php
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\SensiolabsSetList;
use Rector\Nette\Set\NetteSetList;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
@binki
binki / invoke-mailman.sh
Created January 6, 2022 02:24
Set mailing list moderator password mailman3
mailman -C /etc/mailman/mailman.cfg withlist -l list@example.org
@jaygooby
jaygooby / log4j-jndi.conf
Last active April 14, 2026 18:35
fail2ban filter rule for the log4j CVE-2021-44228 exploit
# log4j jndi exploit CVE-2021-44228 filter
# Save this file as /etc/fail2ban/filter.d/log4j-jndi.conf
# then copy and uncomment the [log4j-jndi] section
# to /etc/fail2ban/jail.local
#
# jay@gooby.org
# https://jay.gooby.org/2021/12/13/a-fail2ban-filter-for-the-log4j-cve-2021-44228
# https://gist.github.com/jaygooby/3502143639e09bb694e9c0f3c6203949
# Thanks to https://gist.github.com/kocour for a better regex
#

Proxmox with LVM-thin and why we should use Trim/Discard

Excerpts from the Proxmox VE Administration Guide]

LVM normally allocates blocks when you create a volume. LVM thin pools instead allocates blocks when they are written. This behaviour is called thin-provisioning, because volumes can be much larger than physically available space.

8.10.2. Trim/Discard It is good practice to run fstrim (discard) regularly on VMs and containers. This releases data blocks that the filesystem isn’t using anymore. It reduces data usage and resource load. Most modern operating systems issue such discard commands to their disks regularly. You only need to ensure that the Virtual Machines enable the disk discard option.