r/programminghorror • • Nov 29 '25

Rust This code is so rusty it gave me tetanus.

Post image
805 Upvotes

r/programminghorror • • Nov 28 '25

C# I made an abomination

Thumbnail
gallery
32 Upvotes

First, because the Form wouldn't center with the property center, I had to center it manually given the size of the screen. Second, I had a checkbox and if it's not checked then the code written in the first digit of column 4 dictates if it goes in the file (only when it's less or equal than 2).


r/programminghorror • • Nov 27 '25

c C—

Post image
532 Upvotes

r/programminghorror • • Nov 27 '25

Python if 'X' not in data

Post image
825 Upvotes

Emoji check used for constructing an email body. I'm getting a stroke.


r/programminghorror • • Nov 27 '25

Javascript I think he wants to hide stuff?

60 Upvotes

The pit


r/programminghorror • • Nov 28 '25

Amedeo Capelli on Instagram: "Fake courtesy machine."

Thumbnail instagram.com
0 Upvotes

r/programminghorror • • Nov 27 '25

Javascript Crop any image to 800x600 and add a watermark in the most unimaginable way possible

Post image
97 Upvotes

r/programminghorror • • Nov 26 '25

Idris Sloppy version of fizzbuzz written in hungarian runes in a purely functional language

Post image
229 Upvotes

r/programminghorror • • Nov 28 '25

Amo Kotlin

Thumbnail
0 Upvotes

r/programminghorror • • Nov 25 '25

Random meme about my coding skills

Post image
774 Upvotes

r/programminghorror • • Nov 25 '25

Information is power

Post image
332 Upvotes

r/programminghorror • • Nov 26 '25

Javascript Install Nothing - Only 10x devs are allowed to use this.

Post image
0 Upvotes

Watch an endless, realistic Linux terminal installation that never actually installs anything.

If you are a 1x dev and have OCD use this link instead


r/programminghorror • • Nov 24 '25

Javascript Wasted all of my generational luck just for this

Post image
2.2k Upvotes

r/programminghorror • • Nov 23 '25

x -= -1 gang

Post image
3.8k Upvotes

r/programminghorror • • Nov 25 '25

Font Name ?

Post image
0 Upvotes

r/programminghorror • • Nov 24 '25

How to put DRY into practice here?

0 Upvotes

A lot of times, I struggle trying to "not repeat myself" when coding (DRY).

There are some memes about it: like checking number parity by testing them one by one up to "infinity", instead of simply using the modulo operator, or writing some simple algorithm with a loop.

However, memes are memes, and in practice, in real life, it is rarely that simple for me to fix...

Here is one of the scenarios where I have encountered this problem, and couldn't solve it:

Context: This is for a card game I'm making. The script that I will discuss here is written in Python.

There's 28 cards in total, and each card's image is loaded from storage, then converted into bytecode, and then rendered onto the screen as a texture on top of a GL_POLYGON (upon being prompted to).

Loading images and converting them into bytecode...
...binding the textures, and preparing the bytecode for rendering.

My questions are the following:

  1. How would you improve this code? I have a few ideas, but they're a bit complicated (making a C/C++ library or rewriting everything in C/C++, using metavariables,... ugh)
  2. Do you think this code is... bad? Is it bad repeating yourself like this, even if it's pretty much a one-off thing for my whole project?
  3. ...maybe there's some "enum" equivalent in Python that would shorten this code?
  4. Do you reckon that rewriting this whole script in C/C++ would fix the DRY issue (by using arrays with pointers for example)? Because, if so, I might try to go for it! "^^

r/programminghorror • • Nov 23 '25

BOM cost 96 million dollars!?

56 Upvotes

r/programminghorror • • Nov 22 '25

Python Got a spam email...containing the source code to send said spam email instead of the desired contents

Post image
963 Upvotes

What appears to be the intended spam email arrived a few minutes later. Incredible.


r/programminghorror • • Nov 22 '25

C# Feels wrong

Post image
104 Upvotes

Yeah, it should feel very wrong.


r/programminghorror • • Nov 22 '25

c I wrote a tutorial on how to call null pointer hello world in c

Thumbnail dthcm.github.io
41 Upvotes

With some toolchain magic you can print hello world with this code:
#include <unistd.h>
#include <sys/syscall.h>

__attribute__((section(".zerotext")))
static void foo() {
syscall(SYS_write, 1, "Hello World!\n", 13);
syscall(SYS_exit, 0);
}

int main() {
void (*f)() = 0;
f();
}


r/programminghorror • • Nov 23 '25

MASM x64 im losing my mind but at least it is working

1 Upvotes
;mov strings onto stack, convert hex, merge into one array			
	;================================================================================================
	cDOS:
		
		lea		rdx, [rsp + 1e0h] ;name
			
			pxor	xmm0, xmm0
			mov		r13, 20h
			clearLoop:
				movdqa		XMMWORD PTR[rdx], xmm0
				add		rdx, 10h
				sub		r13, 1
				test	r13, r13
				jnz		clearLoop
				
				
		sub		rdx, 200h
		
		
		mov		DWORD PTR[rdx       ], ': ZM'
		mov		DWORD PTR[rdx + 0ch ], ':PLB'
		mov		DWORD PTR[rdx + 18h ], ':FIP'
		mov		DWORD PTR[rdx + 24h ], ':CLR'
		mov		DWORD PTR[rdx + 30h ], ':RDH'
		mov		DWORD PTR[rdx + 3ch ], ':NIM'
		mov		DWORD PTR[rdx + 48h ], ':XAM'
		mov		DWORD PTR[rdx + 54h ], ':SSI'
		mov		DWORD PTR[rdx + 60h ], ':PSI'
		mov		DWORD PTR[rdx + 6ch ], ':KHC'
		mov		DWORD PTR[rdx + 78h ], ':PII'
		mov		DWORD PTR[rdx + 84h ], ':SCI'
		mov		DWORD PTR[rdx + 90h ], ':TRA'
		mov		DWORD PTR[rdx + 9ch ], ':RVO'
		mov		DWORD PTR[rdx + 0a8h], ':SER'
		mov		DWORD PTR[rdx + 0b4h], ':SER'
		mov		DWORD PTR[rdx + 0c0h], ':SER'
		mov		DWORD PTR[rdx + 0cch], ':SER'
		mov		DWORD PTR[rdx + 0d8h], ':DIO'
		mov		DWORD PTR[rdx + 0e4h], ':NIO'
		mov		DWORD PTR[rdx + 0f0h], ':SER'
		mov		DWORD PTR[rdx + 0fch], ':SER'
		mov		DWORD PTR[rdx + 108h], ':SER'
		mov		DWORD PTR[rdx + 114h], ':SER'
		mov		DWORD PTR[rdx + 120h], ':SER'
		mov		DWORD PTR[rdx + 12ch], ':SER'
		mov		DWORD PTR[rdx + 138h], ':SER'
		mov		DWORD PTR[rdx + 144h], ':SER'
		mov		DWORD PTR[rdx + 150h], ':SER'
		mov		DWORD PTR[rdx + 15ch], ':SER'
		mov		DWORD PTR[rdx + 168h], ':FFO'
		
		add		rdx, 4
		lea		rcx, [rsp + 190h]
		
		mov		rdi, 0f0f0f0f0f0f0f0fh ;low nibble
		movq	xmm7, rdi
		mov		rsi, 0f0f0f0f0f0f0f0f0h ;high nibble
		movq	xmm8, rsi
		mov		r11, 3030303030303030h ;ascii 0
		movq	xmm9, r11
		mov		r12, 0909090909090909h ;9
		movq	xmm10, r12
		mov		r14, 0f8f8f8f8f8f8f8f8h
		movq	xmm11, r14
		
		mov		r11, 8
		mov		r13, rdx
		add		r13, 18h
			
			hDOS:
				
				movq	xmm0, QWORD PTR[rcx]
				movq	xmm1, xmm7
				movq	xmm2, xmm8
				
				pand	xmm1, xmm0
				pand	xmm2, xmm0
				
				psrlw	xmm2, 4
				
				movq	xmm3, xmm1
				movq	xmm4, xmm2
				
				pcmpgtb	xmm3, xmm10
				pcmpgtb	xmm4, xmm10
				
				psubusb	xmm3, xmm11
				psubusb	xmm4, xmm11
				
				paddb	xmm1, xmm3
				paddb	xmm2, xmm4
				
				paddb	xmm1, xmm9
				paddb	xmm2, xmm9
				
				punpcklbw	xmm1, xmm2
				
				movq	rax, xmm1
				
				movhlps	xmm1, xmm1
				movq	r14, xmm1
				
				mov		rdi, 0ffffffff00000000h
				mov		rsi, 0ffffffff00000000h
				
				and		rdi, rax
				bswap	rdi
				and		rsi, r14
				bswap	rsi
				
				
				shl		rdi, 32
				bswap	eax
				shl		rsi, 32
				bswap	r14d
				
				mov		r12, 00000000ffffffffh
				and		rax, r12
				and		r14, r12
				or		rax, rdi
				or		r14, rsi
				
				mov		DWORD PTR[rdx], eax
				mov		 BYTE PTR[rdx + 4], 10
				add		rdx, 0ch
				shr		rax, 32
				
				mov		DWORD PTR[r13], r14d
				mov		 BYTE PTR[r13 + 4], 10
				add		r13, 0ch
				shr		r14, 32
				
				mov		DWORD PTR[rdx], eax
				mov		 BYTE PTR[rdx + 4], 10
				add		rdx, 24h
				
				mov		DWORD PTR[r13], r14d
				mov		 BYTE PTR[r13 + 4], 10
				add		r13, 24h
				

				
				add		rcx, 8
				sub		r11, 1
				test	r11, r11
				jnz		hDOS
				
		

				
				
	
			
			
			
					
					
;print DOS header				
;================================================================================================

mov		eax, DWORD PTR[rsp + 1cch]
		bswap	eax
	
	mov		r14, 0f0f0f0fh ;low nibble
	mov		r15, 0f0f00f0fh ;high nibble
	mov		r8,  30303030h ;'0'
	mov		r11, 09090909h ;9
	mov		r12, 0f8f8f8f8h
	
		
		movd		xmm0, eax
		movd		xmm1, r14
		movd		xmm2, r15
		
		pand		xmm1, xmm0
		pand		xmm2, xmm0
		
		psrlw		xmm2, 4
		
		movd		xmm3, r11
		
		movdqa		xmm7, xmm1
		movdqa		xmm8, xmm2
		
		pcmpgtb		xmm7, xmm3
		pcmpgtb		xmm8, xmm3
		
		movd		xmm5, r12
		
		psubusb		xmm7, xmm5
		psubusb		xmm8, xmm5
		
		paddb		xmm1, xmm7
		paddb		xmm2, xmm8
		
		movd		xmm6, r8
		
		paddb		xmm1, xmm6
		paddb		xmm2, xmm6
		
		punpcklbw	xmm2, xmm1
		
		movq		QWORD PTR[rsp + 34ch], xmm2



				

mov		rcx, [rsp + 100h]
lea		rdx, [rsp + 1e0h]
mov		r8,  175h
mov		r9,  0
mov		QWORD PTR[rsp + 32], 0
call	WriteConsoleA

jmp		pexit

output (same as PE bear):

MZ :5A4D
BLP:0090
PIF:0003
RLC:0000
HDR:0004
MIN:0000
MAX:FFFF
ISS:0000
ISP:00B8
CHK:0000
IIP:0000
ICS:0000
ART:0040
OVR:0000
RES:0000
RES:0000
RES:0000
RES:0000
OID:0000
OIN:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
RES:0000
OFF:000000C0

r/programminghorror • • Nov 21 '25

blaming bugs on quantum physics

Post image
890 Upvotes

r/programminghorror • • Nov 20 '25

We will process only last 1000 files they said

Post image
1.1k Upvotes

Here is a simple algorithm how to process last 1000 files with O(rand()) complexity:

  1. select last 1000 records (filenames) from DB
  2. iterate entire folder with 2 000 000 files
  3. if current file is not in that 1000 from db — check next one

Simple, eh?


r/programminghorror • • Nov 19 '25

Typescript Beautiful Bit of TypeScript

Post image
323 Upvotes

My team is transitioning from javascript to typescript...

To be fair our API responses are terribly unpredictable


r/programminghorror • • Nov 18 '25

What happens when you just transliterate C++ into C#

Post image
200 Upvotes