Skip to content

Instantly share code, notes, and snippets.

View keith's full-sized avatar

Keith Smiley keith

View GitHub Profile
@nickdesaulniers
nickdesaulniers / hunting_private_dirty_memory.md
Last active August 20, 2026 18:06
Hunting Private Dirty Memory

Hunting Down Private Dirty Memory in Linux Shared Libraries

Shared libraries (.so files) on Linux are designed to save memory by sharing physical memory pages across processes via the kernel's Page Cache. But in practice, shared libraries often consume substantially more physical RAM than expected due to Copy-On-Write (COW) dirtying.

When a process writes to any page in a shared objectโ€”or when the dynamic linker (ld.so) writes relocated pointers at startupโ€”that 4 KB page is duplicated in physical RAM as Private_Dirty memory. If a library has 5 MB of dirty pages and is loaded by 100 processes, that library silently costs 500 MB of unshareable RAM.

Here is a practical, command-line-driven playbook for identifying private dirty hotspots in shared objects and resolving them in source code.


@mjkstra
mjkstra / arch_linux_installation_guide.md
Last active September 23, 2026 13:48
A modern, updated installation guide for Arch Linux with BTRFS on an UEFI system
@kconner
kconner / macOS Internals.md
Last active September 21, 2026 13:34
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

from os import urandom
from socket import create_connection
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.serialization import load_der_public_key
def read(sock, length):
result = b''
@MaskRay
MaskRay / implement-an-elf-linker.md
Last active September 18, 2026 04:52
Implement an ELF linker
theme default
class text-center
highlighter MaskRay
fonts
sans serif mono
sans-serif
serif
monospace
@saagarjha
saagarjha / swizzler.h
Last active July 27, 2026 18:01
Type-safe, RAII swizzler for Objective-C++
// Example usage:
// Swizzler<NSString *, NSDateFormatter *, NSDate *> NSDateFormatter_stringFromDate_ {
// NSDateFormatter.class, @selector(stringFromDate:), [&](auto self, auto date) {
// if ([NSCalendar.currentCalendar components:NSCalendarUnitWeekday fromDate:date].weekday == 4) {
// return @"It Is Wednesday My Dudes";
// } else {
// return NSDateFormatter_stringFromDate_(self, date);
// }
// }
// };
@x0nu11byt3
x0nu11byt3 / elf_format_cheatsheet.md
Created February 27, 2021 05:26
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

wget --no-check-certificate --recursive --domains=opensource.apple.com --no-clobber --accept "*.gz" --no-parent -l2 https://opensource.apple.com/tarballs
wget --no-check-certificate --recursive --domains=opensource.apple.com --no-clobber --accept "*.gz" -l2 https://opensource.apple.com/
wget --no-check-certificate --recursive --domains=opensource.apple.com --no-clobber --accept "*.gz" --no-parent -l3 https://opensource.apple.com/darwinbuild/
@TheSherlockHomie
TheSherlockHomie / RenewExpiredGPGkey.md
Created January 3, 2021 16:36
Updating expired GPG keys and backing them up ๐Ÿ”‘๐Ÿ”๐Ÿ’ป

Updating expired GPG keys and their backup ๐Ÿ”‘๐Ÿ”๐Ÿ’ป

I use a GPG key to sign my git commits.

An error like this one might be a sign of an expired GPG key.

error: gpg failed to sign the data fatal: failed to write commit object

Debugging the Swift Toolchain

Use these steps to debug components of the Swift toolchain. This allows you to see Swift's source code from the debugger โ€“ instead of disassembly. The debugger can also provide some variable names and values. This has been initially tested with libswiftCore.dylib.

These instructions were updated as of Swift 5.2.1.

Prerequisites