WTF Bites
-
You've got to be kidding me!
-
You've got to be kidding me!
I seem to recall some linter actually reformatting code to be like this. Turning that off was a "Premium" feature for some reason...
-
@Tsaukpaetra said in WTF Bites:
You've got to be kidding me!
I seem to recall some linter actually reformatting code to be like this. Turning that off was a "Premium" feature for some reason...
Nice codebase you have there. Would be a pity if anything happened to it
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
-
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
-
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
It's actually a thing.
-
@Zecc I usually prefer
if (!precondition) { error() } else { ... }
since it keeps the error message closer to the condition it's testing. I've had enough cases where it spits out a message, and you have to go up a few hundred lines to identify an if statement at hopefully the same indentation level with the corresponding condition.
-
@Zecc I usually prefer
if (!precondition) { error() } else { ... }
since it keeps the error message closer to the condition it's testing.if (!precondition) { throw error() }
orif (!precondition) { error(); return; }
are even better, because then the happy path does not get indented.I've had enough cases where it spits out a message, and you have to go up a few hundred lines to identify an if statement at hopefully the same indentation level with the corresponding condition.
That's what rainbow parenthesis are for.
-
@Bulb Probably one of those. Or tacking on else ifs if I've got a lot of sequential conditions to check. It's a shame people are so averse against comma expressions (or even if clauses with side effects in general)
-
-
It's actually a thing.
Indiana Jones and the Nested Conditional Pyramid of Doom!
-
@dkf coming out at a point the pyramids in question will contain the mummified remains of Harrison Ford?
-
@HardwareGeek said in WTF Bites:
if clauses with side effects
There are cases where
if let
, and it's older cousinsif ((x = something()) != NULL)
andif ((x = something()) >= 0)
are really useful. Especially when there is an if-elseif-elseifβ¦else chain of them, because then they avoid building the aforementioned pyramid of doom.
-
β¦ and note that while C#, Python and some other languages prohibit assignment in if, they do absolutely nothing to prevent other side-effects that are much less noticeable when reading the code.
-
really useful
I know; I've used them occasionally. But they're a waiting to happen.
-
while C#, Python and some other languages prohibit assignment in if
In Python, may I present to you the walrus operator,
:=
. May God safely guard your soul!
-
@Zecc I usually prefer
if (!precondition) { error() } else { ... }
since it keeps the error message closer to the condition it's testing.if (!precondition) { throw error() }
orif (!precondition) { error(); return; }
are even better, because then the happy path does not get indented.And when you have code quality metrics (at build time), that un-nesting is critical because it reduces nesting levels (I think ours starts warning at 3). It's annoying when you have to break one obvious function into 3 or 4 because of like that.
-
@Zecc I usually prefer
if (!precondition) { error() } else { ... }
since it keeps the error message closer to the condition it's testing.if (!precondition) { throw error() }
orif (!precondition) { error(); return; }
are even better, because then the happy path does not get indented.And when you have code quality metrics (at build time), that un-nesting is critical because it reduces nesting levels (I think ours starts warning at 3). It's annoying when you have to break one obvious function into 3 or 4 because of like that.
Clearly having multiple smaller pyramids is better than one giant pyramid, because it makes it much easier to obfuscate the bodies
-
while C#, Python and some other languages prohibit assignment in if
In Python, may I present to you the walrus operator,
:=
. May God safely guard your soul!I thought that was a tiny dick with no head....
-
@Tsaukpaetra The walrus takes offense at your disparaging commentary regarding his walrushood
-
@Applied-Mediocrity said in WTF Bites:
@Tsaukpaetra The walrus takes offense at your disparaging commentary regarding his walrushood
And remember folks, offense is taken, not given.
-
@HardwareGeek said in WTF Bites:
really useful
I know; I've used them occasionally. But they're a waiting to happen.
I consider the GCC solution pretty good: assignment in a boolean context produces a warning (which you can treat as error if you want) and can be silenced by adding extra parenthesis, which serve as quite good indicator that yes, you knew what you are writing.
-
WTF of my day: So, we have this electronic classbook. It allows us to document abscences, the schedule and various other things. Created by a 3rd party vendor.
Said software has some
For example, they seem to have two user databases. In order to allow a pupil to see his schedule, I first have to import all pupils (via CSV, there's no import adapter for our existing database). And then I have to "create users for all pupils". Thankfully I was able to figure out how their OpenID connector works so we don't have to hand out 1700+ pieces of password papers.
Also, creating roles like "Can view all schedules" is a very arcane thing to do.
Anyways, the new school year is looming up ahead and we now want to do a first import. Click on "master data", click on "pupils", click on "import" and ... see a spinner. And nothing else happens.
Okay, press F12 to see the console and it's a lovely HTTP500. "Create users for pupils" also yields a 500. As does "News of the day" for some reason.So I send an email to their official techsupport line that their server shat the bed. Received a ticket #, nothing else happened. Contacted my superior who then contacted our reseller - turns out that we're supposed to always go through our reseller first. Yes, because the Telephone Game is such a great idea when you fucked things up. I actually had to create a screencast to show the problem because our reseller couldn't replicate it (even though I stated very clearly what buttons to click and a screenshot of the error).
After the screencast it suddenly was a widespread and common problem.
But good news: They fixed the problem! Yeah, no. Still didn't work.
But while I was writing this, someone obviously restarted the API server in the background. Now it's actually working. But seriously, don't say: "We fixed it!" when you actually mean: "We're currently rolling out the fix and after a restart, it should work again in a few hours."
-
Why is educational-adjacent software awful?
-
Why is educational-adjacent software awful?
Because it's a subset of "software"
-
@Rhywden So, the issue was supposed to be fixed, right?
Yeah, about that:
This is from just now when I tried to do an import of the new pupils.
Funnily enough, trying to do a "report" on existing classes yields a
HTTP400
for some weird reason:Also seems to be the only place where they actually used a
try ... catch
because all the other places with the 500s are stuck indefinitely with no error message at all (save for the console ones, that is)Amateurs.
-
Why is educational-adjacent software awful?
There's a long list of reasons why it's extra bonus awful, but here are some:
- The people picking it aren't the use who have to use it.
- The people using are carefully kept from giving any sort of meaningful feedback.
- The people in charge definitively want somebody else to be on the hook if things go south, like leaking massive amounts of data.
- The decision makes are impressed by stupid flashy new UIs and idiot features like instant messages, both of which have almost zero utility.
- They make people pay through their noses for it, meaning using anything else is at best discouraged and at worst totally forbidden(tm).
- It typically tries to do everything, at least on paper, because not doing a thing, on paper, would leave a market gap for somebody else to come in.
- It caters to the dumbest possible users both in terms of students and in terms of staff, and doesn't acknowledge the existence of anybody else.
-
Entering a CAPTCHA on uninstall is one thing. Entering a completely unparseable CAPTCHA is another.
But it's from IBM so, fuck 'em.
-
@Arantor Have they tried entering SCHOONER?
-
@Applied-Mediocrity you dumb bastard! It's not SCHOONER it's SAILBOAT!
-
-
But it's from IBM so, fuck 'em.
Yeah, IBM does PCs, not Macs.
Wait - is that supposed to be one of those look-at-it-cross-eyed things? (Never could see those)
-
IBM does PCs
except when they do softwares
Wait - is that supposed to be one of those look-at-it-cross-eyed things? (Never could see those)
More like colour blind test
-
I see a faint, mirrored Debian logo.
-
@Arantor You have to wear those fancy 3d glasses to see the letters.
Also: What happens when you click "Try Another"?
-
Entering a CAPTCHA on uninstall is one thing.
A really, really retarded thing. Fuck off with that.
-
But it's from IBM so, fuck 'em.
Yeah, IBM does PCs, not Macs.
Wait - is that supposed to be one of those look-at-it-cross-eyed things? (Never could see those)
Now that you mention it β¦ yes, it might be, but after being photographed and scaled down the quality is not good enough to be sure.
β¦ it would be wrong for a captcha though, because some people don't see them, while a computer (being instructed by a programmer what to look for) should have no trouble interpreting them.
-
But it's from IBM so, fuck 'em.
Yeah, IBM does PCs, not Macs.
Wait - is that supposed to be one of those look-at-it-cross-eyed things? (Never could see those)
Now that you mention it β¦ yes, it might be, but after being photographed and scaled down the quality is not good enough to be sure.
β¦ it would be wrong for a captcha though, because some people don't see them, while a computer (being instructed by a programmer what to look for) should have no trouble interpreting them.
In other words, a perfect expectation about IBM.
-
@BernieTheBernie said in WTF Bites:
What happens when you click "Try Another"?
You get a different completely unparseable CAPTCHA
-
@TimeBandit Well, it could just show a and prevent you from continuing the uninstall.
-
This tool is comprised of a bunch of scripts meant to help get a certificate generated and signed so you can authenticate to the 802.1x ports. It works well enough.
It uses the filesystem inode number of the running user's home directory as the password for the private key.
Wonderful. Hope that's actually unique and non-predictable...
In case anyone wants to know the "algorythm", it can be found by running:
stat --file-system --printf=%i ~
-
But it's from IBM so, fuck 'em.
Yeah, IBM does PCs, not Macs.
IBM sold it's PC business to Lenovo in 2005. If you are using an IBM PC, it may be a little bit out-dated.
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
I saw something similiar recently in our code base but was only six or seven deep. I never got around to putting on light theme and seeing how pretty rainbow indent would be.
-
@Tsaukpaetra said in WTF Bites:
This tool is comprised of a bunch of scripts meant to help get a certificate generated and signed so you can authenticate to the 802.1x ports. It works well enough.
It uses the filesystem inode number of the running user's home directory as the password for the private key.
Wonderful. Hope that's actually unique and non-predictable...
Your backup broke my crypto keys!!!!!1
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
I saw something similiar recently in our code base but was only six or seven deep. I never got around to putting on light theme and seeing how pretty rainbow indent would be.
The MLP fixation thread is
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
I saw something similiar recently in our code base but was only six or seven deep. I never got around to putting on light theme and seeing how pretty rainbow indent would be.
The MLP fixation thread is
Well, given sufficient extra anthropomorphisation I wouldnβt mind indenting 6 or 7 deep into the pretty Rainbow Dash, thatβs trueβ¦
-
You've got to be kidding me!
Yes, it's obviously supposed to be:
} else {
... Yep...
The real question is... we have egyptian braces, but why don't we have pyramid somethings?
I saw something similiar recently in our code base but was only six or seven deep. I never got around to putting on light theme and seeing how pretty rainbow indent would be.
Yeah, I've seen a lot fewer of these things the last 10-15 years. Possibly because people don't care enough and just let the NPE bubble up instead.
-
@Tsaukpaetra said in WTF Bites:
It uses the filesystem inode number of the running user's home directory as the password for the private key.
Wonderful. Hope that's actually unique and non-predictable...Wait, so if you ever change home partition for any reason (backup restore, migration to bigger drive), it stops working?