WTF Bites



  • @remi said in WTF Bites:

    @PleegWat said in WTF Bites:

    Surely some US institution is storing the standard foot (of length) in a vault somewhere?

    Seems like (what was) the standard metre is still in 🇫🇷. It's not needed since 1960, so if 🇺🇸 wants to take it (🏳?) and split it in 3.28084 for their weird system, they're welcome.

    No need, the foot is by definition exactly 0.3048 meter. The weird US units are just derived units of the metric system nowadays.



  • @Rhywden said in WTF Bites:

    @remi said in WTF Bites:

    or maybe a number of atoms, yes (although I'm not sure about the experimental setup that would make this a usable definition?). I'm sure someone will :pendant: me to death with the details.

    Well, there are actually 4 different attempts, three of which didn't pan out (yet) for various reasons. They're currently going for the Avogadro method which, as the name implies, does indeed involve counting atoms. For that you need an X-ray LASER interferometer and a monocrystal, however, which in turn requires Si-28 of the highest purity.

    The problem with atoms and Avogadro's number is the chicken-and-egg issue of Avogadro's number being, IIRC, the number of atoms in 12 grams of pure Carbon-12 (which means, a definition based on the kilogram).


  • Java Dev

    0_1490694277335_search-ms.PNG

    I see.



  • One of my Makefiles has been ... errm ... growing organically, and the most recent addition caused problems with newlines appearing in one if the variables, which Make doesn't treat as whitespace, but rather as any other characters. So in most contexts, a variable equal to "a.cpp <newline> b.cpp" actually is treated as three items, {a.cpp, <newline>, b.cpp}. (:wtf:). Now, despite being on a *nix, I don't have any sources named <newline>, so that ends up ... not working.

    So, how do you replace newlines with spaces in Make? Well, stackoverflow gives the following gem:

    text := hello a b c
    
    null :=
    space := ${null} ${null}
    ${space} := ${space}# ${ } is a space. Neat huh?
    
    define \n
    
    
    endef
    
    $(error [$(subst ${ },${\n},${text})])
    

    Granted, they replace spaces with newlines, but $(subst ${\n},${ },$(variable)) does actually solve the problem. Mind you, ${\n} references a variable named "\n" that is equal to a newline, and ${ } references a variable named that is equal to . :eek:


  • Winner of the 2016 Presidential Election

    @cvi said in WTF Bites:

    Makefiles



  • @asdf Yes. But it's available on most computing infrastructure out there, and it's still less effort to maintain than actually making a bunch of admins in different computing centers install and maintain recent versions of ${other_tool}.

    *sigh*


  • Winner of the 2016 Presidential Election

    @cvi Same reason why people still write shell scripts and will probably still be writing shell scripts when I'm six feet under.



  • @Medinoc said in WTF Bites:

    @Rhywden said in WTF Bites:

    @remi said in WTF Bites:

    or maybe a number of atoms, yes (although I'm not sure about the experimental setup that would make this a usable definition?). I'm sure someone will :pendant: me to death with the details.

    Well, there are actually 4 different attempts, three of which didn't pan out (yet) for various reasons. They're currently going for the Avogadro method which, as the name implies, does indeed involve counting atoms. For that you need an X-ray LASER interferometer and a monocrystal, however, which in turn requires Si-28 of the highest purity.

    The problem with atoms and Avogadro's number is the chicken-and-egg issue of Avogadro's number being, IIRC, the number of atoms in 12 grams of pure Carbon-12 (which means, a definition based on the kilogram).

    That was the original definition. We have moved on since :)


  • I survived the hour long Uno hand

    Amid Chipotle’s effort to win back customers who may have strayed because of that whole food borne illness nightmare, the company has been trying to improve the customer experience. The company’s latest attempt to regain consumer trust involves removing all preservatives from its entire food menu.

    Not only do you not have to worry about food-borne illnesses caused by bacteria, we're also going to remove the things that prevent or delay bacteria growth from our food! What could go wrong?


  • FoxDev

    @Yamikuronue But hey, at least they'll get back the hipsters and health nuts, right?


  • Notification Spam Recipient

    @RaceProUK said in WTF Bites:

    @Yamikuronue But hey, at least they'll get back the hipsters and health nuts, right?

    .... I fail to see this as a problem...



  • @Yamikuronue said in WTF Bites:

    removing all preservatives from its entire food menu

    Does that include salt, aka NaCl, aka Sodium Chloride, the most prolific and most ancient food preservative?



  • @djls45 It's about time they got rid of it, that stuff is dangerous. Half of it is military grade poison, the other half metal that explodes violently when exposed to water. It should be banned, along with the deadly chemical DHMO.



  • @hungrier We should also ban carbon. You know, it causes all sorts of problems, and some models indicate that it could have a catastrophic effect on the planet. It's a component of all sorts of nasty and dangerous things, like explosives, poisons, venom, viruses, ammunition, drugs, and more! There's no reason we should expose ourselves to such a dangerous material.



  • @Yamikuronue I'm fairly certain that "preservatives" aren't generally used to inhibit spoiling. Radiation and/or pasteurization are supposed to do that. Preservatives are additives meant to keep oils from going rancid and generally keep the food's flavor, color, and texture from changing.


  • FoxDev

    @djls45 said in WTF Bites:

    It's a component of all sorts of nasty and dangerous things, like explosives, poisons, venom, viruses, ammunition, drugs, and morepeople!

    FTFS


  • Discourse touched me in a no-no place

    @djls45 said in WTF Bites:

    It's a component of all sorts of nasty and dangerous things, like explosives, poisons, venom, viruses, ammunition, drugs, and more!

    I hear that it's present in 100% of all cancers.


  • BINNED

    @cvi said in WTF Bites:

    @asdf Yes. But it's available on most computing infrastructure out there, and it's still less effort to maintain than actually making a bunch of admins in different computing centers install and maintain recent versions of ${other_tool}.

    *sigh*

    You can also still write all of your code in Assembly! There are tools that create Makefiles from slightly more readable files. CMake is one of them, but if it is a new project start with the best: meson is in Python, it is fast, truely cross platform and a delight to work with!



  • @dse said in WTF Bites:

    You can also still write all of your code in Assembly!

    Why would you use such a complicated and powerful system?

    You can also write all of your code in BIT!



  • @dse CMake's generated files require CMake to be available whenever you build something (at least, this was the case last time I used it). Also, then you have CMake all over you (for small projects without a lot of dependencies, I consider Make's declarations to be more palatable than the hacked-together crap that is CMake's scripting language).

    I prefer premake in that regard, it generates much cleaner output (i.e., the generated files don't depend on premake). Plus, you get to write it in Lua, which, at the very least, is an actual language that somebody designed -- despite its flaws, it's light-years ahead of CMake-script. Plus, it's a single executable.

    Haven't used Meson, but it seems to depend on ninja being available... At that point, I'd probably go for waf (python, packed into a single .py, so you can check it in), or scons (also python, supports more weird compilers, but has a couple of flaws).

    Also, I do sometimes write my code in assembly. Modern compilers generate loads of crap, occasionally.



  • @dse said in WTF Bites:

    CMake is one of them, but if it is a new project start with the best: meson

    My problem when choosing a build tool is that all of them boast how easy it is to build a simple project with them. Well, simple project is simple, my project will not be. So what I would really like to see in a feature description of a build system is how a build description would look for a project that includes following build steps:

    1. python script generates some resources and some C++ headers,
    2. a C++ executable is built and run to generate some more resources and more C++ headers,
    3. a C++ library is built,
    4. headers for the library are exported to the build directory in slightly different layout¹,
    5. the C++ application core is compiled for the host² platform,
    6. it is linked with a C# UI into a Windows Universal application,
    7. it is linked with an Android/Java UI into an Android application,
    8. it is linked with an Objective C UI into an iOS application,
    9. each version is packaged with the generated resources,
    10. the results of steps 1–3 may be done once and provided to the platform-specific run³

    This actually resembles the previous project I worked on quite closely with some twists from the current one thrown in. And of course, I require that it can not only be done, but that it is also efficient, i.e. that it won't do unnecessary work⁴.


    ¹ Build system of the application I am working on now does that for histerical raisins. Yes, it is a :wtf: and huge complication, but most projects in the wild do contain some legacy stuff, so I expect the build system to be able deal with it.
    ² The three platforms involved in a build are ‘build’, which is where the build system is executed, ‘host’, where the produced binary will run and ‘target’, which is what the produced binary will produce output for and which is mostly only relevant for compilers.
    ³ This actually quite closely resembles my previous project. We had a custom resource format, the tool to generate it ran only on Windows, but you can only build for iOS on MacOS, so the build server first ran the resource generation part and then copied the output to the next step that ran on a separate MacOS build slave.
    ⁴ We used a hack based on rule for precompiled headers in our Android build, which had the problem that when any header changed, all headers for the component were considered changed for the next component build. Colleague lately rewrote it to another hack that runs during the makefile rebuild phase, which is better, but still a hack.



  • @cvi said in WTF Bites:

    Also, then you have CMake all over you

    The point of CMake is that it can generate projects for essentially all IDEs out there (it generates projects for Visual Studio and XCode and some others and the rest has learned to use CMake) and mess the definitions are are in large extend due to the limitations of those IDEs. In an environment where most developers are used to Visual Studio, that is a requirement. But if all you need is Unixy systems and a simpler IDE that works fine with makefiles, CMake is not for you.

    @cvi said in WTF Bites:

    I prefer premake in that regard, it generates much cleaner output (i.e., the generated files don't depend on premake).

    Looks interesting. And it can even generate Android.mk and CMake for old and new style of building Android apps…

    @cvi said in WTF Bites:

    At that point, I'd probably go for waf (python, packed into a single .py, so you can check it in), or scons (also python, supports more weird compilers, but has a couple of flaws).

    Got burnt (long ago, but I doubt they completely changed the model) by the Visual Studio “support” in scons: it could generate VS project, but it used a custom build to call itself for the actual build, which kinda sorta worked for the native target, but totally did not for the WinCE cross-compile.



  • @Bulb said in WTF Bites:

    The point of CMake is that it can generate projects for essentially all IDEs [...]

    I understand why CMake does some of the things it does, but that doesn't mean I have to be happy about it. Besides, CMake makes even the simplest projects depend on it being present, i.e., in cases where it would be completely feasible to create a native Visual Studio project file or whatever that doesn't call out to CMake (I mean, even autotools manages this on occasion). Though, I guess, my main reason for bitching about it is the scripting language -- there's just no reason for it to be that crap. It's not quite autotools-m4 crap, but that's not for a lack of trying.

    Then there's also the CMake astronauts that have spent months developing CMake solutions that will attempt download missing (and sometimes present) dependencies on the fly. I'm sometimes surprised they don't attempt to compile GCC from scratch while they're at it.

    @Bulb said in WTF Bites:

    Looks interesting. And it can even generate Android.mk and CMake for old and new style of building Android apps…

    I've used it for two smaller projects now, and I like it. One of the main features is its capability of generating VS projects+solutions that I could check in, which makes it easier have a Windows-dev quickly test something. (A rant for another time: Visual Studio users that have used to IDE for multiple years, but couldn't create a new solution+project from scratch to save their lives.)

    Haven't tried it outside of nix and windows, though. Premake doesn't have all of the features of CMake, but at least you get to keep a tiny bit more of your sanity. 🙂

    @Bulb said in WTF Bites:

    Got burnt (long ago, but I doubt they completely changed the model) by the Visual Studio “support” in scons

    Unless things have changed significantly, I wouldn't recommend either scons or waf for the Windows/Visual Studio side of things. Last time I tried (been a while, though), waf's VS support was terribly broken too. (I think I've gotten scons to build stuff from the command line using cl directly, but that was a while ago as well.)



  • @cvi said in WTF Bites:

    Though, I guess, my main reason for bitching about it is the scripting language -- there's just no reason for it to be that crap. It's not quite autotools-m4 crap, but that's not for a lack of trying.

    I agree. They apparently thought a very simple DSL will suffice and when it didn't, hacked in Turing-completeness. The result is quite like every other time somebody started building DSL from scratch instead of embedding it into a suitable general-purpose language (💩). Unfortunately is has piled many features and got endorsed by several IDEs, so it's likely to stay around for long time.

    @cvi said in WTF Bites:

    I've used it for two smaller projects now, and I like it.

    But how complex were the project. The real test for this kind of tools is how it deals with custom build steps (in CMake OK, though a bit weird), cross-compilation (CMake manages, but far from well) and such.

    @cvi said in WTF Bites:

    A rant for another time: Visual Studio users that have used to IDE for multiple years, but couldn't create a new solution+project from scratch to save their lives.

    That might be because it's actually a major pain and a pile of :wtf:. Trivial solution with just Win32 platform and Debug and Release configurations mostly works, but when you want something more (like include .NET projects (that use Any CPU platform), other platforms (like Windows Embedded or Windows Phone) or other configuration (like a separate one for unit tests)), Visual Studio tends to totally break the configuration settings every time you try to add a project or do other significant changes.



  • @Bulb said in WTF Bites:

    But how complex were the project. The real test for this kind of tools is how it deals with custom build steps (in CMake OK, though a bit weird), cross-compilation (CMake manages, but far from well) and such.

    No, these were rather trivial projects in that sense. Pretty much plain C++, minimal set of dependencies. I had been manually maintaining builds for a bunch of different systems previously. Premake was a perfect fit for this - it just automated what I did manually before, and without introducing new dependencies on the user side.

    Based on the experience, though, I'll probably try premake on something more complex when it comes up.

    @Bulb said in WTF Bites:

    That might be because it's actually a major pain and a pile of :wtf:.

    I'm glad I don't have to deal with that then. :-) (I still expect to be able to hand a VS dev a handful of .cpp files with a dependency or two and have him create a project to compile those.)


  • Winner of the 2016 Presidential Election

    @Bulb
    Sounds like that would be doable in Gradle. (Not sure how ugly the C# part would be. That depends on whether there are existing, usable plugins for that.)


  • Discourse touched me in a no-no place

    @Bulb said in WTF Bites:

    it generates projects for Visual Studio and XCode and some others

    XCode

    No thanks. Friends don't let friends use XCode.



  • @asdf said in WTF Bites:

    Sounds like that would be doable in Gradle.

    It is usually doable. Question is how easily.

    @asdf said in WTF Bites:

    That depends on whether there are existing, usable plugins for that.

    For builders (like Gradle, rather than build generators like CMake or premake), the packaging part is usually the biggest problem, because each SDK has the package creation integrated to their preferred build system, so you often end up carefully preparing the native binaries so that you can then call a bit of the native build system to pick them up and create the package.

    @dkf said in WTF Bites:

    No thanks. Friends don't let friends use XCode.

    Unfortunately you can't build iOS applications without it. And some companies insist on providing their product also for iPoop, you know?


  • Java Dev

    I had macOS and Xcode update themselves yesterday. The Xcode download refused to start at first, just looking like it was failing for unknown reasons. Finally a dialog popped up informing me that my Apple ID had been locked and that I needed to unlock it. Then it could download. Why it didn't just show that directly when I tried to initialize the download I don't know. Must be some brave new usability feature in the App Store. And then it took longer time to install than the macOS update took to download and install itself.


  • Winner of the 2016 Presidential Election

    @Bulb said in WTF Bites:

    Sounds like that would be doable in Gradle.

    It is usually doable. Question is how easily.

    In this case, doable = the resulting build script won't be incomprehensible/unmaintainable. That's usually the biggest problem with Makefiles for complex projects.


  • Winner of the 2016 Presidential Election

    @Atazhaia
    I'm so glad I don't have to use XCode anymore.


  • BINNED

    What the fuck is this this shit, O2? This was supposed to be a form to change my payment information. A completely static one. Just a PDF.

    0_1490794029827_wtf-o2.png


  • BINNED

    @cvi said in WTF Bites:

    for small projects without a lot of dependencies, I consider Make's declarations to be more palatable than the hacked-together crap that is CMake

    Yes, but no project remains simple and innocent, they all grow to be monsters

    @Bulb said in WTF Bites:

    My problem when choosing a build tool is that all of them boast how easy it is to build a simple project with them.

    Meson does not claim anything for simple projects, its power is in complicated scenarios, even though you can use it for simple projects too. For simple projects Makefile is better IMO.
    On the other hand if you want to compile a complex project cross-platform/cross-compiling, that may even depend on other more complicated dependencies then nothing is like it. There is a reason GStreamer is gradually moving its build system to use it.

    Also, it can generate projects for VS, XCode, CMake, ... or if you want just the binaries. So it certainly has made CMake obsolete. CMake is specially horrible in cross compiling.


  • BINNED

    @blek That is Adobe trying to fuck up the Web since 1993. They probably have PEST too, to replace REST, and use it to make pdf dynamic :--)



  • @dse said in WTF Bites:

    Meson does not claim anything for simple projects, its power is in complicated scenarios
    […]
    it can generate projects for VS, XCode, CMake, ...

    Sounds promising. And so does the premake. I'll have to take a closer look at them.

    @dse said in WTF Bites:

    CMake is specially horrible in cross compiling.

    It is. Recursive calls to cmake to configure for build compiler or for other target compiler (for Android multi-host packages) is hacky and ugly.



  • @Bulb said in WTF Bites:

    My Visual Studio just crapped itself out.

    This time, it's popping up just a
    0_1490797424594_upload-5be224a7-b574-4dcc-b954-6bed37d6ed27
    when I try to close it. It is also saying
    0_1490797392239_upload-98fc31cd-9441-469b-af19-971a061c6067
    when I try to close one source file. And the file name has disappeared from the tab with that file.

    Strangely, clicking the "Save All" icon (but not pressing Ctrl+S in the file) appears to have fixed it…

    Update: I do suspect it was more likely ReSharper's fault than VS'.



  • string message = rec.success ? "success" : string.Format("{0}", rec.issue);
    

    rec.issue is a string.



  • @dse said in WTF Bites:

    Yes, but no project remains simple and innocent, they all grow to be monsters

    QFT.

    However, you can have a makefile grow right along the main project, and become a monster in its own right.


  • kills Dumbledore

    The latest installment in "Jaloopa finds code that leaves a head shaped dent in his desk"

        Protected Sub cstDateOfBirth_ServerValidate(source As Object, args As ServerValidateEventArgs)
            Dim DateValue As Date
    
            If DateTime.TryParseExact(txtDateOfBirth.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, DateValue) = False Then
                cstDateOfBirth.ErrorMessage = "Please enter an valid Date Of Birth."
                args.IsValid = False
            Else
                If String.IsNullOrEmpty(txtDateOfBirth.Text) Then
                    cstDateOfBirth.ErrorMessage = "Please enter an valid Date Of Birth."
                    args.IsValid = False
                Else
                   #Ticket 1234 - correction to date of birth calculation
                    If Not (String.IsNullOrEmpty(dtcEffectiveDate.Text)) Then
                        Dim DOB As Date = Convert.ToDateTime(txtDateOfBirth.Text)
                        Dim DateOfBirth As Date = New Date(DOB.Year, DOB.Month, DOB.Day)
                        Dim EffectiveDate As Date = Convert.ToDateTime(dtcEffectiveDate.Text)
                        Dim FormattedEffectiveDate As Date = New Date(EffectiveDate.Year, EffectiveDate.Month, EffectiveDate.Day)
                        Dim Age As Integer = FormattedEffectiveDate.Year - DateOfBirth.Year
                        If FormattedEffectiveDate.Month > DateOfBirth.Month OrElse (FormattedEffectiveDate.Month = DateOfBirth.Month AndAlso FormattedEffectiveDate.Day < DateOfBirth.Day) Then
                            Age -= 1
                        End If
                        If Age < 16 Or Age > 69 Then
                            cstDateOfBirth.ErrorMessage = "You must be between 16 and 69 years old"
                            args.IsValid = False
                        Else
                            args.IsValid = True
                        End If
                    End If
                End If
            End If
    
        End Sub
    

    OK, lets go through this.

    • if... = false. An anti pattern I see a lot in the codebase. It means you can't quickly look at a line and see what it's doing, you have to scan to the end to see whether the true part is in the if or the else
    • That TryParse that ensures the correct format ends u p with a date object that is the date you wanted. It's never used again. I suspect this check was added after the rest of the method because they discovered it blew up if you entered `a 2016a or something
    • if not a valid date, check to see if it's an empty string. Because "" is definitely getting through the tryparse. See above about that validation surely being added later
    • Ticket reference in a comment. Not a huge WTF, but it can get things pretty cluttered, especially in frequently changed parts of the code
    • (bonus WTF: NodeBB thinks this is PHP and formats basic as plain text, so I had to stick a PHP comment character in to not make it think the rest of the method was part of a string)
    • Make a date object again. Using whatever locale we're using.
    • Now, to make sure the date is formatted right, lets make a new date out of that date
    • Same with effectivedate. Which is either empty or definitely a date, because although we need to check multiple ways that the date of birth is valid, we can assume that effective date validation will definitely have run. Or not. Because it might still be empty
    • Date.AddYears()? Nah, lets just do a subtraction of one year from another and then do some more convoluted logic to massage it.

  • 🚽 Regular

    Is there any good reason for using

            If ... Then
                ...
            Else
                If ... Then
                    ...
                Else
                    If ... Then
                        ...
                    End If
                End If
            End If
    

    instead of

            If ... Then
                ...
            ElseIf ... Then
                ...
            ElseIf ... Then
                ...
            End If
    

    ?

    I'd use early returns anyway.



  • @Jaloopa You forgot the worst crime of them all, 'an valid'.


  • 🚽 Regular

    @coldandtired said in WTF Bites:

    @Jaloopa You forgot the worst crime of them all, 'an valid'.VB

    </obligatory>


  • kills Dumbledore

    @Zecc said in WTF Bites:

    Is there any good reason for using

            If ... Then
                ...
            Else
                If ... Then
                    ...
                Else
                    If ... Then
                        ...
                    End If
                End If
            End If
    

    instead of

            If ... Then
                ...
            ElseIf ... Then
                ...
            ElseIf ... Then
                ...
            End If
    

    ?

    I'd use early returns anyway.

    Me too. That long chain of end if is a smell if not a full on WTF.

    @coldandtired said in WTF Bites:

    You forgot the worst crime of them all, 'an valid'.

    OMG, I didn't even notice that. Surprised nobody's ever mentioned it



  • 0_1490875123432_upload-3eecbe5c-d02e-469c-85e1-395c5d4827da

    net use h: /delete also says the drive does not exist, but when I click it, it still tries to connect—and promptly suspends my account for ¼ hour, because the domain controller does that on 3 failures and the system tries more times than that before asking anything.


  • I survived the hour long Uno hand

    The Wall Street Journal says Amazon is having trouble tracking more than 20 customers at a time and keeping tabs on merchandise moved from store shelves.



  • 0_1490880156587_upload-e3332d4f-9c21-4f82-b710-68d8bc0ce5a8

    :wtf: does "Apple (Album by Parasense)" have to do with anything in my search term? Apple (computer) might be a reasonable(-ish) thing to put there since it at least shows up in the search results, but that makes no (para)sense.



  • @Zecc
    Maybe the author is used to a language that doesn't support ElseIf (like, oh, T-SQL... 😿)?


  • kills Dumbledore

    This
    0_1490881672164_upload-9f3cd772-2a77-4b07-92c2-d7d7a571e8e4

    is not the usual way to code a table that looks like this
    0_1490881702199_upload-131b1e85-76cf-40bd-865c-f3ac33db727f

    is it?

    Having problems with some third party component called RealDropDown.dll, which seems to assume that you're using it in a form with the id Form1. This hasn't caused problems before but seems to be everywhere now. Trying to see what's happening in the page I was presented with the above nested tables.

    It looks like all of this is coming from the realdropdown, since the aspx is just this
    0_1490881934702_upload-78a759cd-9be1-4c9f-852e-4ef7ec709ee6



  • @Jaloopa said in WTF Bites:

    This
    0_1490881672164_upload-9f3cd772-2a77-4b07-92c2-d7d7a571e8e4

    is not the usual way to code a table that looks like this
    0_1490881702199_upload-131b1e85-76cf-40bd-865c-f3ac33db727f

    is it?

    Judging from the TFS Web client, yes, it is.


  • kills Dumbledore

    The fucking thing works in live but not local or test. There are some extra binaries on live, but copying them over does jack shit. I swear this page used to work


Log in to reply