Skip to content

Instantly share code, notes, and snippets.

View ps1dr3x's full-sized avatar
👨‍💻
0x1A4

Michele Federici ps1dr3x

👨‍💻
0x1A4
View GitHub Profile
@ps1dr3x
ps1dr3x / gpg-extend-expiration.md
Created October 13, 2023 09:36
GPG extend expiration (primary key and subkeys)

List Your Keys and Subkeys

gpg --list-keys --with-subkey-fingerprint

Edit the Key (ID of the primary key, not the subkey ID)

gpg --edit-key <KEY_ID>
@ps1dr3x
ps1dr3x / gpg-backup-import.sh
Created October 13, 2023 08:41
GPG full backup and re-import
#!/bin/bash
gpg --import private-keys-backup.asc
gpg --import public-keys-backup.asc
gpg --import-ownertrust ownertrust-backup.txt
@ps1dr3x
ps1dr3x / grep-email-addresses.sh
Created March 12, 2023 13:04
Grep matching email addresses. Output sorted and without duplicates
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | sort | uniq > emails.txt
@ps1dr3x
ps1dr3x / introspection.graphql
Last active February 24, 2023 14:41
GraphQL generic introspection query
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
@ps1dr3x
ps1dr3x / debian-multirepo-stable-testing.md
Last active February 6, 2023 11:40
Debian multirepo setup (stable + individual packages from testing)

Debian multirepo setup (stable + individual packages from testing)

  • Lower Apt Pin priority of testing packages adding the following lines to /etc/apt/preferences (important: only the release name works):

    Package: *
    Pin: release n=bookworm
    Pin-Priority: 50
    
  • Add the testing repo in /etc/apt/sources.list:

@ps1dr3x
ps1dr3x / update-dynhost-ovh.sh
Last active November 16, 2022 10:11
Update DynDNS (OVH)
#!/bin/bash
# Don't forget to chmod +x update-dynhost-ovh.sh and add the cron
# */5 * * * * update-dynhost-ovh.sh
DOMAIN=""
USERNAME=""
PASSWORD=""
LOG_FILE="/var/log/update-dyndns-ovh.log"
@ps1dr3x
ps1dr3x / do-speedtest.sh
Created August 16, 2022 22:53
Speedtest using DigitalOcean's data centers
#!/bin/bash
# Speedtest using DigitalOcean's data centers
wget -O /dev/null http://speedtest-nyc1.digitalocean.com/1gb.test
# or 100mb
# wget -O /dev/null http://speedtest-nyc1.digitalocean.com/100mb.test
# Locations (1-x):
# nyc, sfo, ams, lon, fra, sgp, tor, blr
@ps1dr3x
ps1dr3x / battery-charge-threshold.service
Last active July 5, 2022 08:46
systemd service to set a charge limit for the laptop's battery (when supported)
[Unit]
Description=Set the battery charge threshold
After=multi-user.target
StartLimitBurst=3
StartLimitIntervalSec=300s
[Service]
Type=oneshot
Restart=on-failure
ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
### Keybase proof
I hereby claim:
* I am ps1dr3x on github.
* I am ps1dr3x (https://keybase.io/ps1dr3x) on keybase.
* I have a public key ASAOMSkZS9IQcvRUMI58e-PMjmISJnxJepn4rY8KYj3-_wo
To claim this, I am signing this object:
@ps1dr3x
ps1dr3x / receive.py
Last active December 3, 2022 20:19
Send and receive a file using python's HTTPServer to receive and curl or powershell to send
from os import curdir
from os.path import join as pjoin
from http.server import BaseHTTPRequestHandler, HTTPServer
class StoreHandler(BaseHTTPRequestHandler):
store_path = pjoin(curdir, 'file')
def do_POST(self):
if self.path == '/':