• ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to foo AKA fooo
    foo AKA fooo:
    ¯\(°_o)/¯ I DUNNO LOL:
    After being being subjected to horribly ugly "example code" related to bringing up a new chip (I do embedded systems programming), I've started to use the term "weeds" to refer to all the garbage that makes code hard to read, including things like "} /* FunctionName */" at the end of functions and short if blocks. If your code wasn't so full of weeds to begin with, you wouldn't need to add those other weeds to make it more "readable"!
    But ... but ... but!

    You know, there may be a 1000 line function somewhere in our codebase, and if we don't, you know, put an ending comment at its end, the programmer needs to, well, SCOLL UP to see the function name (unless the IDE has better support, but anyway).

    BECAUSE WE NEED TO HAVE THOSE 1000 LINE FUNCTIONS! (yes, your sarcasm was detected, but just look at the code in question today)

    /* end of file / Yes, they had / end of file */ at the end of every file. But no #ifndef FOO_H sentinels on the .h files. Goooooo, consistency!

  • (cs) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    (I do embedded systems programming)
    With or without file systems?
  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)

    Also, what is this obsession with making sure your code will compile under any barely-ANSI C compiler that it might possibly ever encounter? Especially the /* comments */ all over the place.

    Protip: C89 was twenty-four years ago. And C99 was fourteen years ago. (Even if Microsoft doesn't want to admit it exists.) If you're still using a compiler that doesn't handle // comments, even for the obscurest of microcontroller architectures, please kill yourself now. And start declaring your variables at first use (especially for loop indexes) instead of up at the top of functions.

    In all fairness, the code I've been subjected to was last touched in 2005 (even though they're selling us the chip now), and had 8051-isms throughout it, including ensuring that all loop index variables were declared uint_8, and hacks to third-party code to deal with bank-switched memory. But then they had a big-ass god struct declared where a third of the contents weren't even referenced.

    The worst was registers that take 6+4 bits to specify. So they keep track of two separate numbers (with the requisite 15-character names) and use them together in function calls. I think part of the problem was their fear of passing around eeeevil 16-bit values on an 8051. My code merges them into 16-bit constants using a simple macro, and lets the lowest level register access code deal with which bits mean what. And I also use the shorter register names that match what the chip datasheet uses. So 30+ characters become 10.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Pawprint
    Pawprint:
    ¯\(°_o)/¯ I DUNNO LOL:
    (I do embedded systems programming)
    With or without file systems?
    We use a third-party library that supports FAT32 SD cards and a flash-friendly filesystem for a SPI NOR flash. But that's basically just used for config and log files. I wouldn't have chosen it myself, but we were already using it when I was hired. Our hardware uses a Cortex M3, so no Linux, if that's what you were wondering.
  • (cs)

    And now before you all start blocking your javascript and tracking pixels in fear of the spies, there are ways of tracking your web usage that you can't even detect.

  • QJo (unregistered) in reply to Algorythmics
    Algorythmics:
    nonpartisan:
    You should've seen the original code. It took 60 seconds to analyze a page. That was unacceptable, so Adam tried Google Analytics and it completed the task in only a few milliseconds. Nigel insisted that he could rewrite the code and not be beholden to Google. Now it only takes 20 seconds to analyze a page.

    rightly or wrongly, thats just how it was back then. Meanwhile, the president's daughter...

    No quack.

  • Worf (unregistered) in reply to Adam
    Adam:
    Actually, given that Google knows lots about me, sites using Google Analytics and telling Google which page I visit and when is probably just as much of a privacy problem. Given the three-letter agencies are known to be slurping up data from Google (and similar very large companies), this is definitely an issue.

    I suspect what makes it OK is that Everybody Is Doing It; am I right?

    Don't forget Google owns many ad companies as well, like DoubleClick and the like. They have something like 98% marketshare in the online advertising business (between Google and Google-owned ad companies).

    Between Google Analytics and Google's ad networks, that's practically the entire web...

  • Gunslinger (unregistered) in reply to Honnza
    Honnza:
    Nick:
    I'm going to start using GUIDs, generated each page load, to name my form elements.

    Thanks for breaking autocomplete, myfriend

    No one needs autocomplete anyways.

  • Gunslinger (unregistered) in reply to Adam
    Adam:
    Actually, given that Google knows lots about me, sites using Google Analytics and telling Google which page I visit and when is probably just as much of a privacy problem. Given the three-letter agencies are known to be slurping up data from Google (and similar very large companies), this is definitely an issue.

    I suspect what makes it OK is that Everybody Is Doing It; am I right?

    This is why google-analytics is never getting unblocked from my NoScript.

  • Friedrice The Great (unregistered) in reply to no laughing matter
    no laughing matter:
    Steve The Cynic:
    There's an XKCD on the topic of cobbled-together solutions, something about video files, which fits nicely in with the article you pointed us at.
    Well, probably not the one you remembered, but this xkcd seems somehow related!
    I like this one from today better, but it's about commit comments and not at all related to this privacy monstrosity other than some defenseless code repository somewhere is forced to store not only the production version of the privacy and code monstrosity but probably many other versions besides.
  • Friedrice The Great (unregistered) in reply to Lord Lordship.
    Lord Lordship.:
    faoileag:
    Rick:
    I found it amusing that while they check for a single field named 'Organization' and 'organization', 'Organisation' isn't in there.
    Might be because the code has been developed in the USA and not every coder makes a distinction between American English and Other English, as Wiktionary (http://en.wiktionary.org/wiki/organisation) does.
    The real WTF is American English. One would think, with the amount of cash the Federal Reserve are printing right now, you 'merkins could afford to import some spare "U"s and exchange a few "Z"s for "S"s.
    Sorry, that would require that we have an education system ...
  • Biggles (unregistered) in reply to Honnza
    Honnza:
    JimM:
    JimM:
    OK, I call shenanigans on this one - that's got to be written specifically to get onto TDWTF. There's some remarkable stuff in there...
    if ( 0==1 && browsertype!= -1 )

    for a starter... Oo

    OMFG, just realised - this is a pattern! A few lines earlier there's an "if ( 1==1 && ....) too! So presumably they're checking that the basic foundation of maths hasn't changed before committing their scraped data back to the homeworld?!?!

    Argh, I have to stop reading that code ... it get worse every line... shudder

    most likely it's meant as an easy way to disable/enable conditions with a change of a single character. Because

    true vs false
    is too big a change, and
    /** vs /**/
    is not auto-scoped (it also messes up else if chains)
    you can turn it on and off easier....

    let 0 = 1 #define 0 1 whatever you gotta do for this shit

  • Nick (unregistered) in reply to Honnza
    Honnza:
    Nick:
    I'm going to start using GUIDs, generated each page load, to name my form elements.

    Thanks for breaking autocomplete, myfriend

    Sorry, the behavior will be by design.

  • Biggles (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    Also, what is this obsession with making sure your code will compile under any barely-ANSI C compiler that it might possibly ever encounter? Especially the /* comments */ all over the place.

    Protip: C89 was twenty-four years ago. And C99 was fourteen years ago. (Even if Microsoft doesn't want to admit it exists.) If you're still using a compiler that doesn't handle // comments, even for the obscurest of microcontroller architectures, please kill yourself now. And start declaring your variables at first use (especially for loop indexes) instead of up at the top of functions.

    In all fairness, the code I've been subjected to was last touched in 2005 (even though they're selling us the chip now), and had 8051-isms throughout it, including ensuring that all loop index variables were declared uint_8, and hacks to third-party code to deal with bank-switched memory. But then they had a big-ass god struct declared where a third of the contents weren't even referenced.

    The worst was registers that take 6+4 bits to specify. So they keep track of two separate numbers (with the requisite 15-character names) and use them together in function calls. I think part of the problem was their fear of passing around eeeevil 16-bit values on an 8051. My code merges them into 16-bit constants using a simple macro, and lets the lowest level register access code deal with which bits mean what. And I also use the shorter register names that match what the chip datasheet uses. So 30+ characters become 10.

    Now you're just being picky.

    an evil comment is an evil comment, whether it's /* surrounded */ or //preceded

  • D (unregistered)

    Someone please write a Firefox plug-in to block this evil thing!

  • (cs) in reply to Ruddiger
    Ruddiger:
    This reminds me of this article I came across the other day...

    http://dotnet.dzone.com/articles/automatically-collect-and

    I had to check the date on it wasn't 1st April

    Wow, that is some amazing stuff there. Reminds me of looking at SpectateSwamp's code.

    I particularly liked the file transfer method of issuing an HTTP GET request, then looping through the response one character at a time and writing it out to a file.

    That's clearly a pattern this person enjoys using, since their preferred method of merging files is to open each one, loop through the lines in it and append each line to a new file. (Also, we use a temporary file for this which we immediately rename to the name we want. Not sure what the temp file buys us here.)

    Still, not a bad effort for someone who has obviously no notion that webserver logs exist but thinks they ought to, and also doesn't know much about programming or basic OS functionality, and apparently has no technically-minded friends. It's way better than SwampyCode.

  • QJo (unregistered) in reply to Ruddiger
    Ruddiger:
    This reminds me of this article I came across the other day...

    http://dotnet.dzone.com/articles/automatically-collect-and

    I had to check the date on it wasn't 1st April

    Schubert Nosock?

  • (cs) in reply to anonymous
    anonymous:
    Mostly because there doesn't EXIST a real "sleep" function... blocking until it returns, but not GUI-locking thread-blocking spin-waiting. setTimeout completely trashes your scope, so it forces you to either use a bunch of static/global variables or try to pass them all to the setTimeout callback.

    But Javascript has closures, so you can pass an anonymous function that inherits everything from the existing scope as the setTimeout() callback; or if you need to simulate the effect of calling sleep() in a loop, you can pass a function that tail-calls setTimeout() with itself as a callback. It's a little clumsy but not a terribly huge pain.

  • Bernie The Bernie (unregistered)

    What's so special with companyName that you need to check it twice?

    || (llelementcompany=='companyName')
    || (llelementcompany=='companyName') 

    Captcha: erat - it ought to be errat.

  • faoileag (unregistered) in reply to PleegWat
    PleegWat:
    And now before you all start blocking your javascript and tracking pixels in fear of the spies, there are ways of tracking your web usage that you can't even detect.
    Yup,like Cookieless Cookies. So better start blocking images as well (who needs images anyway?).
  • faoileag (unregistered) in reply to anonymous
    anonymous:
    but I'm forced to use recursion to avoid freezing the GUI ... When you have a lot of data to process or a complex problem to solve, and you can either use a recursive or sequential algorithm to do so, the sequential algorithm is often easier to write and it'd be DAMN NICE if you could just stick a sleep() in there so it wouldn't freeze the entire browser while it chugs away at your function.
    *face palm* sorry, but if that's the reason you need sleep/setTimeout for, then you are doing it wrong.

    Computations that are so complex that they are effectively freezing your browser should not take place there.

    Even if you are just coding for an intranet application you have no control whatsoever over the frontend client. The browsers behaviour can change without prior notice between two releases, and what worked in Version X does not necessarily need to work in Version X+1.

    If you are developing for the great wide Internet, you are in even more trouble. Can you test your application on all possible devices? From high-end pc to low-end smartphone? With all possible versions of os for those devices? And all possible browsers? Probably not.

    anonymous:
    Sure, you could also figure out how to write the whole thing as a web worker, but that's as much work as just making a bunch of variables global or passing them as arguments and then making it recursive.
    If that's the way you make decisions about the architecture of the software products you design/implement I hope I will never come across one of your solutions.

    I have nothing against rants about shortcomings of programming languages, but if the rant boils down to "I'm doing it wrong and the language doesn't support me properly in doing it wrong" then go away.

  • foo AKA fooo (unregistered) in reply to Gunslinger
    Gunslinger:
    Honnza:
    Nick:
    I'm going to start using GUIDs, generated each page load, to name my form elements.

    Thanks for breaking autocomplete, myfriend

    No one needs autocomplete anyways.

    How else are we supposed to enter the CAPTCHAs on this forum?

  • dr memals (unregistered) in reply to Kappa

    thats going to burn mobile phone batteries, perhaps literally

  • Where is today's article eh? (unregistered)

    Did Hanzo get assassinated, thus saving us all?

  • Worf (unregistered) in reply to Gunslinger
    Gunslinger:
    Adam:
    Actually, given that Google knows lots about me, sites using Google Analytics and telling Google which page I visit and when is probably just as much of a privacy problem. Given the three-letter agencies are known to be slurping up data from Google (and similar very large companies), this is definitely an issue.

    I suspect what makes it OK is that Everybody Is Doing It; am I right?

    This is why google-analytics is never getting unblocked from my NoScript.

    Don't forget Google Analytics has a pile of tricks that a webmaster can do so that all links go through them as well. NoScript actually implements workarounds so websites don't break if you block GA. Nasty nasty.

  • Norman Diamond (unregistered) in reply to Bernie The Bernie
    Bernie The Bernie:
    What's so special with companyName that you need to check it twice?
    || (llelementcompany=='companyName')
    || (llelementcompany=='companyName') 
    It's a sanity clause. It NEEDS to be checked twice.
  • yuri (unregistered)

    Don't tell me they've taken the advice oif the commentors and decided not to post because they haven't got anything worthy.....

    oh wait, it's probably Thanksgiving or something....

  • Rudolph (unregistered) in reply to Norman Diamond
    Norman Diamond:
    Bernie The Bernie:
    What's so special with companyName that you need to check it twice?
    || (llelementcompany=='companyName')
    || (llelementcompany=='companyName') 
    It's a sanity clause. It NEEDS to be checked twice.
    Sanity Clause doesn't come for another month yet....
  • (cs) in reply to QJo
    QJo:
    Algorythmics:
    nonpartisan:
    You should've seen the original code. It took 60 seconds to analyze a page. That was unacceptable, so Adam tried Google Analytics and it completed the task in only a few milliseconds. Nigel insisted that he could rewrite the code and not be beholden to Google. Now it only takes 20 seconds to analyze a page.

    rightly or wrongly, thats just how it was back then. Meanwhile, the president's daughter...

    No quack.

    Then who was phone?

  • Joe (unregistered)

    I think the easiest way to gather form field IDs and stuff is secretly submitting the user's autocomplete information to the almighty enterprise right out of Chrome whenever a form is filled and sent. As data is sent anyway, users will hardly notice if what they entered is actually submitted twice. Scripts like this explain why loading certain web pages takes forever even though there isn't much content. This is not what the web was supposed to be or become. They could have used an array at least instead of chaining up thousands of Boolean operations. Hilarious.

  • OneDayWhen (unregistered)

    TRWTF is it is written in disjunctive normal form, easily corrected by rewriting in conjunctive normal form.

  • Rogue_Leader (unregistered) in reply to Nick
    Nick:
    I'm going to start using GUIDs, generated each page load, to name my form elements.

    Yeah. Testability is overrated.

  • Anomaly (unregistered) in reply to faoileag
    faoileag:
    anonymous:
    but I'm forced to use recursion to avoid freezing the GUI ... When you have a lot of data to process or a complex problem to solve, and you can either use a recursive or sequential algorithm to do so, the sequential algorithm is often easier to write and it'd be DAMN NICE if you could just stick a sleep() in there so it wouldn't freeze the entire browser while it chugs away at your function.
    *face palm* sorry, but if that's the reason you need sleep/setTimeout for, then you are doing it wrong.

    Computations that are so complex that they are effectively freezing your browser should not take place there.

    Even if you are just coding for an intranet application you have no control whatsoever over the frontend client. The browsers behaviour can change without prior notice between two releases, and what worked in Version X does not necessarily need to work in Version X+1.

    If you are developing for the great wide Internet, you are in even more trouble. Can you test your application on all possible devices? From high-end pc to low-end smartphone? With all possible versions of os for those devices? And all possible browsers? Probably not.

    anonymous:
    Sure, you could also figure out how to write the whole thing as a web worker, but that's as much work as just making a bunch of variables global or passing them as arguments and then making it recursive.
    If that's the way you make decisions about the architecture of the software products you design/implement I hope I will never come across one of your solutions.

    I have nothing against rants about shortcomings of programming languages, but if the rant boils down to "I'm doing it wrong and the language doesn't support me properly in doing it wrong" then go away.

    Love that you pointed out that he was wrong but gave no information as to why it was wrong. Just that he should go away. The least you could have done is also provide solutions that you deem right. Then someone else can come along tell you you're wrong and the cycle of comments can continue.

  • TooTea (unregistered)
    Just copy/paste some JavaScript that Google tells you to add into the page you want to monitor, and you're good to go.

    This made me laugh out loud. Thanks to Remy training me to look at the source every time not to miss half of the WTF, I very well remembered this comment in TDWTF's own site:

    *snipped* a bunch of JavaScript that Google told us to put in.
    We don't need no stinking JavaScript.
  • Sticky (unregistered)

    This looks and sounds like LeadLander.

  • Paul Neumann (unregistered) in reply to Norman Diamond
    Norman Diamond:
    Bernie The Bernie:
    What's so special with companyName that you need to check it twice?
    || (llelementcompany=='companyName')
    || (llelementcompany=='companyName') 
    It's a santy clause. It NEEDS to be checked twice.
    ftfy He's making a list... Checking it twice...
  • anonymous (unregistered) in reply to flabdablet
    flabdablet:
    anonymous:
    Mostly because there doesn't EXIST a real "sleep" function... blocking until it returns, but not GUI-locking thread-blocking spin-waiting. setTimeout completely trashes your scope, so it forces you to either use a bunch of static/global variables or try to pass them all to the setTimeout callback.

    But Javascript has closures, so you can pass an anonymous function that inherits everything from the existing scope as the setTimeout() callback; or if you need to simulate the effect of calling sleep() in a loop, you can pass a function that tail-calls setTimeout() with itself as a callback. It's a little clumsy but not a terribly huge pain.

    I never said it wasn't possible, just that it's a huge pain in the arse. And scope still gets trashed if you pass a function that tail-calls setTimeout with itself as the callback. This:
    function foo() {
        if (typeof bar != "undefined") {
            alert(bar);
        } else {
            alert("bar is undefined");
    
        var bar = true;
        setTimeout(foo, 0);
    }
    

    } setTimeout(foo, 0);

    just results in an infinite loop of "bar is undefined" alerts. You have to make bar a global variable for it to work.

    Or is that not what you meant when you said "pass a function that tail-calls setTimeout() with itself as a callback"?

    faoileag:
    Computations that are so complex that they are effectively freezing your browser should not take place there.
    You've no right to tell me what I should or shouldn't do in the privacy of my own browser. Next you'll be telling me that the browser isn't an operating system and Google shouldn't be selling Chromebooks. Great, I'll call the wahmbulance right away.

  • (cs)

    Yes, it should inherit everything in the method, even if it's declared after the the method reference.

  • (cs) in reply to chubertdev
    chubertdev:
    Yes, it should inherit everything in the method, even if it's declared after the the method reference.

    FTFM

  • Norman Diamond's cat (unregistered) in reply to anonymous
    anonymous:
    flabdablet:
    or if you need to simulate the effect of calling sleep() in a loop, you can pass a function that tail-calls setTimeout() with itself as a callback. It's a little clumsy but not a terribly huge pain.
    I never said it wasn't possible, just that it's a huge pain in the arse.
    I agree with anonymous. Tail-callbacks are a huge pain in the arse.
  • Neil (unregistered) in reply to anonymous
    anonymous:
    faoileag:
    anonymous:
    Trying to make anything work properly asynchronously in Javascript is a huge pain in the ass. Mostly because there doesn't EXIST a real "sleep" function... blocking until it returns, but not GUI-locking thread-blocking spin-waiting. setTimeout completely trashes your scope, so it forces you to either use a bunch of static/global variables or try to pass them all to the setTimeout callback.
    setTimeout is real asyncronicity and if you need a sleep in an asynchroneous function you are doing it wrong.

    var foo = 'hello world!'; setTimeout(function() { alert(foo); }, 1000);

    Does what is expected, shows an alert with "hello world!" in it after one second. foo is locally scoped, so what's your problem?

    Actually, asynchroneous programming with Javascript is really simple as plenty of AJAX-driven webpages prove.

    Awesome, that works because foo is global and the anonymous function is in the same scope. This doesn't work:

    function test() { var foo = "hello world"; setTimeout(callback, 1000); }

    function callback() { alert(foo); }

    test();

    Oh, you wanted recursion? Yeah, you're stuck with a bunch of globals, or passing everything you need from an anonymous function. Exactly like I said before.

    Try this version:

    function test() { var foo = "hello world"; setTimeout(callback, 1000, foo); }

    function callback(foo) { alert(foo); }

    test();

  • anonymous (unregistered) in reply to Neil
    Neil:
    anonymous:
    faoileag:
    anonymous:
    Trying to make anything work properly asynchronously in Javascript is a huge pain in the ass. Mostly because there doesn't EXIST a real "sleep" function... blocking until it returns, but not GUI-locking thread-blocking spin-waiting. setTimeout completely trashes your scope, so it forces you to either use a bunch of static/global variables or try to pass them all to the setTimeout callback.
    setTimeout is real asyncronicity and if you need a sleep in an asynchroneous function you are doing it wrong.

    var foo = 'hello world!'; setTimeout(function() { alert(foo); }, 1000);

    Does what is expected, shows an alert with "hello world!" in it after one second. foo is locally scoped, so what's your problem?

    Actually, asynchroneous programming with Javascript is really simple as plenty of AJAX-driven webpages prove.

    Awesome, that works because foo is global and the anonymous function is in the same scope. This doesn't work:

    function test() { var foo = "hello world"; setTimeout(callback, 1000); }

    function callback() { alert(foo); }

    test();

    Oh, you wanted recursion? Yeah, you're stuck with a bunch of globals, or passing everything you need from an anonymous function. Exactly like I said before.

    Try this version:

    function test() { var foo = "hello world"; setTimeout(callback, 1000, foo); }

    function callback(foo) { alert(foo); }

    test();

    Okay, that's just another method of passing foo as an argument.

  • Google Analytics? (unregistered)

    Does this code comes from Google Analytics? I don't see it connected to GA, but the article text seems to indicate that...

  • anonymous (unregistered)

    The really worrying thing is that the script has not changed, and I've just been asked to add it to a website! No way is that going on our website!!

Leave a comment on “A Privacy Monstrosity on Top of a Coding Monstrosity”

Log In or post as a guest

Replying to comment #:

« Return to Article