View summarize.c
This file contains 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
// Summarize a numeric sequence | |
// Ref: https://old.reddit.com/r/commandline/comments/11hw06b | |
// Ref: https://github.com/ahmedakef/summarize | |
// This is free and unencumbered software released into the public domain. | |
#include <float.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct { | |
double sum, err; |
View cmd.c
This file contains 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
// libtool-compatibility cmd.exe wrapper | |
// Converts libtool's Cygwin-style "cmd //c ..." to "cmd /c ..." | |
// $ cc -nostartfiles -o cmd.exe cmd.c | |
// This is free and unencumbered software released into the public domain. | |
#define MAX_PATH 260 | |
#define COUNTOF(a) (int)(sizeof(a) / sizeof(0[a])) | |
#define FATAL "cmd.exe (fake): CreateProcessW() failed\n" | |
#define CMDEXE "\\cmd.exe" |
View example.c
This file contains 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 -nostartfiles example.c | |
// $ cl example.c /link /subsystem:console kernel32.lib | |
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <xinput.h> | |
struct gamepad { | |
void (*XInputEnable)(BOOL); | |
DWORD (*XInputSetState)(DWORD, XINPUT_VIBRATION *); | |
DWORD (*XInputGetState)(DWORD, XINPUT_STATE *); |
View child.c
This file contains 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 -nostartfiles -o child.exe child.c | |
// $ cl child.c /link /subsystem:console kernel32.lib | |
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
int mainCRTStartup(void) | |
{ | |
HANDLE stdin = GetStdHandle(STD_INPUT_HANDLE); | |
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE); | |
for (;;) { |
View hin9.c
This file contains 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 -Isrc/hin -Isrc/system -Iexternal/basic/include \ | |
// hin9.c -luring -lz $(pkg-config lua-5.3 --cflags --libs) | |
// Ref: https://gitlab.com/tiotags/hin9 | |
// Ref: https://old.reddit.com/r/linux/comments/zl2vm1 | |
#define _GNU_SOURCE | |
#define HIN_USE_CGI | |
#include "external/basic/basic_args.c" | |
#include "external/basic/basic_endianness.c" | |
#include "external/basic/basic_hashtable.c" | |
#include "external/basic/basic_lists.c" |
View generator.c
This file contains 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
// Generates a random city adjacency list | |
// Ref: https://old.reddit.com/r/C_Programming/comments/zgdxqr | |
// This is free and unencumbered software released into the public domain. | |
#include <stdio.h> | |
#include <time.h> | |
#define NCITIES 1000 | |
#define NEDGES (NCITIES*10) | |
static int randint(unsigned long long *s, int n) |
View make-w64devkit-iso.sh
This file contains 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
#!/bin/sh | |
set -xe | |
dir="$(mktemp -d "${TMPDIR:-/tmp}/iso-XXXXXX")" | |
cleanup() { | |
rm -rf -- "$dir" | |
} | |
trap cleanup EXIT | |
todos >$dir/autorun.inf <<EOF |
View vocab.c
This file contains 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
// Find the @vocab element in an activity stream | |
// Ref: https://mccue.dev/pages/12-3-22-practical-advent | |
#include <string.h> | |
struct buf { | |
char *buf; | |
int len, off; | |
}; | |
struct tok { |
View randn.c
This file contains 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
// Approximate Random Gaussian Generator | |
// $ cc -O3 -fopenmp -o randn randn.c -lm | |
// $ ./randn | |
// Ref: https://old.reddit.com/r/algorithms/comments/yyz59u | |
// This is free and unencumbered software released into the public domain. | |
#include <math.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
struct kahan { double sum, err; }; |
View fuzz.c
This file contains 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
// Fuzz test for Jsonic | |
// $ afl-gcc -m32 -fsanitize=address,undefined fuzz.c jsonic.c | |
// $ afl-fuzz -m800 -iexamples/heroes -oout ./a.out | |
// https://github.com/rohanrhu/jsonic | |
// This is free and unencumbered software released into the public domain. | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include "jsonic.h" | |
static int explore(jsonic_node_t *root, char *buf) |
NewerOlder