Skip to content

Instantly share code, notes, and snippets.

@ajfabbri
ajfabbri / sector-mismatch-to-files.py
Created January 15, 2026 18:27
Script to find files affected by sector mismatches in linux md raid array
#!/usr/bin/env python3
# If you have a linux md (software) RAID array that is reporting sector
# mismatches, you can use this script to find which files are affected.
# Update the `err` and `DEVICE` definitions below, and ensure you have
# e2fsprogs installed. (This is for ext3 / ext4 filesystems).
from typing import List, Tuple
import subprocess
from subprocess import CompletedProcess
err = """
@ajfabbri
ajfabbri / idl-to-avsc.md
Last active June 7, 2024 18:23
Avro IDL to schema duplicates type defn's

When defining a named type (schema), and then using it as a field type in Avro IDL, that named type gets defined twice in the resulting Avro Schema files; once as a separate schema, and again inline (for each schema that uses it).

The IDL:

@namespace("v0_1_example")
protocol SanityCheck {
    enum TestEnum {
        Foo,
        Bar
@ajfabbri
ajfabbri / cryptvol.sh
Last active September 14, 2021 21:16
Bash script to create / open / close an encrypted linux volume backed by a single .img flie
#!/bin/bash
FILENAME="private.img";
KEYFILE=$HOME/.keys/${FILENAME}.key
KEYFILEGPG=$HOME/.keys/${FILENAME}.key.gpg
MOUNTPOINT=$HOME/enc
#MOUNTPOINT=$HOME/enc2
IMG_SIZE="10G"
MODE=""
VOLNAME="cryptvol"
@ajfabbri
ajfabbri / s3guard-empty-dirs.md
Last active December 17, 2016 02:19
HADOOP-13914: s3guard and S3AFileStatus#isEmptyDirectory

Dealing with S3AFileStatus#isEmptyDirectory

Problem: Creating or deleting a file requires updating the isEmptyDirectory bit on the parent directory.

The fact that the isEmptyDirectory flag is stored in S3AFileStatus makes it difficult to cache S3AFileStatus objects. This is essentially what S3Guard does, so this bit of logic needs special consideration.