Skip to content

Instantly share code, notes, and snippets.

@apsun
apsun / hax.c
Last active April 15, 2026 22:21
Hook main() using LD_PRELOAD
/*
* Hook main() using LD_PRELOAD, because why not?
* Obviously, this code is not portable. Use at your own risk.
*
* Compile using 'gcc hax.c -o hax.so -fPIC -shared -ldl'
* Then run your program as 'LD_PRELOAD=$PWD/hax.so ./a.out'
*/
#define _GNU_SOURCE
#include <stdio.h>
<!--
Example Office 2016 setup configuration.xml
1. Download setup.exe from https://www.microsoft.com/en-us/download/details.aspx?id=49117
2. Overwrite `configuration.xml` with this file
3. Run `setup.exe /download configuration.xml`
4. Run `setup.exe /configure configuration.xml`
This file currently is set to install the 32-bit US English version
of Office 2016 ProPlus with only Word, PowerPoint, and Excel.
@apsun
apsun / myalloc.c
Last active March 3, 2026 18:19
A simple C memory allocator
/*
* myalloc - a simplified reimplementation of glibc's malloc
*
* This allocator aims to follow in the spirit of the glibc implementation,
* but with simplicity as the main design goal, instead of efficiency or
* scalability. It uses a single free list instead of grouping blocks
* into buckets, and is not at all thread safe.
*
* Some assumptions made:
* - 2's complement, little endian, 8 bits per byte
@apsun
apsun / delet_tweets.md
Last active October 23, 2025 18:50
Delete your old tweets with this disgusting bash script

100% free. Runs completely locally on your machine. Bypasses the 3200 tweet limit. May require some eye bleach for the script. Here's how to use it:

  1. Go to settings -> account -> your Twitter data and request a download. This may take a few hours. You'll get an email with a link to download a zip file. Extract the zip file and navigate to the data directory.

  2. Go to Twitter in a web browser and find any Tweet you want to delete. We're going to use it to extract your authentication credentials for the next step. Open developer tools, delete the tweet, and find the request

@apsun
apsun / build.gradle.kts
Last active October 5, 2025 13:27
Documented build.gradle for publishing an Android library to Maven Central
// This is a documented version of the build.gradle file from RemotePreferences:
// https://github.com/apsun/RemotePreferences/blob/master/library/build.gradle.kts
//
// It aims to explain exactly WTF is going on when you inevitably copy-paste
// someone's build.gradle from the internet and can't figure out why it's not
// working.
//
// It contains, to the best of my knowledge, the best practices as of Oct 2023 for
// building an Android library and publishing it to OSSRH (Maven Central).
//
# Set brightness
bright() {
dbus-send \
--dest=com.ddcutil.DdcutilService \
--type=method_call \
/com/ddcutil/DdcutilObject \
com.ddcutil.DdcutilInterface.SetVcp \
int32:1 string: byte:0x10 uint16:"$1" uint32:0
}
@apsun
apsun / duplicity-backup.md
Last active May 12, 2025 05:40
Backup files using duplicity to Backblaze B2

This gist has graduated to a full-fledged project! All future updates will happen in the repo; this gist is no longer maintained.

duplicity -> Backblaze B2

Daily systemd timer to backup the contents of my filesystem to Backblaze B2. As-written, it will keep up to a year's worth of backups, performing one full backup every month. This script was tested with duplicity 3.0.3.

<html>
<body>
<svg width="1024" height="1024" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="shadow">
<feDropShadow result="drop-shadow-0" in="SourceGraphic" style="flood-opacity: 0.3;" stdDeviation="10" dx="0" dy="10"/>
</filter>
<clipPath id="clip-0">
<path style="stroke-width: 3px; fill: rgb(255, 255, 255);" d="M 100 724 L 100 300 C 100 185.001 170 99.995 300.026 100 L 724 99.995 C 854 100 924 185.001 924 300 L 924 724 C 924 839.001 854 923.995 724 924 L 300.026 924 C 170 924 100 839.001 100 724 Z"/>
</clipPath>
@apsun
apsun / nfc_normalize.sh
Last active March 25, 2025 07:55
NFC-normalize all filenames in the current directory
find . | grep -P '\p{M}' | xargs -d'\n' -L1 convmv -f utf-8 -t utf-8 --nfc --notest
@apsun
apsun / clean_firefox.sh
Created March 25, 2025 07:54
Clear Firefox history recommendations and cache
sqlite3 ~/.mozilla/firefox/*.default-release/places.sqlite 'delete from moz_origins;'
rm -rf ~/.mozilla/firefox/*.default-release/storage/default/**/cache