Skip to content

Instantly share code, notes, and snippets.

View ozzyozbourne's full-sized avatar
🎯
Focusing

osaid khan ozzyozbourne

🎯
Focusing
View GitHub Profile
/*
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:

@ozzyozbourne
ozzyozbourne / slabAlloc.zig
Created December 3, 2024 06:24 — forked from lassade/slabAlloc.zig
allocates many slices with different sizes with a single allocation
pub fn SlabAllocation(comptime types: []const type) type {
var alignment: usize = 1;
var slices: [types.len]type = undefined;
for (types, 0..) |T, i| {
slices[i] = []T;
alignment = @max(alignment, @alignOf(T));
}
const out_alignment = alignment;
const Slices = std.meta.Tuple(&slices);
return struct {