Skip to content

Instantly share code, notes, and snippets.

View dmcallejo's full-sized avatar

dmcallejo dmcallejo

View GitHub Profile
@dmcallejo
dmcallejo / gist:8b6a472af26784cf896efbfee805376f
Created November 26, 2024 10:10
Remove all traces of window manager and desktop environment from OrangePi OS
# Remember to create your own user and password before deleting everything with useradd -m <user> and passwd <user>
sudo pacman -Rnsc gtk-update-icon-cache qt5-base wayland xorg-server xorg-server-common xorg-xprop chromium calamares audacious clonezilla gtk2 gtk3 gtk4 karchive kauth kconfig gtk2 gtk3 gtk4 xfce4 lightdm
@dmcallejo
dmcallejo / gist:ee3a903e329e4b59763ad45b812e3aba
Last active October 1, 2024 08:01
Docker internals cheatsheet
# Check logs size of containers, sorted by size and show total usage
sudo du -ch $(docker inspect --format='{{.LogPath}}' $(docker ps -qa)) | sort -h | sed 's/\/var\/lib\/docker\/containers\///' | awk '{if ($1 != "total") {split($NF, arr, "/"); id = arr[1]; print $1 " " $2 " " id} else {print $1 " " $2 " " $1}}' | while read size unit id; do if [ "$size" != "total" ]; then name=$(docker ps --format "{{.Names}}" --filter id=$id); echo "$size $unit $name"; else echo "$size $unit $id"; fi; done
# Check all volumes and images sizes
docker system df -v
@dmcallejo
dmcallejo / fix-bcm4331.sh
Last active December 17, 2024 09:18
Fix for unstable and freezing Wi-Fi connection with Broadcom BCM4331 (i.e. Macbook Pro Early 2011). Also improves Wi-Fi speed.
# You may need to run this every time you boot a new kernel
sudo apt install --reinstall bcmwl-kernel-source; sudo modprobe -rv bcma; sudo modprobe -v wl
@dmcallejo
dmcallejo / gist:f426f9eaa9a968e18c66f1177e9894b2
Created January 5, 2024 19:58
Filename date to EXIF date
#!/bin/bash
FILES=$1*.*g
REGEX='.*(\d{4})-?(\d{2})-?(\d{2})(?>-|_|\s(?>at\s)?)(\d{2})(?>\.|-)?(\d{2})(?>\.|-)?(\d{2}).*'
for f in $FILES
do
echo -n "$f:"
date=$(echo "$f" | perl -ne 'print if m/'"$REGEX"'/' | perl -pe 's/'"$REGEX"'\..*/"$1:$2:$3 $4:$5:$6"/g')
if [ -n "$date" ]; then
echo $date
@dmcallejo
dmcallejo / reboot_genexis
Last active January 2, 2023 23:19
Programatically reboots Genexis routers used by ISPs like Adamo in Spain.
#!/bin/sh
help()
{
echo "Usage: reboot_genexis [ -p | --password (REQUIRED) ]
[ -u | --user default: user]
[ -h | --host default: 192.168.1.1 ]
[ --help ]"
exit 2
}
@dmcallejo
dmcallejo / gist:3aef05029222eb38604a61b1623784c8
Created November 16, 2022 10:41
Fix for "Too short!" error on avidemux
# This will recreate timestamps on the stream allowing avidemux to export the file. Note that the output has to be a Matroska container.
ffmpeg -start_at_zero -copyts -i input_file.ts -map 0:v -c copy -map 0:a:0 output_file.mkv
@dmcallejo
dmcallejo / grab-magnets-from-watchdir.custom-cont-init-script
Created January 4, 2022 16:04
Add magnet files from watch dir to transmission (with authentication, for linuxserver.io docker image)
#!/bin/bash
# Filename: grab-magnets-from-watchdir.custom-cont-init-script
# Save this file in /config/custom-cont-init.d/
# This way it will run everytime the container is created and will add the crontab entry and transmission authentication
# Save env files to get authentication
printenv | sed 's/^\(.*\)$/export \1/g' > /root/container.env
# Add entry to crontab, runs every minute
echo '* * * * * . /root/container.env; /config/grab-magnets-from-watchdir.sh' >> /etc/crontabs/root
@dmcallejo
dmcallejo / generate_ssl_cert.sh
Created June 17, 2020 10:46
Generate SSL self signed cert and key unattended
#!/bin/bash
# This line generates a self signed SSL certificate and key without user intervention.
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/C=AU/ST=Some-State/L=Sydney/O=Internet/OU=./CN=./emailAddress=."