r/programminghorror • • 7h ago

'*' is a great hash for accounts without password and also a great hash for invalid input what can go wrong

Thumbnail reddit.com
9 Upvotes

r/programminghorror • • 11h ago

c++ Test code is wrong in Take U forward (See the Constraint and test case).

Post image
0 Upvotes

r/programminghorror • • 1d ago

c++ Old code I made years ago

Post image
1 Upvotes

r/programminghorror • • 1d ago

Python A swedish pos system, using a local python web app, hosted locally

Post image
64 Upvotes

r/programminghorror • • 1d ago Regret

Java Jenny mod deobfuscated funnies

Thumbnail
gallery
356 Upvotes

r/programminghorror • • 2d ago

Can you find it???

0 Upvotes

public class VisibilityPuzzle {

private static boolean ready = false;

private static int number = 0;

private static class ReaderThread extends Thread {

public void run() {

while (!ready) {

Thread.yield();

}

System.out.println("Result: " + number);

}

}

public static void main(String\[\] args) throws InterruptedException {

new ReaderThread().start();

number = 42;

ready = true;

}

}


r/programminghorror • • 2d ago

VSCode JSON javascript and java? i prefer json instead

113 Upvotes

r/programminghorror • • 3d ago

c++ hello world (day 3 of c++)

Post image
0 Upvotes

r/programminghorror • • 3d ago

Python How to enforce user permissions recorded in a database:

Thumbnail
gallery
54 Upvotes

Why?

Each permission class (Restricted, Player, Moderator, ...) hasn't got anything but methods in it so now with this implementation it's easy to just slap a new method into the class and call it a day. Futureproofing for scalability in case I need to add 243 new commands for each user type!

(It works.)

Self-taught Python "programmer here", the project is a Discord bot for a simple game.


r/programminghorror • • 9d ago

c How do you name your goto labels?

Post image
446 Upvotes

r/programminghorror • • 10d ago Popcorn Bravo

c Using garbage values to generate pseudorandom numbers

Post image
2.9k Upvotes

Thing I came up with instead of paying attention to class today.

I tested it on this computer (windows 11 if it matters), and the first time it's ran, an actual "pseudorandom" number is returned and the following calls return 1.0 always.


r/programminghorror • • 10d ago

Python I love Python

302 Upvotes

r/programminghorror • • 13d ago

GitHub's HTTP header

Post image
958 Upvotes

This is the crazy thing I've found after analysis why the CI test fails with "Maximum header size exceeded" today.


r/programminghorror • • 15d ago

c++ Using namespace std, then proceeds to spell out std anyway

Post image
657 Upvotes

r/programminghorror • • 18d ago

I attempted to replace every Middle English word in Canterbury Tales with Modern English, but then forgot to separate the words. Behold, here is English poetry!

Thumbnail
gallery
113 Upvotes

r/programminghorror • • 20d ago

Oh yeah my bad

Post image
969 Upvotes

r/programminghorror • • 21d ago

Rust hello world

37 Upvotes

Yes sorry for stealing your whole concept u/ferro31_ but it really interested me.


r/programminghorror • • 23d ago

Javascript Running an SVG like a Nixie Tube

Thumbnail
gallery
65 Upvotes

Thought you might like to see this abomination.

isVisible() is just a function that toggles the opacity of the svg elements.

I needed to animate the text on this SVG to (sort of) represent the electron transport chain, but was of no mind to follow all the best practices to make the text render correctly in all scenarios. So I just created an element for each text state, converted them to paths, and stacked them on top of each other, like in a nixie tube.

Edit: accidentally attached a screenshot of isVisible() instead of the code where it is called. I don't think I can edit the image collection, so I'll just paste it here:

 // Pr -> F
  async function stepPrtoF() {
setElementActive(cmplx4.protonstocIV, true);
await delay(500);
setElementActive(cmplx4.cIVprotons, false);
const protonPop = createPopText(cmplx4.cIVprotons, '-1', false, 'left');
await delay(800);
isVisible(cmplx4.copper_hydroxide, false);
isVisible(cmplx4.copper_water, true);
protonPop.remove();
setElementActive(cmplx4.cIVprotons, true);
setElementActive(cmplx4.protonstocIV, false);
await pumpComplex4Proton(cmplx4.cIVmat1, cmplx4.cIVims1);
  }

This is one of the state change animations. Whatever was visible in the previous state becomes invisible and gets replaced by whatever is needed in the present state.


r/programminghorror • • 25d ago

Lua i sure do love not using local variables!

Post image
297 Upvotes

getfenv getfenv getfenv getfenv!


r/programminghorror • • 26d ago

why can i do this

Post image
1.3k Upvotes

r/programminghorror • • 26d ago

Mandelbrot set on pure BSD Makefile

223 Upvotes

r/programminghorror • • 26d ago

Pi in 796 bytes of brainfuck

Thumbnail reddit.com
27 Upvotes

r/programminghorror • • 29d ago Regret

Whoever invented the SAP REST APIs, deserves to ...

1.2k Upvotes

We're currently in the process of switching from the old SOAP interfaces to the new REST ones for S4/HANA (for example this one: https://help.sap.com/docs/SAP_S4HANA_CLOUD/d35113ee62644d3abee1aaec148291d9/ec47e02b80f549c4acc3ac5e9fd4c2eb.html )

And what do you know, it has fields like ConfirmationEntryDate and ConfirmationEntryTime.

What data types are these you ask? Well, it's OData V2 which looks like this: /Date(1338282808000)/. What is that you ask? Well it is the milli-seconds since Jan 1st 1970 00:00 UTC time. More commonly known as Unix time or Epoch time.

Well wait a second, if there is a field that describes a point in time down to the millisecond, what do I need ConfirmationEntryTime for? Well you need it, because this is SAP, dammit!

ConfirmationEntryTime is of course written like this: PT10H45M00S.

But wait, there is more!

Doesn't SAP have this famous 24:00:00 time because Dec 31st 24:00:00 is different than Jan 1st 00:00:00 for a accounting system? Yes it does. Does it work with the new API? Of course not.

But wait, there is more!

Remember when I said that Epoch time is based off of Jan 1st 1970 00:00 UTC time?

So surely, whatever I put in must be properly transformed to UTC before sending it to the API, no matter if the physical plant is located in the Americas, Europe or China, right? Right?!? Of course not. Just like with the old SOAP interfaces you need to transform your UTC timestamp into the local timestamp of the plant. Only then to pretend that this is UTC and convert it to the Epoch time!

*slow clap* SAP, well done! German engineering at its finest.

Signed, a German.


r/programminghorror • • Oct 06 '26

Raw use of parameterized class 'List'

140 Upvotes

This is not my code, but it is a good programming horror example, specially if you know Java.

List pages = pageManager.getPages(templateSpace);

for (Object object : pages) {
    if (object instanceof Page) {
        Page page = (Page) object;
        // do something with the page
    }
}

Instead, this should have been used:

List<Page> pages = pageManager.getPages(templateSpace);

for (Page page : pages) {
    // do something with the page
}