Skip to content

Instantly share code, notes, and snippets.

View lamarqua's full-sized avatar

Adrien lamarqua

  • Montréal, Québec
View GitHub Profile
@d7samurai
d7samurai / .readme.md
Last active October 20, 2025 09:24
Minimal D3D11 bonus material: extra minimal triangle

Minimal D3D11 bonus material: extra minimal triangle

A quick side exercise to see how little code one can get away with to put that RGB triangle on screen using D3D11 (without bending over backwards with trickery). This is a complete app in < 40 LOC (including the HLSL).

pretty minimal d3d11 triangle

For more.. elaborate.. D3D11 reference code, see the original Minimal D3D11, Minimal D3D11 pt2 and Minimal D3D11 pt3

@vmartins
vmartins / mame-roms1.md
Created September 27, 2022 17:49
MAME download all roms arcade (1/2)
@thefranke
thefranke / Redirector.json
Last active January 30, 2025 05:13
Redirector Configuration
{
"createdBy": "Redirector v3.5.3",
"createdAt": "2023-05-24T14:38:35.748Z",
"redirects": [
{
"description": "Wikipedia -> Wikiless",
"exampleUrl": "https://en.wikipedia.org/wiki/XYZ",
"exampleResult": "https://farside.link/wikiless/wiki/XYZ",
"error": null,
"includePattern": "*wikipedia.org/*",
// We have five kinds of nodes: literal, negate, not, add, xor.
// In this case we only need 3 bits for the tag but you can use as many as you need.
enum Tag {
LIT,
NEG,
NOT,
ADD,
XOR,
};
struct Object {
Key key; // The key is any piece of data that uniquely identifies the object.
// ...
};
struct Handle {
Key key;
Index index; // This caches a speculative table index for an object with the corresponding key.
};
@hagsteel
hagsteel / theme.vim
Created October 7, 2020 08:07
Vim colours
set background=dark
highlight clear SignColumn
highlight ColorColumn ctermbg=234
highlight LineNr ctermbg=234 ctermfg=14
highlight CursorLineNr ctermbg=23 ctermfg=7
highlight CursorLine ctermbg=236
highlight StatusLineNC ctermbg=238 ctermfg=0
highlight StatusLine ctermbg=240 ctermfg=12
highlight IncSearch ctermbg=3 ctermfg=1
@DavidBuchanan314
DavidBuchanan314 / life.c
Last active August 9, 2023 23:12
Yet another reformatting of my tiny game of life implementation. Valid ANSI C with no (default) compiler warnings or UB
#define F\
for(i=l;i\
<l*4; i++)
main(){int
i,j,w=512,
n,l=w*w,o[
]={~w,-w,-
w+1,-1,1,w
-1,w,w+1},
b[l*5];F b
@the6p4c
the6p4c / cursed.c
Created August 27, 2020 02:23
hey! don't do this!
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/io.h>
#include <sys/mman.h>
#include "elf.h"

Per,

Patching inline-caches is rare, so taking a lock & doing single-threaded updates is fine. No CAS needed for performance, nor is false-sharing an issue (this data is also code, so nearly always resides with other read-only code).

Patching typically covers a bunch of X86 ops, at least 2 but maybe 3 or 4, depending. If any of the updates to these words happens on partial instructions, a racing other CPU might see a partial update.

Patching covers a set of X86 instruction words, more than fits in an 8-byte CAS. 16-byte CAS's must be aligned properly.

Putting all this together, these constraints imply:

  • Updates are done via CAS covering whole instructions. No CAS spans a partial instruction.
@zwegner
zwegner / utf8_prob.py
Created June 30, 2020 18:41
Calculate probability of N-byte sequence being part of a valid UTF-8 sequence
from fractions import Fraction
ascii = range(0, 0x80)
cont = range(0x80, 0xC0)
cont_2_0 = range(0xA0, 0xC0)
cont_2_2 = range(0x80, 0xA0)
cont_3_0 = range(0x90, 0xC0)
cont_3_2 = range(0x80, 0x90)
leader2 = range(0xC2, 0xE0)
leader3_0 = range(0xE0, 0xE1)