Skip to content

Instantly share code, notes, and snippets.

View thesamesam's full-sized avatar

Sam James thesamesam

View GitHub Profile
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active June 14, 2026 22:44
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@MawKKe
MawKKe / cryptsetup-with-luks2-and-integrity-demo.sh
Last active June 24, 2026 17:43
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) ekkwam@gmail.com
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#
@gyakovlev
gyakovlev / porting-with-crossdev.md
Last active March 7, 2022 22:03
porting-with-crossdev.md
@rkeiii
rkeiii / gist:0fe05fdcee6f520c208280acbf2b49ea
Created September 10, 2022 23:20
Hack fix script for volumes suffering ZFS encryption bug
#!/usr/bin/env bash
#
# This script attempts to recover a ZFS filesystem afflicted by the bug described in
# the following GitHub issues:
#
# * https://github.com/openzfs/zfs/issues/13859
# * https://github.com/openzfs/zfs/issues/13521
# * https://github.com/openzfs/zfs/issues/13709
#
@Earnestly
Earnestly / posix-issue8.md
Last active October 30, 2024 12:40
A Selected List of Additions and Changes Coming With POSIX Issue 8
@kconner
kconner / macOS Internals.md
Last active July 21, 2026 14:43
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:

@vidraj
vidraj / rust-bootstrap.md
Created March 10, 2024 15:49
How to cross-compile Rust for musl-based ppc and ppc64 Gentoo systems

How to cross-compile Rust for musl-based ppc and ppc64 Gentoo systems.

Right now, there are no prebuilt packages for Rust on ppc-musl and ppc64-musl, and bootstrap on the host machines (ppc or ppc64) cannot be done, because the Rust project doesn't publish the necessary prerequisite binary stage0s.

These targets are, however, supported by Rust, and it is possible to build binary packages of rustc by cross-compiling from a build system with a working Rust installation. After such bootstrap, Rust can be

@rubyroobs
rubyroobs / git_repo_binary_investigation_idea.zsh
Last active May 21, 2024 22:17
a starting point for investigating anomalous contributions in git repositories
# ruby's git repo investigation zsh one-liner-ish thingy
# (a starting point for investigating anomalous contributions in git repositories)
echo "$(find . -type f ! -size 0 ! -path './.git*' -exec grep -IL . "{}" \;)" | \
sed -e "s/^\.\///g" | \
while read line; \
do \
echo ">>>>>>>>$line"; \
echo "$(git log --follow --find-renames=40% --pretty=format:"%ad%x0A%h%x0A%an%x20<%ae>%x0A%s" -- "$line" | head -n 4)"; \
commitdates="$(git log --follow --find-renames=40% --pretty=format:"%ae" -- "$line" | head -n 1 | xargs -I {} git log --author={} --pretty=format:"%ad")"; \
@smx-smx
smx-smx / XZ Backdoor Analysis
Last active February 24, 2026 09:30
[WIP] XZ Backdoor Analysis and symbol mapping
XZ Backdoor symbol deobfuscation. Updated as i make progress