Skip to content

Instantly share code, notes, and snippets.

@damonjw
damonjw / LICENSE
Last active October 13, 2024 18:18
Event driven simulator in Python, using async/await
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@d7samurai
d7samurai / .readme.md
Last active May 7, 2025 21:20
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Other gists in this series:

@mmozeiko
mmozeiko / tls_client.c
Last active March 21, 2025 15:58
simple example of TLS socket client using win32 schannel api
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#define SECURITY_WIN32
#include <security.h>
#include <schannel.h>
#include <shlwapi.h>
#include <assert.h>
#include <stdio.h>
@d7samurai
d7samurai / .readme.md
Last active April 21, 2025 20:02
Minimal WASAPI

Minimal WASAPI

Minimal WASAPI reference implementation. Runnable console application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft. Produces a steady sine wave sound.

(This is a re-post of the same gist I posted a few years earlier, simply due to me wanting the Minimal D3D11 series to be listed contiguously and it's not possible to hide or rearrange gists).

from typing import Optional, Tuple, Union, overload
_time_unit_map = {
"ps": -12,
"ns": -9,
"us": -6,
"ms": -3,
"s": 0,
}
@Boostibot
Boostibot / win32_stack_trace.c
Last active February 2, 2025 23:51
win32 stack trace
#include <stdint.h>
typedef struct {
char function[256]; //mangled or unmangled function name
char module[256]; //mangled or unmangled module name ie. name of dll/executable
char file[256]; //file or empty if not supported
int64_t line; //0 if not supported
} Platform_Stack_Trace_Entry;
//Captures the current stack frame pointers.
//Saves up to stack_size pointres into the stack array and returns the number of
@d7samurai
d7samurai / .readme.md
Last active March 19, 2025 21:29
Minimal D3D11 sprite renderer NEO

sponsored by SuperNeo copy 4

Minimal D3D11 sprite renderer NEO

Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.

Minimal D3D11 sprite renderer NEO 1337

Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.

The renderer is "im

////////////////////////////////
// NBHS - Non-blocking hashset
////////////////////////////////
// You wanna intern lots of things on lots of cores? this is for you. It's
// inspired by Cliff's non-blocking hashmap.
//
// To use it, you'll need to define NBHS_FN and then include the header:
//
// #define NBHS_FN(n) XXX_hs_ ## n
// #include <nbhs.h>
#include "friday.h"
Entry(InputWaveInfo)
{
wave_info *WaveInfo = (wave_info*)InputWaveInfo;
shared_wave_info *Shared = WaveInfo->Shared;
memory_arena Arena = {0};
Arena.Start = MemoryReserve(GigaBytes(64));
@Boostibot
Boostibot / rdtsc_frequency.c
Last active February 1, 2025 00:12
Get RDTSC frequency on linux x86
//Combination of the following:
// original gist: https://gist.github.com/pmttavara/6f06fc5c7679c07375483b06bb77430c
// discussion here: https://hero.handmade.network/forums/code-discussion/t/7485-queryperformancefrequency_returning_10mhz_bug/2#23567
// dump_vdso_data.c: https://gist.github.com/mildsunrise/c63505931534bd3c0e143c0db8cad3f3
//
// Original license:
// SPDX-FileCopyrightText: © 2022 Phillip Trudeau-Tavara <[email protected]>
// SPDX-License-Identifier: 0BSD
// https://linux.die.net/man/2/perf_event_open