WTF Bites
-
How has this literal one-line function accumulated 15 commits and 5 bug reports?
... now im all sad.
-
-
Wait, did you see what the one line is?
return toString.call(n) === '[object Number]' && n > 0;
WTF!
-
@yamikuronue said in WTF Bites:
Wait, did you see what the one line is?
return toString.call(n) === '[object Number]' && n > 0;
WTF!
Ok, someone needs to write a NodeJS module named "return-first-argument-of-one-argument-function-that-is-the-module" and find a way to introduce bugs to that.
-
-
@yamikuronue said in WTF Bites:
toString.call(n) === '[object Number]'
Is that how you really do that type-check in JS? Because that just makes me very sad.
-
@yamikuronue any idea why modules like
is-negative
andis-positive
are separate instead of bundled together in a single library/module/whatever? Even if you only need one or the other, splitting them up makes a bigger mess than grouping them together. Compared to Boost,is-positive
is a quark.
-
@dkf
typeof
exists but type juggling and morons do too.
-
@arantor This being JS, I'd not be at all surprised if
typeof
didn't work in some cases (that don't happen in practice but which someone claims are theoretically possible if the installer is an utter moron…)
-
@dkf one of the bugs in that project suggests using typeof precisely because it's possible to overload the function currently being used, while not possible (AFAIK) to overload typeof.
-
@arantor Also, am I right in saying that the test succeeds for the string
"[object Number]"
?
-
@dkf I think so. How to get 6 bugs on a one line if statement.
-
@yamikuronue said in WTF Bites:
Wait, did you see what the one line is?
return toString.call(n) === '[object Number]' && n > 0;
WTF!TIL there is a global
toString
function.
-
Is that how you really do that type-check in JS? Because that just makes me very sad.
That's some funky code. I don't see why you can't do just
typeof(x) === 'number' && x > 0;
But maybe they micro-benchmarked it or there is some gotcha I don't see.
-
@cartman82 I think this one is worse:
How has this literal one-line function accumulated 15 commits and 5 bug reports?
That's nothing:
22 commits. No bug reports though.
-
@cartman82 said in WTF Bites:
Another glorious npm library.
This is the documentation page, with examples, installation instructions, rationale and license information.
-- FUCKING SNIP --
And this is the code.The entire library can be replaced with the highlighted section.
I mean, I appreciate the effort and everything, but come on. This should have been a blog article.
I'm not a JS-guy, but it looks it needs, because process could be undefined:
-
@cartman82 I think this one is worse:
How has this literal one-line function accumulated 15 commits and 5 bug reports?
The bug reports? Easily:
I wouldn't expect anything else. :]
ETA
'd (by @Yamikuronue, again!). I'll see myself out.
-
@yamikuronue said in WTF Bites:
toString.call(n) === '[object Number]'
Is that how you really do that type-check in JS? Because that just makes me very sad.
(typeof x == 'number' || x instanceof Number)
, so it catches both primitives and objects.I've checked and
(Infinity instanceof Number) === false
, so you should test for that too.
-
Is that how you really do that type-check in JS?
NO!
(I mean, you can, but
typeof
exists for a reason!)
-
@yamikuronue Grumpy Cat meme is .
-
@cartman82 said in WTF Bites:
typeof(x) === 'number' && x > 0;
But maybe they micro-benchmarked it or there is some gotcha I don't see.
Just curious, where did the brainworm of using the
typeof
operator like a function come from? you could remove the parentheses (and insert a space :P ) and it would work exactly the same.(typeof x == 'number' || x instanceof Number)
, so it catches both primitives and objects.Who the fuck uses number objects instead of primitives besides pedantic dickweeds?
-
@tsaukpaetra said in WTF Bites:
Hardest part was getting plastic to feed single sheets of paper effectively.
Wrapping a rubber band around a LEGO wheel isn't cheating...
-
@anotherusername said in WTF Bites:
@tsaukpaetra said in WTF Bites:
Hardest part was getting plastic to feed single sheets of paper effectively.
Wrapping a rubber band around a LEGO wheel isn't cheating...
Did that, it often grabbed a minimum of three sheets (somehow). Which isn't bad, just.... highly annoying.
-
@tsaukpaetra that's why you use a second wheel for the other side of the paper. Then you drive it in the backward direction, but with low enough power that once there's 1 sheet of paper between it and the main wheel it'll be overcome by the power of the main wheel and turn in the proper direction.
I dunno, I just made that up. I think something of that nature would probably work, though...
-
@anotherusername said in WTF Bites:
@tsaukpaetra that's why you use a second wheel for the other side of the paper. Then you drive it in the backward direction, but with low enough power that once there's 1 sheet of paper between it and the main wheel it'll be overcome by the power of the main wheel and turn in the proper direction.
I dunno, I just made that up. I think something of that nature would probably work, though...
Yeah, my skills at that point couldn't engineer that mechanism (though several years later it did occur to me, after observing a somewhat similar mechanism in an actual printer, though the lower part was a piece of cork to provide the relevant friction.
-
So I'm checking out this new mobile send/receive payments thing in my bank's mobile app. I get to the screen where you can request money from someone and it asks to enter the amount. Once you do that, well, there was no way I could see to move forward. Top right was "Cancel", top left was a back arrow, bottom left was a clear entry button, and bottom right was backspace. It used its own in-app keyboard rather than using the Android keyboard of your choice (probably as a sort of security measure, since it won't let me take screenshots). Then I discovered that I had to scroll the screen down to see the blue button labeled "Review" which was conveniently 2px off the bottom of the screen. I wasn't expecting that because it looked like everything fit on one screen what with the giant numpad and all.
-
I subscribe to a certain streaming video platform. My main use of this platform is through the Xbox one app. For several reasons, I ended my Xbox gold membership. Well after that expired, the app stopped working. Turns out you need to have an Xbox gold membership. Ok, that's stupid but not WTF material, really.
The ? It took me a while to track down the problem because the error message was "server error", upon which the app would close. That's it. Nothing else.
Oh, and it waited 2+ weeks after the gold subscription ran out to start having problems.
-
-
"Review" which was conveniently 2px off the bottom of the screen
Are you sure it wasn't 3px?
-
Today's dumbass problem: "Why the fuck are there functions in my Settings.php?!"
Today's dumbass install script:
# Copy files up a directory cp ./other/install.php ./install.php cp ./other/install.php ./Settings.php cp ./other/install_3-0_mysql.sql ./install_3-0_mysql.sql cp ./other/composerInstaller ./composerInstaller
Today's dumbass programmer: @yamikuronue XD
-
I wanted to type this:
public Mock<ICartWrapper> Cart { get; set; }
But instead, I typed this:
I didn't notice until it failed to build.
-
@alexmedia You're supposed to take the plastic off the candy before you eat it.
-
That's a lot of precision....
-
@anonymous234 said in WTF Bites:
That's a lot of precision....
plus or minus 60k digits is a huge error range.
-
Apparently this animation requires a scrollbar.
-
@lb_ you're nearly there, now you just need
<video controls="" src="URL goes here"></video>
.
-
@anotherusername it used to auto embed.
-
@lb_ well, it does for imgur links, because the oneboxer gets ahold of them.
-
@anotherusername I mean another video I posted in the same way auto-embedded. Not sure when it was changed, but it was in the lounge.
-
-
@jarry Who the fuck runs an AMA on GitHub‽
-
@jarry I see the argument, but how often does one need to compare to negative zero??
-
@anotherusername said in WTF Bites:
@lb_ well, it does for imgur links, because the oneboxer gets ahold of them.
Unless Chrome Mobile, which doesn't actually play them.
-
@tsaukpaetra IIRC they look like static images if the browser won't let them play automatically, because they also don't have the
controls
attribute. And I've noticed that imgur oneboxes have a mouseover layer on top that captures the mouse input, so you can't even right click to access thevideo
tag's normal Play option...
-
@anotherusername said in WTF Bites:
imgur oneboxes have a mouseover layer on top that captures the mouse input, so you can't even right click to access the video tag's normal Play option...
Yes, but on mine at least it gives the option to download it which sometimes almost works.
Download the download to play. It's the new fad.
-
@cartman82 the rationale behind it:
Those are some solid arguments for the linuxy/npm way, where you gather a million composable little lego pieces and then make exactly what you need from them, instead of trying to contort some bloated framework to fit your needs.
There are also well known counter-arguments: Quality control; Bloat and performance issues; Dependency complexity; Choice and decision overload.
I can see both sides, and will generally veer towards quality, whether it comes as a tiny one line module or an excellent framework.
-
@tsaukpaetra I usually just view raw and open the URL in a new tab.
-
@cartman82 said in WTF Bites:
I can see both sides
Me too, but let's not forget that the underlying issue (JS standard library and type punning rules suck) should be eventually fixed; and that those modules are just a symptom which shows that the underlying technology is broken.
It's also interesting that in the PHP world, which has the same problems, the common approach is using a large framework, not micro-modules.
-
It's also interesting that in the PHP world, which has the same problems, the common approach is using a large framework, not micro-modules.
PHP stdlib is pretty robust compared to js, so they don't really need to solve a bunch of small pain points with these micro-libs.
-
@anotherusername said in WTF Bites:
@tsaukpaetra I usually just view raw and open the URL in a new tab.
Same, but then I have new tab on me...