Skip to content

Instantly share code, notes, and snippets.

@segin
segin / SPEC.md
Created March 2, 2026 02:26
elfobj

libelfobj — Specification

1. Purpose

libelfobj is a portable, zero-dependency C library for reading, creating, modifying, validating, and writing ELF (Executable and Linkable Format) object files. It serves as the sole ELF manipulation layer for all Substrate binutils (as, ld, nm, objcopy, objdump, readelf, strip, size, strings, ar, addr2line, elfedit).

2. Scope

Attribute Value

Substrate Assembler (as) — Specification

1. Purpose

The Substrate assembler (as) is a standalone, multi-architecture assembler that translates assembly language source files into relocatable ELF object files. It replaces the current GCC/GAS wrapper with a native implementation that has no external toolchain dependencies at runtime.

2. Scope

Attribute Value
@segin
segin / inflate.hpp
Created December 3, 2025 14:03
Vibe-coded PNG-to-JPEG converter
#ifndef INFLATE_HPP
#define INFLATE_HPP
#include "utils.hpp"
#include <vector>
#include <stdexcept>
#include <algorithm>
// A simple Inflate (Deflate decompression) implementation.
// Supports uncompressed blocks, fixed Huffman blocks, and dynamic Huffman blocks.
// Import required modules
const http = require('http');
const fs = require('fs');
const path = require('path');
// Define the port the server will listen on
const PORT = 3000;
// A simple in-memory data store
let apiData = {
@segin
segin / smartctl-dash-a.txt
Created December 17, 2023 08:55
HDD smart status
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.6.5-arch1-1] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Seagate BarraCuda 3.5 (SMR)
Device Model: ST8000DM004-2CX188
Serial Number: WCT0FVXJ
LU WWN Device Id: 5 000c50 0ad59fa62
Firmware Version: 0001
User Capacity: 8,001,563,222,016 bytes [8.00 TB]
@segin
segin / readexe-os2.txt
Last active August 12, 2023 17:25
readexe sample output
readexe-os2.exe:
DOS executable with magic: MZ (0x5a4d)
Number of executable pages: 0x0001 (0+ bytes)
Size of final page: 0x00000080 (128 bytes)
Total code size: 0x00000080 (128 bytes)
Total relocation entries: 0x0000
Header size in paragraphs: 0x0004 (64 bytes)
Minimum heap in paragraphs: 0x0000 (0 bytes)
Maximum heap in paragraphs: 0xffff (1048560 bytes)
Minimum memory to load: 128 bytes
@segin
segin / movies.zsh
Created December 5, 2022 02:54
subtitle sorter for rarbg releases
for MOVIE in */
do if [ -d "${MOVIE}/Subs" ]; then
mv -v $(ls -S ${MOVIE}Subs/*_English.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).eng.srt
mv -v $(ls -S ${MOVIE}Subs/*_French.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).fre.srt
mv -v $(ls -S ${MOVIE}Subs/*_Spanish.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).spa.srt
mv -v $(ls -S ${MOVIE}Subs/*_Dutch.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).dut.srt
mv -v $(ls -S ${MOVIE}Subs/*_Italian.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).ita.srt
mv -v $(ls -S ${MOVIE}Subs/*_Portugese.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).por.srt
mv -v $(ls -S ${MOVIE}Subs/*_German.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).ger.srt
mv -v $(ls -S ${MOVIE}Subs/*_hin.srt | head -n 1) ${MOVIE}$(basename ${MOVIE}).hin.srt
@segin
segin / grunthack0.1.0-no-guidebook-epstein.diff
Created October 25, 2019 09:29
grunthack0.1.0-no-guidebook-epstein.diff
--- grunthack0.1.0-no-guidebook.diff 2019-10-25 04:23:16.587197700 -0500
+++ grunthack0.1.0-no-guidebook-epstein.diff 2019-10-25 04:25:55.760627700 -0500
@@ -17814,7 +17814,7 @@
+ /* stick the proverbial two fingers up at the Gods,
+ * and go home */
+ display_nhwindow(WIN_MESSAGE, FALSE);
-+ You("return home with %s...",
++ You("return home with %s, realizing Epstein did not kill himself...",
+ the(xname(otmp)));
+ done(DEFIED);
@segin
segin / grunthack0.1.0-no-guidebook-epstein.diff
Created October 25, 2019 09:29
grunthack0.1.0-no-guidebook-epstein.diff
--- grunthack0.1.0-no-guidebook.diff 2019-10-25 04:23:16.587197700 -0500
+++ grunthack0.1.0-no-guidebook-epstein.diff 2019-10-25 04:25:55.760627700 -0500
@@ -17814,7 +17814,7 @@
+ /* stick the proverbial two fingers up at the Gods,
+ * and go home */
+ display_nhwindow(WIN_MESSAGE, FALSE);
-+ You("return home with %s...",
++ You("return home with %s, realizing Epstein did not kill himself...",
+ the(xname(otmp)));
+ done(DEFIED);
@segin
segin / fft.cpp
Created November 19, 2018 05:48
WASM test
#include <stdio.h>
#include <cmath>
#include <iostream>
using namespace std;
class FFT {
private:
float *real, *imag;
int size;