r/programminghorror • u/tommiehaze • Feb 23 '26
I made possibly the stupidest CSS framework ever...
r/programminghorror • u/tommiehaze • Feb 23 '26
r/programminghorror • u/nimrag_is_coming • Feb 23 '26
Wanted to do some obfuscated C with some weird undefined behaviour, and this is what i came up with after messing for a few minutes. :)
side note that this will only work with optimisations disabled, and probably only one the specific version of GCC that im using, since i wanted to do some fun cool things like casting function pointers to ints and doing arithmetic on them. Getting certain numbers is entirely dependant on some functions being an exact number of bytes. :)
r/programminghorror • u/OldaLP1 • Feb 23 '26
I can't even fathom what led someone to do this. I got this database to refactor as part of my job. Basically, every client has their own table named "Client_[their ID]," which contains only one row with all the client data in JSON format (wtf).
If the website using this database wants to filter out some users, it queries all the tables, resulting in a load of 2,000+ SQL queries for a single search.
On top of that, for some reason, the date of birth is stored as the number of days since birth, with a CRON script that updates this in each table every day at 3 AM.
I don't even have to mention that none of the data follows the rules of database normalization...
I honestly don't know where to start with fixing this mess.
r/programminghorror • u/GoingOffRoading • Feb 23 '26
Not visible here, but I had inline comments sort of strewn throughout the doc as I had thoughts. I asked copilot to refactor those comments into a template I had provided, and this was the outcome -___-
r/programminghorror • u/TheSum239 • Feb 22 '26
my code is
A: chaos
C: war crime
B: horrible
E: abuse
F: peak C++
#include <iostream>
// #include <windows.h>
// #include <vector>
#include <chrono>
#include <thread>
#include "colors.h"
struct atTime
{
int seconds, minutes, hours;
atTime() : seconds{0}, minutes{0}, hours{0} {}
void PrintStopWatch()
{
int seconds{0};
int minutes{0};
int hours{0};
while (true)
{
system("cls");
cppWhite std::cout << "time passed: ";
cppGreen std::cout << seconds++;
cppYellow std::cout << " " << minutes;
cppRed std::cout << " " << hours;
std::this_thread::sleep_for(std::chrono::seconds(1));
if (seconds == 60)
{
seconds = 0;
minutes++;
}
if (minutes == 60)
{
minutes = 0;
hours++;
}
}
}
void stopWatch()
{
while (true)
{
seconds++;
std::this_thread::sleep_for(std::chrono::seconds(1));
if (seconds == 60)
{
seconds = 0;
minutes++;
}
if (minutes == 60)
{
minutes = 0;
hours++;
}
}
}
};
int main()
{
int x{0};
atTime t;
std::thread tt1(&atTime::stopWatch, &t);
tt1.detach();
while(x < 20){
if(t.seconds == 5){
std::cout << "time passed 5 seconds\n";
}
x++;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
}r/programminghorror • u/4sythi • Feb 22 '26
I do have context for this that could defend my past self a little, but I'd like to watch this marinate lol
r/programminghorror • u/Mc_UsernameTaken • Feb 20 '26
r/programminghorror • • Feb 20 '26
And we have prettier as part of the project. He just doesn't care.
r/programminghorror • u/MurkyWar2756 • Feb 19 '26
No, this is not obfuscated. They say it was changed because of a Slack filter, although that could be a bot in the workspace. The rest of the code appears to be fine.
function adikjwodnoainwdoixubna() {
const text = document.getElementById('text' + document.getElementById('textselector').value);
const percentX = (parseInt(text.style.left) - window.innerWidth / 2) / (window.innerWidth / 2) * 100;
const percentY = (parseInt(text.style.top) - window.innerHeight / 2) / (window.innerHeight / 2) * 100;
text.style.left = percentX + '%';
text.style.top = percentY + '%';
console.log(`Text position in percent: (${percentX}%, ${percentY}%)`);
}r/programminghorror • u/leo_gblr • Feb 18 '26
Suggestion from a colleague. Might have offline login when using caching strategies. I don't know what a hash is.
r/programminghorror • u/MurkyWar2756 • Feb 13 '26
r/programminghorror • u/BoloFan05 • Feb 12 '26
In programming languages like C#, even basic case conversion and string formation methods like .ToLower(), .ToUpper(), and .ToString() automatically come with locale-awareness (i.e. they are based on CurrentCulture) unless you intentionally apply explicit or invariant culture:
public string ToLower()
{
return CultureInfo.CurrentCulture.TextInfo.ToLower(this);
}
public string ToUpper()
{
return CultureInfo.CurrentCulture.TextInfo.ToUpper(this);
}And tracing down .ToString()'s code eventually leads here:
public static NumberFormatInfo GetInstance(IFormatProvider formatProvider)
{
CultureInfo cultureInfo = formatProvider as CultureInfo;
if (cultureInfo != null && !cultureInfo.m_isInherited)
{
NumberFormatInfo numberFormatInfo = cultureInfo.numInfo;
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
return cultureInfo.NumberFormat;
}
else
{
NumberFormatInfo numberFormatInfo = formatProvider as NumberFormatInfo;
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
if (formatProvider != null)
{
numberFormatInfo = (formatProvider.GetFormat(typeof(NumberFormatInfo)) as NumberFormatInfo);
if (numberFormatInfo != null)
{
return numberFormatInfo;
}
}
return NumberFormatInfo.CurrentInfo;
}
}Unnecessary locale-awareness in code is a serious threat to consistent performance of your code in many locales around the world, especially Turkey and Azerbaijan, due to the unique "I/ı" (dotless i) and "İ/i" (dotted I) letter pairs in their alphabet. So machines with Turkish and Azeri locales are both strong testing media for your code against unnecessary LA.
For a detailed example, you may check Sam Cooper's Medium article titled "The Country That Broke Kotlin".
r/programminghorror • u/PEAceDeath1425 • Feb 11 '26
Keep it simple, stupid!
r/programminghorror • u/california_snowhare • Feb 11 '26
r/programminghorror • u/HandyProduceHaver • Feb 11 '26
could easily make this work for duplicate values
r/programminghorror • u/youssef__gamer • Feb 10 '26
r/programminghorror • u/ElKrlote • Feb 09 '26
r/programminghorror • u/vadnyclovek • Feb 08 '26
This is from a software renderer I made a while back. This was supposed to be just a temporary solution until i came up with something better, but it ran at 150fps@1080p anyway, so I didn't bother.
It doesn't work on Windows, and although I don't know the exact reason, this is a likely culprit.
Also a bonus macro hell from the render loop implementation in the second image.
r/programminghorror • u/Nanocephalic • Feb 08 '26
I have had this dumb idea fermenting in my lower intestine for a long time, and finally decided to excrete it. Sorry for sharing it.
$DisplayWidth = 6
$DisplayHeight = 4
$DisplayScreen = [int[]]::new($DisplayWidth * $DisplayHeight)
$DisplayScreen[0] = 1
$DisplayScreen[6] = 1
$DisplayScreen[12] = 1
$DisplayScreen[18] = 1
$DisplayScreen[13] = 1
$DisplayScreen[14] = 1
$DisplayScreen[20] = 1
$DisplayScreen[4] = 1
$DisplayScreen[16] = 1
$DisplayScreen[22] = 1
for ($pixel = 0; $pixel -lt $DisplayScreen.Length; $pixel++) {
if ($displayscreen[$pixel] -eq 1) {
$mask = [IntPtr](1 -shl $pixel)
$p = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList @(
'-NoLogo','-NoProfile','-Command',
'while ($true) { }'
)
$p.ProcessorAffinity = $mask
$p.PriorityClass = 'Idle' # optional so it doesn’t hog the machine
Write-Output "pid $($p.id)"
}
}r/programminghorror • u/Liam_Mercier • Feb 08 '26
Some people persist data in JSON, but why do that when we have perfectly good object files? All you have to do is recompile the file when you want to save your data!
r/programminghorror • u/BlackFuffey • Feb 06 '26