This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Advent of Code 2025 Day 9 | |
| // $ cc -o aoc2509 aoc2509.c | |
| // $ ./aoc2509 <input.txt | |
| #include <stddef.h> | |
| #include <stdint.h> | |
| #define S(s) (Str){s, sizeof(s)-1} | |
| #define affirm(c) while (!(c)) unreachable() | |
| #define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is free and unencumbered software released into the public domain. | |
| #include <assert.h> | |
| #include <stddef.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #define lenof(a) (ptrdiff_t)(sizeof(a) / sizeof(*(a))) | |
| #define S(s) (Str){s, lenof(s)-1} | |
| #define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // $ cc -o parser parser.c | |
| // $ ./parser <schema.json | |
| // Ref: https://old.reddit.com/r/C_Programming/comments/1q0c2j7 | |
| #include <assert.h> | |
| #include <stddef.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #define lenof(a) (ptrdiff_t)(sizeof(a) / sizeof(*(a))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Basic template engine | |
| // $ cc -o template template.c | |
| // $ printf '<title>{{title}}</title>\nHello, <b>{{name}}</b>!\n' >index.html | |
| // $ ./template <index.html title='Example Page' name=skeeto | |
| // Ref: https://old.reddit.com/r/C_Programming/comments/1pypl5t | |
| #include <stdio.h> | |
| #include <string.h> | |
| int main(int argc, char **argv) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Ref: https://old.reddit.com/r/C_Programming/comments/1pxat1v | |
| #include <assert.h> | |
| #include <stdarg.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) | |
| typedef struct Dtor Dtor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // $ eval cc -g3 -o demo demo.c $(pkg-config --cflags --libs sdl2) | |
| // Ref: https://old.reddit.com/r/C_Programming/comments/1prwizy | |
| // Ref: https://github.com/Avery-Personal/Jubi | |
| #define JUBI_IMPLEMENTATION | |
| #include "Jubi.h" | |
| #include "SDL.h" | |
| static Sint32 randn(Uint64 *s, Sint32 lo, Sint32 hi) | |
| { | |
| *s = *s*0x3243f6a8885a308d + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://old.reddit.com/r/C_Programming/comments/1pr881z/ | |
| // $ cc -std=gnu23 -O -o baseline baseline.c | |
| #include <assert.h> | |
| #include <stddef.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <unistd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://old.reddit.com/r/C_Programming/comments/1pnh9fq | |
| #include <assert.h> | |
| #include <stddef.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define S(s) (Str){s, sizeof(s)-1} | |
| #define new(a, n, t) (t *)alloc(a, n, sizeof(t), _Alignof(t)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .section .exebuf,"bwx" | |
| .globl exebuf | |
| exebuf: .space 1<<21 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .section .exebuf,"bwx" | |
| .globl exebuf | |
| exebuf: .space 1<<12 |
NewerOlder