Skip to content

Instantly share code, notes, and snippets.

View ozzyozbourne's full-sized avatar
🎯
Focusing

osaid khan ozzyozbourne

🎯
Focusing
View GitHub Profile
@ozzyozbourne
ozzyozbourne / latency.txt
Created August 15, 2026 19:05 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@ozzyozbourne
ozzyozbourne / gist:6630fa826240e1d04f412a1e9e1fe424
Created June 13, 2026 09:58
reference counted tree pruning example
use std::{rc::Rc, cell::RefCell};
#[derive(Debug)]
struct TreeNode {
val: i32,
left: Option<Rc<RefCell<TreeNode>>>,
right: Option<Rc<RefCell<TreeNode>>>
}
impl Drop for TreeNode { fn drop(&mut self) { println!(">>> Free Node {}", self.val); } }
@ozzyozbourne
ozzyozbourne / microgpt.py
Created June 12, 2026 09:49 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
W3siaWQiOiJ1bnRyYXBfb3B0aW9uc19zdGF0ZSIsInZhbHVlIjp7InVudHJhcF9jaGFubmVsX2hpZGVfYnV0dG9uX2pvaW4iOnRydWUsInVudHJhcF9jaGFubmVsX2hpZGVfYnV0dG9uX3B1cmNoYXNlIjp0cnVlLCJ1bnRyYXBfY2hhbm5lbF9oaWRlX2NoYW5uZWxfYmFubmVyIjp0cnVlLCJ1bnRyYXBfY2hhbm5lbF9oaWRlX2NoYW5uZWxfbWVudV9idXR0b25fc2hvcnRzIjp0cnVlLCJ1bnRyYXBfY2hhbm5lbF9oaWRlX2hvbWVfdGFiX3NlY3Rpb25fb3VyX21lbWJlcnMiOnRydWUsInVudHJhcF9jaGFubmVsX2hpZGVfaG9tZV90YWJfc2VjdGlvbl9zaG9ydHMiOnRydWUsInVudHJhcF9nbG9iYWxfZGlzYWJsZV92aWRlb19hdXRvcGxheSI6dHJ1ZSwidW50cmFwX2dsb2JhbF9oaWRlX2FsbF9hZHMiOnRydWUsInVudHJhcF9nbG9iYWxfaGlkZV9hbGxfc2hvcnRzIjp0cnVlLCJ1bnRyYXBfZ2xvYmFsX3ZpZGVvX3F1YWxpdHkiOiJoZDE0NDAiLCJ1bnRyYXBfaGVhZGVyX2hpZGVfY3JlYXRlX2J1dHRvbiI6dHJ1ZSwidW50cmFwX2hlYWRlcl9oaWRlX25vdGlmaWNhdGlvbnNfYmVsbCI6dHJ1ZSwidW50cmFwX2hlYWRlcl9oaWRlX3VwbG9hZF9idXR0b24iOnRydWUsInVudHJhcF9oZWFkZXJfaGlkZV92b2ljZV9zZWFyY2hfYnV0dG9uIjp0cnVlLCJ1bnRyYXBfaG9tZV9oaWRlX2Fkc19maXJzdF9zbG90Ijp0cnVlLCJ1bnRyYXBfaG9tZV9oaWRlX2Jhbm5lcnNfYWRzX3dpdGhfY2xvc2UiOnRydWUsInVudHJhcF9ob21lX2hpZGVfaGVhZGVyX3dpdGhfY2F0
/*
Minmal Cocoa Window with Metal API
No error handling intentionally to just show the happy path
IMPORTANT: you odin version needs to be using the commit edcd335 or later!
Otherwise you will get a silent error at runtime as Cocoa would have not been linked!
*/
package minimal_metal_window
import NS "vendor:darwin/Foundation"
@ozzyozbourne
ozzyozbourne / cpp_stm_free_tutorial.md
Created January 9, 2026 01:08 — forked from graninas/cpp_stm_free_tutorial.md
Software Transactional Memory in C++: Pure Functional Approach (tutorial)

Software Transactional Memory in C++: pure functional approach (Tutorial)

In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM) that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.

.global _main
.align 2
.data
msg: .ascii "Hello, World!\n" ; non-null terminated 'string'
len = . - msg ; Calculate string length (14 bytes)
.text
_main:
mov x0, #1 ; File descriptor 1 = stdout
apiVersion: v1
kind: ConfigMap
metadata:
name: otel-collector-config
data:
config.yaml: |
receivers:
otlp:
protocols:
http:
@ozzyozbourne
ozzyozbourne / bitonic_sort.cu
Created December 25, 2024 02:08 — forked from mre/bitonic_sort.cu
Bitonic Sort on CUDA. On a quick benchmark it was 10x faster than the CPU version.
/*
* Parallel bitonic sort using CUDA.
* Compile with
* nvcc -arch=sm_11 bitonic_sort.cu
* Based on http://www.tools-of-computing.com/tc/CS/Sorts/bitonic_sort.htm
* License: BSD 3
*/
#include <stdlib.h>
#include <stdio.h>
@ozzyozbourne
ozzyozbourne / std_log.md
Created December 3, 2024 22:49 — forked from kassane/std_log.md
Quick overview of Zig's `std.log`

A simple overview of Zig's std.log for Zig v0.12.0 or higher

Logging functionality that supports:

  • If a log message should be printed is determined at comptime, meaning zero overhead for unprinted messages (so just leave the code peppered with debug logs, but when it makes sense scope them; so downstream users can filter them out)
  • Scoped log messages
  • Different log levels per scope
  • Overrideable log output (write to file, database, etc.)
  • All the standard std.fmt formatting magic

Basic Usage: