/r/programminghorror
Share strange or straight-up awful code.
RULES:
All posts MUST show terrible code. There are no exceptions.
No Editor Themes - If it's just your editor that looks bad, it doesn't belong here.
No Advertisement Code. This is generally written by people in marketing who only know what "code" looks like from other ads. It's not real code, so it doesn't belong.
No Student Code. Yes, they're learning, but bad code is part of the process.
No Generated Code. If it's minified JS, generated XML, or what have you, we don't want it here. Yes, the YouTube homepage has an extra right-angle bracket. We know.
No Asking for Help. Go to r/learnprogramming. What are you doing here?
No Spamming/Advertising. We don't care about your shitty Youtube video or new crypto that will "change the world".
Be Nice. No hate speech of any kind is allowed, as well as generally being a jerk. Talk about the code, not eachother.
No Direct Contact of the Mods. Please use the modmail, we don't want to be contacted directly.
Please direct stories without code to /r/talesfromtechsupport, and programming questions to /r/learnprogramming
Programming Horror is where developers come together to revel in the idiocy of our peers.
This subreddit is meant for sharing funny programming related stories and strange or straight-up awful code.
For the sake of not being mauled by rabid lawyer bears, please make sure to anonymize your stories - changing the names of people and companies.
For code examples, indent all your lines with 4 spaces to make it more readable:
foo = 'bar'
Sister subreddits
/r/programminghorror
Recently I've been exploring js proxies and I've been looking for a good excuse to explore tag functions. So I wrote this monstrosity to play with them together:
const wordReplacer = (word) => (strings, ...values) => {
return strings.join(word)
}
const proxyHandler = {
get(_, prop) {
return wordReplacer(prop)
},
};
const replaceWith = new Proxy({}, proxyHandler);
const Aaaah = replaceWith['Aaaah!']
const replaced = Aaaah`"${'Hello'}" said Bob to Alice.`
console.log(replaced) // "Aaaah!" said Bob to Alice.
https://gist.github.com/mike-pete/5dc3b185a909d2a1068bc50ea5698180
It feels like it'd fit in nicely with the other code in this sub lol
fr fr though proxies are pretty neat. I recently used them to build a typesafe RPC library for iframes. I you haven't used them before, definitely give them a try!
And you’re feeling a little trollsy
byte[] controlByteArr = new byte[] { controlByte };
System.arraycopy(controlByteArr, 0, output, CONTROL_BYTE_ADDR, controlByteArr.length);
Hi, I used to code a bit 1-2 years ago, but I recently got back into it a few months ago. Can someone help me get started maybe start making an application with someone. Ill learn everything i need fast. DM
I'm to blame for this one. You might be wondering what is wrong with this.
If you use json you might realize the directory back slashes aren't escaped.
On the JSON page it claims their strings are like C string and Java strings.
That's a lie. I can store directories in C string and it doesn't require escaping characters.
I really didn't want to deal with writing functions to escape everything and the later undo that.
So my solution is Not JSON or njsn. I get why it is there it makes full sense for it to exist with js.
So why is this a programming horror.
Well some poor person down the road is going to open this file and think it is json because he didn't read the documentation first.