Skip to content

Instantly share code, notes, and snippets.

View kyle0r's full-sized avatar

Kyle kyle0r

  • Independent Consultant
  • Earth
View GitHub Profile
@kyle0r
kyle0r / cli visual comparison of similar directory hierarchies.md
Last active August 30, 2025 11:49
Side-by-side visual comparison of similar directory hierarchies with comm, vimdiff and rhash

I wrote and used these snippets to compare two root-filesystem backups from a KVM but they could be used for any similar directory hierarchy. The snippets helped me spot deltas between the two hierarchies and confirm the newer backup superseded the older one, so the old copy could be discarded.

Summary

This Gist presents a concise yet practical set of shell snippet recipes that help to visually and functionally compare two similar directory hierarchies (trees). For example, comparing two root filesystem backups, but it works for any pair of paths. The gist outlines three main approaches:

  1. comm → review output via less -S.
  2. vimdiff → interactively explore differences.
  3. rhash → compare checksums for exact binary verification, then view differences with comm or vimdiff.

This snippet dumps ext2/3/4 filesystem block allocation info in MiB's

Use case: you want block level allocation info without mounting the filesystem

Example output:

used: 8599.37 MiB
free: 13926.63 MiB
total: 22526.00 MiB
@kyle0r
kyle0r / ext_block_inspector.md
Last active August 26, 2025 00:47
Forensic inspection tool for ext2/3/4 partition images

This script is a forensic inspection tool for ext2/3/4 partition images that have been rescued with ddrescue or similar methods.
It allows the user to map and inspect specific regions of an image by either disk sector (LBA) or ext filesystem block number.

Download the latest version with curl:

curl -sSL 'https://gist.githubusercontent.com/kyle0r/b3b7df3576953f898d8495854dea13d0/raw/ext_block_inspector.sh' > ~/ext_block_inspector.sh

A containerised Linux desktop env setup

This gist is currently a Work In Progress.

These steps were practised and performed on a Debian Bookworm container and Proxmox 8.x Hypervisor (Debian). Instructions may vary for other releases/distros. Please DYOR and observe that YMMV. Comments, ideas and critique very welcome.

Speed run screencast: https://youtu.be/SFWV8blEdZQ

This gist is effectively a tech demo. I hope you enjoy and take away something useful.

The objective with most of the topics is to show ways / introduce tooling to boost productivity and the quality of our daily lives working in tech.

Capturing my steps for creating CIDR network lists (ipset) suitable for use with firewalls such as iptables and nftables.

For example, I reference this approach in my Secure defaults for Debian sshd_config and MFA gist.

The ipsets that I build in this gist reduce the permitted IPv4 hosts from ~4.28 billion to ~47 million, a reduction of ~98.88%, which helps to reduce the attack surface but still lets in some traffic including your preferred IPS/networks.
This approach is not as good as, or a replacement for, setting up a VPN or Bastion setup, or implementing Zero Trust Network Access (ZTNA), or reducing the host list to only trusted hosts/networks. These topics can be tricky for dynamic IP addressing setups and will be the subject of a future Gist.

Step 1 - determine relevant ASN(s)

Glossary: AS refers to the network itself, and ASN refers to the number that identifies tha

@kyle0r
kyle0r / HOWTO Easily edit any part of a git repos history or content.md
Created April 7, 2025 06:30
HOWTO easily edit any part of git repos history, file content, commits, authors, timestamps etc - from tail to tip

💡 Public Service Announcement: Editing a git repos history will cause the repo hashes to be recomputed, resulting in a divergence in remote refs/branches. A fetch followed by a force push will be required to update remotes.
This can wreak havoc on a project if contributors and maintainers are not "in the know".
Please think carefully about the implications for public repos and repos that you collaborate on with others.
I strongly encourage you to announce, in good time, that you intend to proceed with making such changes.


The anatomy of a git repo has various facets, including:

  • The file content
@kyle0r
kyle0r / Firefox Quick Tabs Ported 1.0.6.md
Last active April 6, 2025 18:55
Firefox Quick Tabs Ported 1.0.6 - fix popup search field focus issue

Modification of this XPI: https://addons.mozilla.org/firefox/downloads/file/3467566/quick_tabs_ported-1.0.6.xpi
Extension page: https://addons.mozilla.org/firefox/addon/quick-tabs-ported/

A recent version of Firefox caused issues with the extensions search field.
The search field intermittently stopped receiving focus when the popup was activated, especially when activating the extension via the configurable keyboard shortcut.

This code change to the popup.js should resolve the issue. Tested on Firefox 131.

Related issue thread from the original Quick Tabs Chrome project:
babyman/quick-tabs-chrome-extension#189 (comment)

@kyle0r
kyle0r / kostal-parse-actuals.md
Last active April 6, 2025 21:22
kostal-parse-actuals

First version: 2024.38.1
Current version: 2024.38.1

Description

I'm sharing my research and development script, the knowledge could be used to create a more mature script using Perl or Python, or your preferred development language.

The purpose of this script is to parse log data from Kostal PV inverters. The primary objective is to learn about the data available in the log and how it can be used, and to summerise the data, and provide data insights. The secondary objective is to produce summerised results and compare them with the Kostal Solar Portal or other PV analytics portals to verify the correctness of the script logic and mathematics. I've hosted an intro video on YouTube.

First version: 2024.20.1
Current version: 2024.21.1

Run iostats-for-zpool --help for usage.

iostats-for-zpool will attempt to show you a side-by-side iostat and zpool iostat with pool devices grouped together.

Intro video:

iostats-for-zpool.example.mp4
@kyle0r
kyle0r / dpkg-diff-pkg-file.md
Last active April 6, 2025 21:35
dpkg-diff-pkg-file - diff between original package file vs. local file

First version: 2024.18.1
Current version: 2024.18.4

Run dpkg-diff-pkg-file --help for usage. Also available at the top of the script.

dpkg-diff-pkg-file will attempt to show you a visual difference between an original package file vs. your local file. This can help resolve config drift and conflicts ahead of attended/unattended upgrades.

Intro video: https://www.youtube.com/embed/19wm3gI4LfI

INSTALL