Skip to content

Instantly share code, notes, and snippets.

View AlexTMjugador's full-sized avatar
🐰
Likely going down a rabbit hole to get a neat thing

Alejandro González AlexTMjugador

🐰
Likely going down a rabbit hole to get a neat thing
View GitHub Profile
@AlexTMjugador
AlexTMjugador / PlayerProfile.java
Last active September 16, 2022 23:35
Quick and dirty Minecraft offline to online mode UUID migrator. Works for a Paper server with some plugins, including LuckPerms, when using its default H2 storage engine.
package io.github.alextmjugador;
import lombok.Data;
@Data
public class PlayerProfile {
private String name;
private String id;
}
@AlexTMjugador
AlexTMjugador / Clone ext4 partition over network to a maybe different sized partition
Last active October 31, 2022 09:38
Clone a ext4 partition from a computer to another over the network, even if they have different sizes, as long as the filesystem contents fit in the destination partition. UUIDs and labels are copied, so bootloader and mount configurations do not need to be updated.
# Source computer commands (run these first):
$ sudo mount -o ro /dev/sda2 /mnt
$ socat -dd -u EXEC:"sudo tar -C /mnt --acls --xattrs --numeric-owner -vcf - ." TCP-LISTEN:2212
# Destination computer commands (the UUIDs and labels can be obtained with lsblk on the source computer).
# 192.168.0.2 is the IP address of the source computer:
$ sudo mkfs.ext4 -U <source filesystem UUID> -L <source filesystem label> /dev/nvme0n1p2
# Set partition UUID with fdisk (enter expert mode)
$ sudo mount /dev/nvme0n1p2 /mnt
$ socat -dd -u TCP:192.168.0.2:2212 EXEC:"sudo tar -C /mnt --overwrite --numeric-owner -vpxf -"
@AlexTMjugador
AlexTMjugador / reinstall-deb-subtree.sh
Last active November 17, 2022 14:43
Script to download and reinstall all the files within a subtree provided by the Debian packages installed on the system. Unlike reinstalling all the packages, this script only extracts the files within the specified subtree, does not execute any package setup scripts, and stores its results in a configurable directory, making it a better fit for…
#!/bin/sh -e
# Script to download and reinstall all the files within a subtree
# provided by the Debian packages installed on the system. Unlike
# reinstalling all the packages, this script only extracts the
# files within the specified subtree, does not execute any package
# setup scripts, and stores its results in a configurable $OUTPUT_DIR,
# making it a better fit for advanced Linux installation repairs.
#
# When the filesystem to repair does not match the root filesystem
@AlexTMjugador
AlexTMjugador / discticker.sh
Last active April 23, 2023 17:29
Shell script to create nice-looking animated Discord stickers. Supports processing several files in parallel.
#!/bin/sh -e
# Shell script to convert videos to APNG images suitable for use as Discord
# stickers. Tools used:
# - ffmpeg
# - pngquant
# - apngasm
while getopts r:f:p:m:h option; do
case $option in
@AlexTMjugador
AlexTMjugador / ffxiv_xivlauncher_proton_launch.sh
Last active February 3, 2024 12:54
FFXIV Proton launch script with XIVLauncher. Supports both launching the game outside of Steam via protontricks and from Steam, as a non-Steam game shortcut.
#!/bin/sh -e
# Script to setup and launch FFXIV using XIVLauncher on a Proton >= 8 Wine
# prefix. Can be used by adding this script as a non-Steam game to Steam and
# choosing the right Proton compatibility layer. Do not modify the default
# target directory, which matches the directory where this script is.
# XIVLauncher files must be installed in the "xivlauncher" subdirectory at the
# script directory. After launching FFXIV for a first time using Steam to set up
# the Proton prefix, launching it outside of Steam via protontricks is supported.
@AlexTMjugador
AlexTMjugador / bw-backup
Created February 28, 2024 17:58
Backup scripts for personal Bitwarden vaults, storing the results to a password-encrypted LUKS file volume. Perfect for simple and secure off-site backups of Bitwarden vaults where a little human interaction for providing key material is warranted.
#!/bin/sh -eu
# Backs up a personal Bitwarden vault to an encrypted LUKS file store.
. ./bw-common
echo '> Exporting personal vault to JSON file...'
bw export --format json --output "$WORKDIR"/backup/export.json
echo '> Exporting attachments...'
@AlexTMjugador
AlexTMjugador / build_date_time.rs
Last active November 23, 2024 23:13
Minimalistic and lightweight Rust code to fetch the build creation timestamp of the current executable for Windows platforms, without requiring any build-time script or configuration.
/// Minimalistic and lightweight Rust code to fetch the build creation timestamp of the current
/// executable for Windows platforms, without requiring any build-time script or configuration.
///
/// Only the following is required in your `Cargo.toml`:
/// ```toml
/// [dependencies]
/// windows-sys = { version = "0.59.0", features = ["Win32_System_LibraryLoader", "Win32_System_Threading", "Win32_System_ProcessStatus"] }
/// tz-rs = { version = "0.7.0", default-features = false }
/// ```
fn build_date_time() -> Option<UtcDateTime> {