WTF Bites
-
@sebastian-galczynski said in WTF Bites:
And I always parenthesize the condition of a ternary
PHP developer detected
-
@homoBalkanus said in WTF Bites:
@sebastian-galczynski said in WTF Bites:
And I always parenthesize the condition of a ternary
PHP developer detected
Php has reversed ternary, because it wouldn't be retarded enough without it.
-
@sebastian-galczynski said in WTF Bites:
And I always parenthesize the condition of a ternary
PHP developer detected
You're not entirely wrong. But I think I would have started doing this elsewhere even if I hadn't been exposed to Pretty Horrible Precedences.
-
@sebastian-galczynski said in WTF Bites:
After some brainstorming we decided that they must have worded it badly and they mean "between expired and otherwise invalid token". But why would they need that? Can't they decode the JWT and check whether it's expired? Is their clock wrong?
Side note: this would actually make a sense. When the client does not have any means to validate the token signature (which is pretty much guaranteed in the case of frontend, and doubly so if the signature uses HMAC), it cannot check for token validity.
So, distinguishing "token expired, ask auth server for a new one" and "something is seriously wrong, are we under attack?" is quite handy.
-
@sebastian-galczynski said in WTF Bites:
And I always parenthesize the condition of a ternary
PHP developer detected
PHP made this sort of thing somewhat required now precisely to avoid that kind of shit.
In 7.4 this gets you a deprecated warning, in 8.0 this is a fatal error.
https://3v4l.org/vFasj for example.
-
== is higher.
The one that always gets me is that
==
is also higher precedence than&
, which makes no sense to me because why would I ever bitwise-and the result of a logical comparison with anything? Ideally that shouldn't even compile.
-
Transparent wood promises to be an environmentally friendly substitute for glass or plastic
Transparent wood is made by removing the lignin content in wood and replacing it with transparent, plastic materials.
-
@Gern_Blaanston said in WTF Bites:
Transparent wood promises to be an environmentally friendly substitute for glass or plastic
Transparent wood is made by removing the lignin content in wood and replacing it with transparent, plastic materials.
Ecologic ship of Theseus problem.
-
@ixvedeusi said in WTF Bites:
bitwise-and the result of a logical comparison with anything
'&&' won't evaluate the right-hand side expression if the left hand is false. '&' will evaluate both sides unconditionally, so '&' can be used to avoid introducing unwanted branches.
Of course, there are other ways of avoiding creating a branch, which may additionally be clearer to somebody reading the code.
-
@sebastian-galczynski said in WTF Bites:
And I always parenthesize the condition of a ternary
PHP developer detected
PHP made this sort of thing somewhat required now precisely to avoid that kind of shit.
In 7.4 this gets you a deprecated warning, in 8.0 this is a fatal error.
for example.Nice to see they work towards fixing it (making it work like in all other languages). Meanwhile in JS stuff like
typeof(null)=='object'
and[][0]
not throwing an error is seemingly forever.
-
@sebastian-galczynski PHP is working on being a better language.
Some of the gnarlier issues theyâre reluctant to touch (e.g. inconsistent naming in the string functions) but ever since PHP 7, each release has brought more strictness in general.
-
PHP is working on being a better language.
Jailhouse conversion, very inspiring
-
@Gern_Blaanston They didn't mention disposable utensils in the onebox blurb, but I've used wooden ones and they are absolute dogshit. 2/10, would not recommend
-
@hungrier IME wooden knives & forks are good enough compared to their plastic equivalents.
Someone needs to push wooden straws though because plastic straws got replaced with paper straws and paper straws are terrible.
inb4: paper straws suck
-
@loopback0 So far I've used them twice and both times they suffered a critical structural failure.
I'm also not a huge fan of wooden disposable chopsticks, but for a different reason: You can't just throw them out because they'll poke through your garbage bag
-
So far I've used them twice and both times they suffered a critical structural failure.
This happens with plastic knives and forks too
I'm also not a huge fan of wooden disposable chopsticks, but for a different reason: You can't just throw them out because they'll poke through your garbage bag
I'm one of those savages who struggles with chopsticks so doesn't use them irregardless of construction
-
@loopback0 I've had plastic forks and knives bend, but IME only when trying to do so. Wooden ones just split out of nowhere. Maybe my work just bought crappy ones, but I've seen no evidence that any other kind exists
-
I'm also not a huge fan of wooden disposable chopsticks, but for a different reason: You can't just throw them out because they'll poke through your garbage bag
Better than bamboo disposable chopsticks, because they're at least usable (by non-savages) before being thrown in the garbage. Bamboo has too low a coefficient of friction, so it's much more difficult to eat with them.
-
@loopback0 said in WTF Bites:
irregardless of construction
Including the construction of proper English sentences.
-
Title of a YT video:
-
POV: trying to authenticate to MS shit from a Windows VM for the first time.
Dear MS, did you notice that you asked me to pick an account here? That I did not type anything at all because there's nothing to type it into, only to pick the only account you're showing me? Of course not.
For whatever reason the default they're showing me is an alternate address attached to the same account I'm using locally, but of course it won't work as a login ID
-
@HardwareGeek said in WTF Bites:
I'm also not a huge fan of wooden disposable chopsticks, but for a different reason: You can't just throw them out because they'll poke through your garbage bag
Better than bamboo disposable chopsticks, because they're at least usable (by non-savages) before being thrown in the garbage. Bamboo has too low a coefficient of friction, so it's much more difficult to eat with them.
Easier than metal chopsticks. (Thanks, Korea!) But at least those you don't throw out.
-
POV: trying to authenticate to MS shit from a Windows VM for the first time.
Dear MS, did you notice that you asked me to pick an account here? That I did not type anything at all because there's nothing to type it into, only to pick the only account you're showing me? Of course not.
There is something to type into, hidden behind the â Use another account option.
For whatever reason the default they're showing me is an alternate address attached to the same account I'm using locally, but of course it won't work as a login ID
You are logging in from the VM for the first time, ain't you? So it does not actually have a remembered account yet. It sucked the guess it presented to you from the wrong finger, which is ⌠a minor wtf. It is a heuristic that probably works for most users who only have one address, at the cost of doing a very wrong thing for user's who have multiple. The smarter a heuristic is, the more spectacularly it may go wrong.
The smear suggests you only have one line there, so the account is neither âSigned inâ (if you already logged in with it to a different site) nor âConnected to Windowsâ (if you are logged in with it into the system and the AD-AAD integration is correctly set up).
If it was and still showed that message, it would obviously be wrong. But it isn't your case. It pulled the e-mail from some stray cookie and listed it because it might work.
-
@LaoC Of course the whole MS cloudless thing is a tangle of poorly integrated hacks that , so they were pushed into production. It kinda sorta works with a lot of gotchas all over the place. But that login isn't that much of a wtf. In the overall scheme of things anyway.
-
@Bulb It could have tried making no guess at all instead (which would be wrong for absolutely everyone) but that's about it. This is a "I've got this; maybe it's right?" level guess.
-
@dkf The point is not that MS guessed wrong; it's (I think) that MS is accusing him of mistyping its own bad guess.
-
@HardwareGeek said in WTF Bites:
@dkf The point is not that MS guessed wrong; it's (I think) that MS is accusing him of mistyping its own bad guess.
This. I would at least hope for a sub title of "imported from local account information" or someshit.
-
Weeee... Addressing some SonarQube code smells (or my PR won't pass)
if (something == other && boolVar)
Looks good, right?
BZZZZT
"Add parentheses around complex operands"Ooh. Even more fun. So I fixed the above, but needed a negative test.
if ((something2 == other2) && !boolVar)
BZZZZT
"Add parentheses around complex operands"So
operator!
needs to be parenthesized too.
-
@dcon Makes sense, you have two operators that are adjacent there...
-
@dcon Makes sense, you have two operators that are adjacent there...
Yeah, because
a && !b
could be read either asa && (!b)
or ...(a && !) b
?!
-
@dcon Makes sense, you have two operators that are adjacent there...
Yeah, because
a && !b
could be read either asa && (!b)
or ...(a && !) b
?!Well, it is C++, so who knows what overloading perversions someone has done. Haven't had any conditions with
operator*
oroperator&
so I don't know how SonarQube will react to those...
-
@dcon you can't change precedence. And even if you could, you can't change it to something that doesn't even make sense at the AST level.
-
you can't change it to something that doesn't even make sense
:cplusplus: Is that a challenge?
-
@dcon you can't change precedence. And even if you could, you can't change it to something that doesn't even make sense at the AST level.
-
@dcon Makes sense, you have two operators that are adjacent there...
Yeah, because
a && !b
could be read either asa && (!b)
or ...(a && !) b
?!Well, if the operands were swapped,
!a && b
could mean(!a) && b
or ... nothing else because all unary operators have higher precedence than all binary ones. Except maybe structure/union member access but I'm not even sure if that's classified as a binary operator.
-
Except maybe structure/union member access but I'm not even sure if that's classified as a binary operator.
IIRC it is classified as operator in C++ (non-overloadable, thank God), with highest precedence of all.
-
@Gustav Well, the structure member (
.
) is not overloadable. The structure pointer member (->
) is overloadable and overloaded really often.
-
@Bulb and let's not forget the
.*
operator, which actually has lower precedence than unary operators.
-
@Gustav I've only seen that once or twice in my careerâand it was probably me who used it back when I implemented âdelegatesâ on some project long ago well before C++11.
-
@Gustav I've only seen that once or twice in my careerâand it was probably me who used it back when I implemented âdelegatesâ on some project long ago well before C++11.
Same. I was about to say I've never encountered that in the wild, but then I remembered I once used it to write something too clever for my own good. Not quite sure, but I think my boss told me to scrap it. Probably for the better.
-
I'm sure there's a
goodreason for this, but it's highly unintuitive.Anyhoo, based on this SO post I was able to hack up a fix, so that's good for now.
-
@topspin it's hard to justify using dedicated byte-offset-in-struct types when 99.(9)% of those use cases are covered by array indices.
-
@Zecc You want to change your
d
tod2
for better$ex
?
-
@topspin it's hard to justify using dedicated byte-offset-in-struct types when 99.(9)% of those use cases are covered by array indices.
The usual case is member function pointers, and that is not covered by indices.
Also in that case it's far from a byte-offset-in-struct. In fact, back when I used it, I had to fiddle with some MSC++ options, because MSC++ has different representation of member function pointers depending on whether you have single inheritance, multiple inheritance or virtual inheritance, and, to save compilation time, a lot of the classes were forward-declared where the pointers were used, so the compiler didn't know and I had to force it to just use the more general representation.
⌠GCC does this better, it has one representation that isn't as expensive as the most general MSC++ one.
-
@Zecc You want to change your
d
tod2
for better$ex
?If you're really curious: this is part of a helper class mapping data from a IDataReader into a IList<T> using reflection.
It started throwing this exception once I made one of the properties nullable, a necessary change to accommodate for the data being that way.
-
@topspin it's hard to justify using dedicated byte-offset-in-struct types when 99.(9)% of those use cases are covered by array indices.
You tend to run into pointer-to-member types if you try to do (half-assed) reflection of any sort in C++. (I do wish we could get proper static reflection already.)
But, there, it's mostly templated code, so the fact that pointer-to-member has an awkward (potentially) representation doesn't really matter. Few if any of the pointer-to-member values should ever make it into runtime code.
-
-
@topspin it's hard to justify using dedicated byte-offset-in-struct types when 99.(9)% of those use cases are covered by array indices.
The usual case is member function pointers, and that is not covered by indices.
Also in that case it's far from a byte-offset-in-struct. In fact, back when I used it, I had to fiddle with some MSC++ options, because MSC++ has different representation of member function pointers depending on whether you have single inheritance, multiple inheritance or virtual inheritance, and, to save compilation time, a lot of the classes were forward-declared where the pointers were used, so the compiler didn't know and I had to force it to just use the more general representation.
⌠GCC does this better, it has one representation that isn't as expensive as the most general MSC++ one.
I read about that in an almost 2 decades old post about fast delegates (there's been several follow-ups since) and concluded that was a real mess I don't want to think about. Interesting that they haven't changed to a less complex implementation by now (maybe due to ABI constraints).
-
Interesting that they haven't changed to a less complex implementation by now (maybe due to ABI constraints).
I thought the various versions of msvcrNNN.dll are not abi-compatible anyway, which leaves either or the sheer horror of having to touch the twisted and tangled mess that reportedly is msvc++ innards.
-
I thought the various versions of msvcrNNN.dll are not abi-compatible
I was under the impression that Windows at some point had public C++ APIs and because of that the ABI is basically set in stone.