Skip to content

Instantly share code, notes, and snippets.

View mrbid's full-sized avatar

James William Fletcher mrbid

View GitHub Profile
@mrbid
mrbid / increment.c
Last active August 19, 2022 13:10
Mission critical file increment helper process.
/*
James William Fletcher (github.com/mrbid)
February 2021
Mission critical file increments.
https://james-william-fletcher.medium.com/mission-critical-integer-increment-operations-from-php-c1c71fb42451
This file is compiled to a program that any
service can externally execute to ensure
a file increment or decrement operation
@mrbid
mrbid / increment2.c
Last active August 19, 2022 13:10
Mission critical file increment helper process. Variant 2.
/*
James William Fletcher (github.com/mrbid)
August 2021
Mission critical file increments. Variant 2.
https://james-william-fletcher.medium.com/mission-critical-integer-increment-operations-from-php-c1c71fb42451
This file is compiled to a program that any
service can externally execute to ensure
a file increment or decrement operation
@mrbid
mrbid / increment3.c
Last active August 19, 2022 13:10
Mission critical file increment helper process. Variant 3.
/*
James William Fletcher (github.com/mrbid)
August 2021
Mission critical file increments. Variant 3.
https://james-william-fletcher.medium.com/mission-critical-integer-increment-operations-from-php-c1c71fb42451
This file is compiled to a program that any
service can externally execute to ensure
a file increment or decrement operation
@mrbid
mrbid / math_bench.c
Last active June 12, 2023 20:20
A simple benchmark of FPU math functions using RDTSC.
/*
James William Fletcher (github.com/mrbid)
August 2021
Simple math function benchmark using RDTSC.
https://james-william-fletcher.medium.com/rdtsc-the-only-way-to-benchmark-fc84562ef734
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
@mrbid
mrbid / math_bench2.c
Last active October 22, 2022 10:49
A simple benchmark of FPU math functions using RDTSC + basic precision benching of sqrt().
/*
James William Fletcher (github.com/mrbid)
August 2021
Simple math function benchmark using RDTSC.
https://james-william-fletcher.medium.com/rdtsc-the-only-way-to-benchmark-fc84562ef734
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
@mrbid
mrbid / random_float_bench.c
Last active October 22, 2022 10:49
Benchmarking random float functions.
/*
James William Fletcher (github.com/mrbid)
August 2021
Benchmarking random float functions.
https://james-william-fletcher.medium.com/benchmarking-random-float-functions-in-c-13b9febb3d5b
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@mrbid
mrbid / rand_float_normal_bench.c
Last active October 22, 2022 10:49
Benchmarking random float functions with box muller transformation.
/*
James William Fletcher (github.com/mrbid)
August 2021
Benchmarking random float functions using
the box muller transformation.
https://james-william-fletcher.medium.com/benchmarking-random-float-functions-in-c-13b9febb3d5b
*/
#include <stdio.h>
@mrbid
mrbid / random_float_bench_ext.c
Last active October 22, 2022 10:46
Benchmarking random float functions. Extended.
/*
James William Fletcher (github.com/mrbid)
October 2022
compile: gcc random_float_bench_2022.c -Ofast -lm -o main
Benchmarking random float functions, an update to the original in August 2021:
https://gist.github.com/mrbid/51ed2963c88981452a5f87a3b072f8fb
https://james-william-fletcher.medium.com/benchmarking-random-float-functions-in-c-13b9febb3d5b
*/
@mrbid
mrbid / ioq3nst.py
Last active August 24, 2021 16:47
Real-Time Neural Style Transfer for ioQuake3 using TensorFlow Keras
# Code adapted from the original article by Orhan G. Yalçın
# https://towardsdatascience.com/fast-neural-style-transfer-in-5-minutes-with-tensorflow-hub-magenta-110b60431dcc
# For use in the following article concerning Real-Time NST in ioQuake3:
# https://james-william-fletcher.medium.com/real-time-neural-style-transfer-in-quake3-71cd5f6c3e4
import tensorflow as tf
import tensorflow_hub as hub
import sys
import time
import os
@mrbid
mrbid / screenshot.c
Last active August 19, 2022 13:09
Generate screenbuffers to /dev/shm on demand.
/*
James William Fletcher (github.com/mrbid)
https://gist.github.com/mrbid/deacf1f19ec521de68d1c017977a2653
This code is an adaption of;
https://stackoverflow.com/questions/34176795/any-efficient-way-of-converting-ximage-data-to-pixel-map-e-g-array-of-rgb-quad/38298349#38298349
It will loop indefinitely generating a new output to /dev/shm/dbuff.png every time the existing dbuff.png is deleted.
It should generate ~60 fps when compiled with GCC, or around 16 fps with clang for some reason. ¯\_(ツ)_/¯