Skip to content

Instantly share code, notes, and snippets.

View JackStouffer's full-sized avatar
💭
I may be slow to respond. Email me.

Jack Stouffer JackStouffer

💭
I may be slow to respond. Email me.
View GitHub Profile
@JackStouffer
JackStouffer / llm-c-code-prompt.md
Created March 2, 2025 04:21
My LLM Prompt For Writing C

When generating C code, please adhere to the following style guidelines to ensure the code is maintainable, debuggable, and easy to modify:

  • Conceptualize programming as a sequence of data transformations, where specific input data is processed step-by-step to produce desired output data. For example, a program that handles HTTP requests can be understood as taking an HTTP request string and current database state to generate an HTTP response string. This perspective prioritizes concrete reasoning over abstract design principles often associated with object-oriented programming (OOP) or 'clean code' paradigms.
  • Avoid object-oriented programming and prioritize Plain Old Data (POD) structures and procedural solutions.
  • De-prioritize encapsulation as a design goal, focusing instead on simplicity and efficiency.
  • Prefer explicit error code returns while avoiding errno and exceptions
  • Avoid Deep Nesting: Do not use deeply nested if-statements. For sequential, dependent conditions, use boolean flags to contro
@JackStouffer
JackStouffer / test.d
Created January 4, 2017 20:55
std.conv.parse!double auto decoding test
import std.stdio;
import std.range;
import std.algorithm;
import std.traits;
import std.container;
import std.meta;
import std.conv;
import std.datetime;
Target parse1(Target, Source)(ref Source p)
@JackStouffer
JackStouffer / test.d
Created January 4, 2017 18:57
auto decoding test for std.conv.parse!int
import std.stdio;
import std.range;
import std.algorithm;
import std.traits;
import std.container;
import std.meta;
import std.conv;
import std.datetime;
Target parse1(Target, Source)(ref Source s)

Keybase proof

I hereby claim:

  • I am JackStouffer on github.
  • I am jackstouffer (https://keybase.io/jackstouffer) on keybase.
  • I have a public key whose fingerprint is 5F6A 81FC BB9E BEF0 CFA3 AD73 7E49 FBE6 8B88 208C

To claim this, I am signing this object:

@JackStouffer
JackStouffer / circuit_breaker.py
Last active October 14, 2016 15:18
A Circuit Breaker, basically a way to auto fail to relieve pressure on an external service after a number of failures in quick succession
import datetime
BREAKER_OPEN = 0
BREAKER_HALF_OPEN = 1
BREAKER_CLOSED = 2
class OpenException(Exception):
pass
import std.stdio;
import std.datetime;
import std.conv;
import std.traits;
import std.utf;
import std.range;
import std.algorithm;
Target parse2(Target, Source)(ref Source p)
if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) &&
################ Unified Information ################
Cores per CPU = 2
Threads per CPU = 4
------------------ TLB Information ------------------
Instruction TLB:
- - - - - ITLB1: - - - - - - - - - - - - - - - - - -
Page size = 4 KB
Pages count = 64
Pages count = 64
Associativity: 8-way associative
@JackStouffer
JackStouffer / dmd.conf
Created September 4, 2015 19:15
My dmd conf
[Environment]
DFLAGS=-I%@P%/../../phobos -I%@P%/../../druntime/import -w -dip25 -m64 -g -debug -L%@P%/../../phobos/generated/osx/debug/64/libphobos2.a
@JackStouffer
JackStouffer / quadtree.d
Created August 11, 2015 19:27
A Quadtree implementation in D with unit tests
import std.traits: hasMember;
/*
Quadtree implementation that allows the collision resolver
to only scan a small subset of the possible colliding objects
See Also:
http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374
*/
struct Quadtree(T, uint MAX_OBJECTS = 10, uint MAX_LEVELS = 5) if (
@JackStouffer
JackStouffer / ringbuffer.d
Created August 11, 2015 19:24
A simple ring buffer implementation in D with unit tests
import std.traits : isNumeric;
struct RingBuffer (T, uint buffer_length = 4) if (isNumeric!T) {
private T[buffer_length] buffer;
private T sum;
private byte lastIndex;
@safe @nogc nothrow pure {
this(const T initial_value) {
this.lastIndex = 0;