Skip to content

Instantly share code, notes, and snippets.

View eisenwave's full-sized avatar

Jan Schultke eisenwave

View GitHub Profile
@eisenwave
eisenwave / pointers.md
Last active July 25, 2025 09:13
How pointers in C++ actually work

How pointers in C++ actually work

Abstract: This document teaches you from the very basics to advanced features such as std::launder how pointers in C++ work. It is aimed at developers of any skill level. However, it links to the C++ standard so that advanced readers can verify the information and investigate further.

Motivation: Most tutorials on pointers are aimed at beginners, and present a simplified model. Some tutorials perpetuate an explanation of pointers that is solely based on their implementation (pointer = memory address). This tutorial aims to provide a comprehensive explanation of pointers that is in line with how they actually work from a language perspective.

@eisenwave
eisenwave / case_against_almost_always_auto.md
Last active September 19, 2025 09:13
The case against Almost Always `auto` (AAA)

The case against Almost Always auto (AAA)

Introduction

I've been writing C++ for half a decade now, and auto has always been a great source of discomfort to me. Whenever I came back to a past project that makes extensive use of it, I found myself confused, and first had to look at all the types before I could make sense of it.

Similarly, I've worked as an intern at a company that had a AAA policy for its code base. Whenever something didn't work, and I had to debug some code, half the time was spent just looking up types.

@leduyquang753
leduyquang753 / termFormat.py
Created February 2, 2022 05:57
Windows terminal output converter into Discord's ANSI code block.
# Terminal output converter into Discord's ANSI code block.
# Targeted at Windows terminal. Enable HTML text format when copying.
from bs4 import BeautifulSoup as BS
import cssutils as CSS
import win32clipboard as Clipboard
# Map the colors of your scheme to the standard 16 colors supported by the ANSI
# code block.
colorMap = {
@jeremy-rifkin
jeremy-rifkin / malloc.hpp
Last active April 15, 2025 19:46
High performance malloc implementation
uintptr_t base;
const uintptr_t height = 100000000;
std::mt19937 rng;
[[gnu::constructor]] void init_malloc() {
base = (uintptr_t) sbrk(height);
}
void* malloc(size_t) { // parameter ignored, we don't need it
return (void*)(base + rng() % height); // odds of any collision is like, low
}
void free(void*) {} // no-op
@msikma
msikma / rfc5646-language-tags.js
Created February 26, 2015 13:51
RFC 5646 Language Tags
// List of language tags according to RFC 5646.
// See <http://tools.ietf.org/html/rfc5646> for info on how to parse
// these language tags. Some duplicates have been removed.
var RFC5646_LANGUAGE_TAGS = {
'af': 'Afrikaans',
'af-ZA': 'Afrikaans (South Africa)',
'ar': 'Arabic',
'ar-AE': 'Arabic (U.A.E.)',
'ar-BH': 'Arabic (Bahrain)',
'ar-DZ': 'Arabic (Algeria)',