WTF Bites



  • @levicki said in WTF Bites:

    @Vixen But you must respect me, that's my chosen pronoun! 🚎

    I respect you to the exact extent that you have shown you deserve.

    And you are NOT my mistress. I can acknowledge no one but my mistress as being over me.


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    Clicking the [X] or Cancel

    There shouldn't be a cancel button in the first place!

    @levicki said in WTF Bites:

    did you mean "Not now" or "Never again"?

    No, that question would have been "Submit now" or "Submit later". Affirmative actions, baby!

    @levicki said in WTF Bites:

    Did you perhaps mean to close another window which was below when this one popped up and you now regret closing the survey with no direct way of getting to it again?

    If your UI is so fucking terrible that you can't tell the difference, that's not my problem.

    @levicki said in WTF Bites:

    There certainly is room for improvement though:

    That was never in question.

    @levicki said in WTF Bites:

    Given that it pops up only once a year and that it takes less than 5 seconds to complete not having "Remind me later" option is totally reasonable.

    Remind me later == 1 year from now. But tell me why your option is much better Master UI Builder!

    @levicki said in WTF Bites:

    when I am criticizing something badly done I can also suggest how to improve it and you obviously cannot even explain what exactly is wrong with this UI except that you were blind as a bat and didn't see yuge "No, thanks" option but instead went on a rampage in Task Manager and on a totally pointless rant here.

    Punctuation! Can you use it?!?! Also, no, you didn't suggest how to improve it until pushed, so I call BS.

    @levicki said in WTF Bites:

    Please call me Master.

    Okay Master Fucktard.

    @levicki said in WTF Bites:

    my posterior is adequately padded.

    Ah, that explains how so much shit is available for you to spew forth.


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    @Vixen But you must respect my wish, that's my chosen pronoun! 🚎

    Master is not a pronoun.


  • Discourse touched me in a no-no place

    We don't need to discuss pronouns in another topic.

    :arrows:


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    So you are a 'tard and you want me to fuck you?

    If you don't know me by now... 🎵



  • @Bulb said in WTF Bites:

    In a C++ library we have a singleton with a virtual destructor.

    @Bulb said in WTF Bites:

    Ok, it gets worse. The getInstance is a template and the class is actually inherited. :wtf_owl:

    @Bulb said in WTF Bites:

    @Gąska said in WTF Bites:

    @Bulb I'm pretty sure the 3rd :wtf: is a workaround for the 2nd :wtf:. I think the rules for regular methods in header and template methods in header are very different regarding instantiation of static variables.

    Inline methods do produce common symbols and get merged and methods defined in the class definition are implicitly inline, so that would not be a problem. But I looked into the commit that introduced this, and the singleton is actually being inherited!

    I didn't see #2 and #3, but this sounds like one of the (older?) "standard" ways of implementing singletons.



  • @loopback0 said in WTF Bites:

    Firefox's task manager shows it using this much memory:

    a2165a67-ab80-4569-88be-87d7364c7282-image.png

    Windows disagrees:

    ab1b1a7c-aded-4adf-a8dd-8c22aa4111d2-image.png

    Volume of all instantiated objects vs. volume of assigned memory blocks – i.e. used vs. available?



  • @Tsaukpaetra Next you're going to say that asshole and meatsack are not pronouns.


  • Notification Spam Recipient

    @Carnage said in WTF Bites:

    @Tsaukpaetra Next you're going to say that asshole and meatsack are not pronouns.

    No, they're snacks!


  • I survived the hour long Uno hand

    @levicki
    You say that as if SO advice for every programming problem ever wasn’t “roll your own”



  • @izzion said in WTF Bites:

    @levicki
    You say that as if SO advice for every programming problem ever wasn’t “roll your own”

    What about the fraction that are "use jQuery"?


  • I survived the hour long Uno hand

    @Benjamin-Hall said in WTF Bites:

    @izzion said in WTF Bites:

    @levicki
    You say that as if SO advice for every programming problem ever wasn’t “roll your own”

    What about the fraction that are "use jQuery to roll your own"?

    FTFY



  • @Tsaukpaetra said in WTF Bites:

    List of Pronouns

    How can they possibly keep that list up-to-date?



  • I think I found a legitimate use for goto in C besides goto cleanup;-kind of error recovery, generated FSMs and such

    whitespace:
      /* Skip leading whitespace */
      while (*src == ' ' || *src == '\t') ++src;
      /* a long element may be continued by ending the line with a backslash */
      if (*src == '\\' && *(src+1) == '\n') {
        src += 2;
        goto whitespace;
      }
    

    vs

      int in_whitespace = 0;
      do {
        /* Skip leading whitespace */
        while (*src == ' ' || *src == '\t') ++src;
        /* a long element may be continued by ending the line with a backslash */
        if (*src == '\\' && *(src+1) == '\n') {
          src += 2;
          in_whitespace = (*src == ' ' || *src == '\t');
        }
      } while (in_whitespace);
    

    (The code continues with the invariant esablished that if src doesn't point at a token, it's either a NUL terminator or something it's not supposed to understand.)

    I also might be overlooking a simpler way to write that, given the constraints.



  • It's unrelated, but unless you have extra checking that's not in the code you posted, *(src+1) is dangerous: you may be accessing memory past the end of the buffer.
    My mistake. Since && implies lazy evaluation, and the buffer is NUL-terminated, that can't happen in (*src == '\\' && *(src+1) == '\n').

    Minor style note: *(src+1) is usually written as src[1].



  • You can avoid using goto like this:

    for (;;)
    {
        char c = *(src++);    
    
        if (c == '\\' && *src = '\n')
        {
            src++;
        }
        else if (c != ' ' && c != '\t')) break;
    }
    

    Whether it is acceptable or not depends on your style guide (some prohibit using break in for loops).


  • Notification Spam Recipient

    @dcon said in WTF Bites:

    @Tsaukpaetra said in WTF Bites:

    List of Pronouns

    How can they possibly keep that list up-to-date?

    It was created before "pronoun" meant "identity".


  • BINNED

    @levicki said in WTF Bites:

    C++ standard library WTFs:

    1. Even after all C++(03|11|14|17|20)... revisions std::string and std::wstring still don't have ltrim(), rtrim(), trim(). One would think that C++ standard committee geniuses would think of adding something that trivial to the standard library when even QBasic 1.1 had those 28 years ago.

    I think this goes back some 15-20 years to the generally accepted idea (see Meyers, Sutter) that std::string has “way too many member functions” already. Which is easily explained with standard design advice like the Single Responsibility Principle that classes should have, well, the name says it all, and thus in C++ you should “prefer non-member non-friend” functions if possible.
    And yet it ignores that in every other language (or even framework), including better designed ones, strings do have all these member functions like trim, because they’re basic and useful. It also ignores that putting the functionality in a non-member doesn’t actually reduce any complexity and the resulting call syntax sucks, e.g. for chaining. But somehow this irrational hatred of the number of member functions in std::string has prevented adding any further, and for some unfathomable reason also prevented at least adding something like std::trim as a non-member like the advise says.

    I’m pretty sure that my codebase somewhere has the following

    // Providing a trim function in the standard lib would be too much to ask.
    std::string trim(const std::string& s) {
    


  • @Zerosquare said in WTF Bites:

    You can avoid using goto like this:

    for (;;)
    {
        char c = *(src++);    
    
        if (c == '\\' && *src = '\n')
        {
            src++;
        }
        else if (c != ' ' && c != '\t')) break;
    }
    

    Whether it is acceptable or not depends on your style guide (some prohibit using break in for loops).

    Are there style guides that forbid break but allow goto?


  • Notification Spam Recipient

    @hungrier said in WTF Bites:

    @Zerosquare said in WTF Bites:

    You can avoid using goto like this:

    for (;;)
    {
        char c = *(src++);    
    
        if (c == '\\' && *src = '\n')
        {
            src++;
        }
        else if (c != ' ' && c != '\t')) break;
    }
    

    Whether it is acceptable or not depends on your style guide (some prohibit using break in for loops).

    Are there style guides that forbid break but allow goto?

    And would that same style guide forbid early returns?


  • Considered Harmful

    @Vixen said in WTF Bites:

    @levicki said in WTF Bites:

    I am the first to complain when there is bad UI

    yeah...... you defending Steam by saying that this is good user experience really tells me you complain when there is bad UI....

    Explotiative and manipulative UI, which includes an admitted error, is not bad, but in fact to be praised?

    Yeah. I'm not with you there, but you are clearly far too off your rocker to be worth continued interactions. Good day sir, madam and/or other pronoun of your preference. Please do not allow the door to hit you on the posterior on your way out.

    A no thanks option that actually represents a no thanks? Where's the issue?


  • Considered Harmful

    @topspin said in WTF Bites:

    @levicki said in WTF Bites:

    C++ standard library WTFs:

    1. Even after all C++(03|11|14|17|20)... revisions std::string and std::wstring still don't have ltrim(), rtrim(), trim(). One would think that C++ standard committee geniuses would think of adding something that trivial to the standard library when even QBasic 1.1 had those 28 years ago.

    I think this goes back some 15-20 years to the generally accepted idea (see Meyers, Sutter) that std::string has “way too many member functions” already. Which is easily explained with standard design advice like the Single Responsibility Principle that classes should have, well, the name says it all, and thus in C++ you should “prefer non-member non-friend” functions if possible.
    And yet it ignores that in every other language (or even framework), including better designed ones, strings do have all these member functions like trim, because they’re basic and useful. It also ignores that putting the functionality in a non-member doesn’t actually reduce any complexity and the resulting call syntax sucks, e.g. for chaining. But somehow this irrational hatred of the number of member functions in std::string has prevented adding any further, and for some unfathomable reason also prevented at least adding something like std::trim as a non-member like the advise says.

    I’m pretty sure that my codebase somewhere has the following

    // Providing a trim function in the standard lib would be too much to ask.
    std::string trim(const std::string& s) {
    

    Observe, from a language whose standard library is so minimal it doesn't even have random numbers:


  • BINNED

    @pie_flavor as I said in

    every other language, including better designed ones

    (for values of “every” strictly limited to “sane enough to even have strings”)


  • Banned

    @pie_flavor said in WTF Bites:

    a language whose standard library is so minimal it doesn't even have random numbers

    That's dumb. When did this happen? I'm sure it used to have them.


  • Banned

    @levicki said in WTF Bites:

    @Gąska said in WTF Bites:

    That's dumb. When did this happen? I'm sure it used to have them.

    Frankly, I'd prefer using OS provided (secure) RNG source

    I didn't say the implementation of standard library shouldn't use OS-provided functionality. But it still should have it exposed in its API regardless of what's the backing implementation.

    and same goes for Unicode conversion.

    Huh? OS-provided Unicode conversions? Is there even such a thing?

    What language libraries should do is provide thin wrappers around those to present us with identical API on all platforms.

    Well, depends. For non-crypto PRNG for example, it's somewhat useful in some scenarios to control the seed of your random function, and have the ability to reproduce the entire sequence exactly. I'm pretty sure neither Windows nor Linux provides that option.


  • BINNED

    @Gąska said in WTF Bites:

    @pie_flavor said in WTF Bites:

    a language whose standard library is so minimal it doesn't even have random numbers

    That's dumb. When did this happen? I'm sure it used to have them.

    It’s in the rand crate.

    I know that because it’s literally the second chapter of the Rust book and I didn’t get reading farther than that (then my attention span lead me to actually read the implementation of that crate before learning the rest of the basics, then other things got in the way).



  • @hungrier said in WTF Bites:

    Are there style guides that forbid break but allow goto?

    I doubt it. It wouldn't make much sense.
    I was trying to demonstrate that there was a way that didn't need either goto or an additional variable.

    @Tsaukpaetra said in WTF Bites:

    And would that same style guide forbid early returns?

    Probably. For example, MISRA C forbids goto, break in loops, and early returns.


  • Notification Spam Recipient

    @Gąska said in WTF Bites:

    OS-provided Unicode conversions? Is there even such a thing?

    He wishes!



  • @levicki said in WTF Bites:

    @Zerosquare I think your code doesn't do the same as @aitap's. You are advancing the pointer before you figure out whether the character you fetched was a whitespace and when you break out of the loop your src may be past a non-whitespace character. Here is how I'd do it:

    while (true) {
    	char c = src[0];
    	if (c == ' ' || c == '\t') {
    		src += 1;
    	} else if (c == '\\' && src[1] == '\n') {
    		src += 2;
    	} else {
    		break;
    	}
    }
    

    You're right, I didn't notice this. Good catch.


  • Notification Spam Recipient

    Status: Google Forms (can) store submissions into a Google Sheets document. Great!

    Google Sheets can do formulas referencing the destination sheet. Awesome!

    Google Forms adds data to the destination sheet by inserting rows (as opposed to appending. I.e. an Insert -> New Row is performed before adding the data). FUCK!

    Here I was about to go ballistic on the other editors of the sheet who were apparently messing with formulas when it was Google who dun fucked up.

    *Sigh*



  • @levicki said in WTF Bites:

    1. Even after all C++(03|11|14|17|20)... revisions std::string and std::wstring still don't have ltrim(), rtrim(), trim(). One would think that C++ standard committee geniuses would think of adding something that trivial to the standard library when even QBasic 1.1 had those 28 years ago

    There are standard idioms for it; rtrim is:

    s.resize(std::min(s.size(), s.find_last_of(" \n")));
    

    That's sure good enough for everybody, right?

    You still get the comittee chairman say¹ that most string methods shouldn't be string methods, but generic algorithms. Which I would kinda agree if it wasn't for the need of mutating algorithms like the above.

    Edit: also :hanzo:.

    @levicki said in WTF Bites:

    As of C++17 std::codecvt_utf8, std::codecvt_utf8_utf16, std::codecvt_utf16, std::wstring_convert, and std::wbuffer_convert are deprecated and there seems to be no replacement in sight. Stack Overflow "advice" on the subject of portable UTF-8 conversion seems to be "roll your own" which is a terrible, terrible idea.

    I wrote those several times, because the projects predated or couldn't use C++11 anyway. Or because the codecvt wasn't useful, because I usually need conversion between the legacy 8-bit encoding and utf-8, not to/from the ill-defined wchar_t.


    ¹ Apparently he's updating the post to C++14… still?



  • @Gąska said in WTF Bites:

    Huh? OS-provided Unicode conversions? Is there even such a thing?

    Win32 has at least MultiByteToWideChar and WideCharToMultiByte.

    @Bulb said in WTF Bites:

    There are standard idioms for it; rtrim is:
    s.resize(std::min(s.size(), s.find_last_of(" \n")));

    That's sure good enough for everybody, right?

    It's a bit more humane with std::string_view, where there is remove_prefix and remove_suffix. String handling in C++ is still awkward, though (and string_view introduces as many problems as it solves).



  • @topspin said in WTF Bites:

    I’m pretty sure that my codebase somewhere has the following

    Mine does. For both std::string and wstd::string. It also has several variants (total of 12). Of course, all implemented via a template so I only had to write the real function once!


  • Considered Harmful

    6e86af3b-76e8-4756-a578-57e022116bf5-image.png

    Error: Success?


  • Considered Harmful

    OK, now it's saying stdin is not a tty when I try to commit. :wtf: is happening?


  • Java Dev

    @error Someone injected a keylogger between you and your terminal?


  • Considered Harmful

    @PleegWat Traced the error back to husky running git hooks.



  • @error said in WTF Bites:

    6e86af3b-76e8-4756-a578-57e022116bf5-image.png

    Error: Success?

    Looks like something in your powershell is trying to process git output and does not actually understand it.

    @error said in WTF Bites:

    OK, now it's saying stdin is not a tty when I try to commit. :wtf: is happening?

    The same thing is probably trying to… um, don't know what. stdin is not a tty error would make sense from trying to spawn an editor to edit the commit message, but I can't imagine what makes sense to attach to the input of git command.

    @error said in WTF Bites:

    @PleegWat Traced the error back to husky running git hooks.

    :wtf:⁉

    Is the checkout hook printing that error? It might be, actually. And the commit one complaining about the tty—but it still should be a tty?


  • Java Dev

    @error said in WTF Bites:

    npm

    well-theres-your-problem.rm


  • Considered Harmful

    @Bulb said in WTF Bites:

    Is the checkout hook printing that error? It might be, actually. And the commit one complaining about the tty—but it still should be a tty?

    Basically there was a hook.cmd for Windows users, and a hook (extensionless) for Bash, and the bash script invoked the Windows script with winpty. The git hook is calling into the Bash version regardless of host shell. So I "fixed" it by sniffing for a tty and only calling winpty if it needed it.


  • Banned

    @levicki said in WTF Bites:

    Well, depends. For non-crypto PRNG for example, it's somewhat useful in some scenarios to control the seed of your random function, and have the ability to reproduce the entire sequence exactly. I'm pretty sure neither Windows nor Linux provides that option.

    Well for that you have rand() in the C runtime library or std::random in C++ standard library.

    Yes, you do. I was just saying it's a good idea to have these in the standard library.

    @Bulb said in WTF Bites:

    That's sure good enough for everybody, right?

    I didn't measure performance so I am inclined to say "Maybe", but even if the answer is "Yes" that code is terribly ugly and unreadable, just like most code dealing with std namespaces.

    :whoosh:


  • BINNED

    Bildschirmfoto 2019-10-07 um 23.56.01.png

    "A new version of Google News is available      UPDATE"

    :wtf_owl:

    I've opened this page literally 5 minutes ago. Did the exponential release version thing reach the point where you fucking update your website (not just the content) every three seconds now, so I have to "update" while I read it?! :wtf: :wtf: :wtf:


  • Banned

    @topspin you were just unlucky to hit the go-live window. Not that unusual at midnight CET.



  • @topspin said in WTF Bites:

    Bildschirmfoto 2019-10-07 um 23.56.01.png

    "A new version of Google News is available      UPDATE"

    :wtf_owl:

    I've opened this page literally 5 minutes ago. Did the exponential release version thing reach the point where you fucking update your website (not just the content) every three seconds now, so I have to "update" while I read it?! :wtf: :wtf: :wtf:

    I get the equivalent popup for this site quite a bit. 🤷🏻♂


  • Considered Harmful

    @Gąska said in WTF Bites:

    @pie_flavor said in WTF Bites:

    a language whose standard library is so minimal it doesn't even have random numbers

    That's dumb. When did this happen? I'm sure it used to have them.

    Nope! No randoms in the stdlib at all. You have to use the rand crate.



  • @error said in WTF Bites:

    regardless of host shell

    Regardless of host terminal, actually—the difference is whether running from conhost, the rxvt-or-what-crap-they-ship or some other application, and git bash can be run from either (I've always ran it from ConEmu via conhost).

    Anyway, it's the correct fix.



  • @pie_flavor said in WTF Bites:

    @Gąska said in WTF Bites:

    @pie_flavor said in WTF Bites:

    a language whose standard library is so minimal it doesn't even have random numbers

    That's dumb. When did this happen? I'm sure it used to have them.

    Nope! No randoms in the stdlib at all. You have to use the rand crate.

    The default hasher is randomized however, showing that there are, just not exposed in the public API. And indeed, there is a function sys::hashmap_random_keys defined for various platforms (on Un*x it tries getrandom and /dev/urandom, on Windows it uses RtlGenRandom on winapi and BCryptGenRandom on uwp, on VxWorks it uses randSecure from libc, on CloudABI it uses arc4random_buf, on Wasm is uses a Dilbert generator—which is incidentally probably the reason it is not exposed: it does not work everywhere.


  • Banned

    @pie_flavor said in WTF Bites:

    @Gąska said in WTF Bites:

    @pie_flavor said in WTF Bites:

    a language whose standard library is so minimal it doesn't even have random numbers

    That's dumb. When did this happen? I'm sure it used to have them.

    Nope! No randoms in the stdlib at all. You have to use the rand crate.

    I just remembered. They moved it away right before 1.0. It was in stdlib in alpha and before.

    Still dumb.


  • Java Dev

    Word is the best website editor. The W3 validator agrees.

    good-webdesign.png


  • Considered Harmful

    I thought if (!(foo is null)) was getting ugly. So I started writing if (foo is Foo nonnull). Rider told me that was stupid, and recommended I change to if (foo is { } nonnull). Which is not only apparently valid C# syntax, but also does exactly what I'm asking. Wat.


Log in to reply