• Seb* (unregistered)

    What the hell is up with those <font face="Arial"></font>-tags in beginning of the text?

  • James (unregistered) in reply to SomeCoder
    SomeCoder:
    Remember Lisa McPherson:
    If you've got Firefox, use the AdBlock Plus plugin; it saves Alex's bandwidth for ads you don't want to see.

    Off topic but is that how AdBlock works? Does it actually not download the offending material or does it download it but not display it?

    I'm just curious. I use AdBlock and I love it.

    As I understand it, Adblock intercepts the HTML you download from the server, and either inserts CSS to set the display style for unwanted items to "hide", or removes them altogether, before passing the page source on to the rendering engine. Or maybe it changes "IFRAME SRC=ad.php" to "IFRAME SRC=about:blank" or similar. I'm not positive.

    Anyway, as a result the rendering engine has no reason to request the blocked items (be they images, IFRAMEs, or what have you), so they're not downloaded. I used to have a proxy to do the same thing (Proxomitron FTW!) before I switched to FF. Whichever way you do it, the point is to take the reference to the ad out of the HTML source before it gets rendered -- clever and effective. I love my ABP!

  • foxyshadis (unregistered) in reply to Jason
    Jason:
    Can someone explain to me what the WTF is with the network code?

    I'm not sure what this TIMEDWAIT thing is he's talking about and a quick google search didn't reveal it to me in under 27 seconds.

    That's because it's actually TIME WAIT.

    ais523:
    Too bad the "text" column is only a VARCHAR2(5).

    No, that's only what it is at the moment. Presumably, if there was a need to add FILE_NOT_FOUND at a later date, the application would automatically ALTER the TABLE to make it a wider column. After all, why waste space with wide columns, when you can automatically resize them to fit the data?

    No, no, no, you just add a third column, RealText, with a 255 length, just in case there is anything using the original with a too-small buffer and no checks.

  • (cs) in reply to ParkinT
    ParkinT:
    One obvious ommission is: static char monthsvaried[13][5] = { " ", "jAn", "fEb", "mAr", "aPr", "mAy", "jUn", "jUl", "aUg", "sEp", "oCt", "nOv", "dEc"}; static char monthvaried[13][6] = { " ", "jaN", "feB", "maR", "apR", "maY", "juN", "juL", "auG", "seP", "ocT", "noV", "deC"}; static char monthsvaried[13][7] = { " ", "JAn", "FEb", "MAr", "APr", "MAy", "JUn", "JUl", "AUg", "SEp", "OCt", "NOv", "DEc"}; ... snip ...

    [5], [6], [7]? I think your internet browser (or your mind) used fill series rather than copy cells. :)

  • (cs) in reply to Marchuary
    Marchuary:
    But these arrays will give you "Feb" as the abbreviation for March. Or am I missing something?
    Yes.

    Arrays in C and it's derivatives are zero based, so months[1] will actually give you the second entry, which in this case happens to be "Jan". Mapping 1 to "Jan" seems pretty correct to me...

    np: Justus Köhncke - (It's Gonna Be) Alright (Safe And Sound)

  • Rev. Spaminator (unregistered)

    At least this system was written in C and is supported by Oompa Loompas. I work with a system written PL/1 and is supported by a bunch of cavemen.

  • SpamBot (unregistered)

    Wibble Wobble WTF

  • Brian White (unregistered) in reply to James
    James:
    James:
    I have just enough SQL knowledge to be dangerous, which is probably bad since I'm designing a database for a big project now. In SQL Server 2005, there's no "boolean" column type, so I just use an int and interpret the values 0 and 1 as false and true respectively. Would it be "better" to have a tblTrueFalse:

    ID VALUE 0 FALSE 1 TRUE

    then set up a foreign key so that trying to modify a record with a value of 2 would throw an error immediately? I don't plan to do it, but it's one of the only solutions I would be able to come up with give my (admittedly lacking) knowledge of the system.

    Wow, I feel like an idiot -- 10 seconds of Googling turned up the Bit data type. D'oh! Anyway, the idea still applies (of using a foreign-keyed table to make your own enumerated data type), just where there's more than two (but fewer than 10/26/whatever) valid choices. Is that a terrible idea, or what?

    Problem with BIT datatype is that it's nullable, leading to a trinary state of null, 1, 0.

  • Anon Sam (unregistered) in reply to Brian White

    BIT binaryflag NOT NULL ?

  • (cs) in reply to Greg
    Greg:
    What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.

    Yes, if a business is confusing "bowls" with "bowels" then I certainly don't want to eat in the company cafeteria.

  • (cs) in reply to mrprogguy
    mrprogguy:
    Greg:
    What kind of bowls does this company have? Fruit bowls? Soup bowls? Enquiring minds want to know.

    Yes, if a business is confusing "bowls" with "bowels" then I certainly don't want to eat in the company cafeteria.

    Nor play on the company boweling team.

  • (cs) in reply to Ru
    Ru:
    13 months eh? I can see the point of that, seeing as how months of the year are inconveniently indexed from 1 in real world dates.

    Except in C, where struct tm has a member called tm_mon that's 0-11.

  • speaking of security... (unregistered) in reply to ais523

    that would be especially useful in the case of an external "malformed string" attack. then the system will automatically resize the table to however long a mess is injected where it doesn't fit. beautiful workaround. the only issue is having to randomly upsize drives all the time for lord-only-knows what reason.

  • joeybladb (unregistered)

    I wish I could get paid for the time I just wasted trying to figure out what those code snippets are supposed to do.

  • Rodolpho Zatanas (unregistered) in reply to YAYitsAndrew

    The 'minim' is a WTF in itself. By using minims to build up letters in times past, scribes made it impossible for readers to discern "m", "n", "u" etc from each other. (Let alone words like "minimum".)

  • (cs)

    At last! A real WTF that doesn't pussy around with the sort of insane database crap that one expects from insane database freaks!

    Not that you'd be able to deduce this from most of the comments, however.

    The "Oompa Loompa" joke is inspired.

    The TCP/IP state-handling code is, well, not quite genius level. It misses out both the 1% inspiration and the 99% perspiration. I am, however, impressed that it has been cut'n'pasted twenty times or more, without anybody muttering the magic three letter incantation to themselves.

    I can actually solve the massively-distributed bit of this problem for these people. I'd have to kill them after I showed them the solution of course; purely for the benefit of the gene-pool, you understand.

    But I'm not going to tell you how.

  • Greg van Paassen (unregistered) in reply to James
    James:
    James:
    I have just enough SQL knowledge to be dangerous, which is probably bad since I'm designing a database for a big project now. In SQL Server 2005, there's no "boolean" column type, so I just use an int and interpret the values 0 and 1 as false and true respectively. Would it be "better" to have a tblTrueFalse:

    ID VALUE 0 FALSE 1 TRUE

    then set up a foreign key so that trying to modify a record with a value of 2 would throw an error immediately? I don't plan to do it, but it's one of the only solutions I would be able to come up with give my (admittedly lacking) knowledge of the system.

    Wow, I feel like an idiot -- 10 seconds of Googling turned up the Bit data type. D'oh! Anyway, the idea still applies (of using a foreign-keyed table to make your own enumerated data type), just where there's more than two (but fewer than 10/26/whatever) valid choices. Is that a terrible idea, or what?

    sp_addtype(). Informix's (and Microsoft SQL Server's) lame version of CREATE DOMAIN.

    If you're going to use BIT, better be sure you'll never need a value for "don't know/don't care" in that field.

    OT, you have to serve it the SQL -- why is it called SQL Server? ;-D

  • The Fake WTF (unregistered) in reply to Marchuary

    But these arrays will give you "Feb" as the abbreviation for March. Or am I missing something?

    No they don't. C arrays are 0-based. So month 0 is the blank one, month 1 is Jan, etc.

    And for the rest, I assume they meant bowels, not bowls.

  • Westley (unregistered) in reply to James
    James:
    Wow, I feel like an idiot -- 10 seconds of Googling turned up the Bit data type. D'oh! Anyway, the idea still applies (of using a foreign-keyed table to make your own enumerated data type), just where there's more than two (but fewer than 10/26/whatever) valid choices. Is that a terrible idea, or what?

    Use bit for booleans, make sure you mark it as NOT NULL. For enumerations, you could create a lookup table with a foreign key if you really wanted to, but it's a lot of overhead for just a few values. There's a couple of other options...

    You could create an enumeration in code and just store the underlying integer value in the database. For example, in C#...

    public enum MyStatus { New, InProgress, Complete }

    int myStatus = (int)MyStatus.InProgress;

    If you need something more descriptive in the database for something like a separate reporting module, you could store the text of the enumeration instead -- but then you risk the application breaking if someone renames a value in the enumeration.

    string myStatus = MyStatus.InProgress.ToString();

    There are a few ways to skin this cat. I'm sure others have differing suggestions.

  • Dylan (unregistered)
    if ((int_year > 80) && (int_year < 100)) int_year +=1900; if ((int_year >= 0) && (int_year < 20)) int_year +=2000;

    Oh god, what do we do if I'm born in xx20 to xx80? or legitimately born in 1915? its y2k all over again.

  • efile (unregistered) in reply to silent d

    use EFILE

  • (cs)

    I've got a system with some of this code we're trying to get out of the door. The sinking feeling in my stomach is because the WTF code I just read is better than the code on the screen in front of me.

  • reaver121 (unregistered) in reply to Westley
    Westley:
    James:
    Wow, I feel like an idiot -- 10 seconds of Googling turned up the Bit data type. D'oh! Anyway, the idea still applies (of using a foreign-keyed table to make your own enumerated data type), just where there's more than two (but fewer than 10/26/whatever) valid choices. Is that a terrible idea, or what?

    Use bit for booleans, make sure you mark it as NOT NULL. For enumerations, you could create a lookup table with a foreign key if you really wanted to, but it's a lot of overhead for just a few values. There's a couple of other options...

    You could create an enumeration in code and just store the underlying integer value in the database. For example, in C#...

    public enum MyStatus { New, InProgress, Complete }

    int myStatus = (int)MyStatus.InProgress;

    If you need something more descriptive in the database for something like a separate reporting module, you could store the text of the enumeration instead -- but then you risk the application breaking if someone renames a value in the enumeration.

    string myStatus = MyStatus.InProgress.ToString();

    There are a few ways to skin this cat. I'm sure others have differing suggestions.

    Only storing the int or the text of an enumeration is IMHO not a good idea. You create an invisible dependency. The first person who changes the enumeration breaks the code.

    So I usually go for the lookup-table solution if possible. You could use a constraint or an user defined type (I know that SQL Server supports this, Oracle probably too). Unfortunately I usually use diagrams to view/control my database and constraints/ are not immediately visible present while a lookup table is.

    Constraints/user defined types are also more limited then a lookup table (in SQL Server anyway, don't know in other products). I usually prefer numbers as unique values in enumerations (be it in code or in the database) instead of strings. I usually work in ASP.NET and depending on the culture (English Americain,...) that you use for your code a string compare can fail or not fail. Numbers compare always the same way. But I also want a string representation of those unique values so an lookup table is the way to go.

  • (cs) in reply to James
    James:
    I'm guessing the existence of the Yes/No - Zero/One tables are because the guy knows how to use foreign keys, but does not know how to use constraints -- or maybe the DB he was using doesn't support constraints.
    The database that contains the Yes_No table has no constraints, and no foreign key relations are defined. (WTF, right?) I have no idea what the table is used/useful for.
  • (cs)

    if (youreHappyAndYouKnowIt){ ClapYourHands(); }

  • Kasper (unregistered) in reply to Anon Sam
    It would be nice if the system warned them that their inputs were being auto-corrected
    Maybe it does. We can't really tell from this small piece of code without context.

    I have done code like that which would update the year entered by the user as soon as the input field lost focus. But where this example uses a fixed cutoff at 20, I made it dynamic based on the current year. Such that in 20 years the code would still behave as the users expected.

  • Proko (unregistered)
    Highly Paid Consultant:
    for(;;) { myport++; if ((myport - LISTENPORT) >= 5) { myport = LISTENPORT; WARNING(func, "bind() failedon all ports from " << LISTENPORT); SLEEP(func, 5, "No idea"); ...}

    Of course, why haven't I ever done that. If I can't listen port, what I want then I try to listen ports that are close to the one I wish to listen. Maybe some whispers on packets come trough. I recommend that this site will begin doing the same, so when it can't listen at port 80, it listens 81, 82, 83 or 84.

    NB: The 1,800-line function called "doit" is actually documented. The HPC wrote the diagrams and ideas on napkins and maintenance programmers were simply unqualified to look from there

  • 'nother dude (unregistered)

    The real WTF is that programming is done in bowls.

  • dkf (unregistered) in reply to Proko
    Proko:
    NB: The 1,800-line function called "doit" is actually documented. The HPC wrote the diagrams and ideas on napkins and maintenance programmers were simply unqualified to look from there
    You do realize that for architectural documentation, a napkin is probably ideal? Or at least, if you can't fit it on a napkin (or beermat), nobody's going to understand it anyway so it might as well be not documented.
  • bd (unregistered) in reply to FredSaw
    FredSaw:
    Good idea having 13 slots for months. Shows the coder was thinking ahead to future expansion. Scalable code... very enterprisy.
    Or, the coder was anticipating Gallic War bond pricing and accompanying Unidecember and Duodecember woes:
    To restore the calendar to its supposed original relation with the seasons, he extended the year of 45 B.C. to 445 days, adding the months of Unidecember and Duodecember… This became known as the Year of Confusion.
    But even then, it would still be incorrect, as one empty slot is missing and both should be at the end of the array.
  • Rich (unregistered)

    Of course bits being just 0 and 1 dont have any real meaning - other than the conventions that non sql people follow... in SQL of course, 0 represents success... so we like to have things explicit. It helps on presentation too, or indeed nice outer joins that show the number of x and ys even if no ys exist.

    But programmers never have to do all that kind of tedious crap, they just move onto the next piece on unmaintainable Front Ahead Design Enterprise app.

    captcha - appellatio - sounds rude to me ;)

  • Highlander (unregistered) in reply to Dylan
    Dylan:
    if ((int_year > 80) && (int_year < 100)) int_year +=1900; if ((int_year >= 0) && (int_year < 20)) int_year +=2000;

    Oh god, what do we do if I'm born in xx20 to xx80? or legitimately born in 1915? its y2k all over again.

    As informed programmers know, we immortals were born in the year 60. I for one appreciate not having some nitwit add 1900 years to my birthdate. But don't worry, the problem will be solved as soon as I cut off the heads of all my fellow immortals.

  • the real wtf fool (unregistered) in reply to Architect Anonymous
    Architect Anonymous:
    if ((int_year > 80) && (int_year < 100)) int_year +=1900; if ((int_year >= 0) && (int_year < 20)) int_year +=2000;

    This looks like a workaround for Javascript's buggy support for dates. Not really the authors fault.

    And what happens in 2020? Or if someone mistakenly uses this function for birth years rather than the current year?

  • (cs) in reply to dkf
    dkf:
    Proko:
    NB: The 1,800-line function called "doit" is actually documented. The HPC wrote the diagrams and ideas on napkins and maintenance programmers were simply unqualified to look from there
    You do realize that for architectural documentation, a napkin is probably ideal? Or at least, if you can't fit it on a napkin (or beermat), nobody's going to understand it anyway so it might as well be not documented.
    Well, there's a difference between architectural documentation (which should definitely be written on the back of a beer-mat) and the User Guide to the architecture.

    I find that the latter typically works best when written on the back of beer vouchers. Of course, the Architect has to hang out with the plebs down the pub, but then we all have our cross to bear.

  • (cs) in reply to YAYitsAndrew
    YAYitsAndrew:
    I wish this was posted under Code SOD so that I would have known to avoid it. I don't enjoy reading other people's terrible code.

    captcha: minim (as in 'minim'um effort Alex has been putting into these past few updates)

    Boo, it's another dolt.

    The whole purpose of this site is reading other people's terrible code. Perhaps you shouldn't be loading it in your browser then?

  • (cs)
    static char months[13][4] = {         "   ", "Jan", "Feb", "Mar", "Apr", "May",          "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    

    All right... let's see here. How do I get "Feb?" Is it... months[2]? Huh... no that returns "DoWibble." Hmm... is it... months[1][2]? Huh.. no that returns the Radial Tires object. Maybe its months[5][2]? No, that's "grandma's cookies." And months[20][12][4][2] returns "12." [Snip][Snip][Snip] AH!! I found it! To get Feb, you have to use months[13][4][2]! Of course! How aptly named.

  • (cs)

    The flexibility!

    SELECT * FROM ONOFFTABLE 
     
    keycode  text  
    -------  ----- 
          0  ON 
          1  OFF 
    
  • bef (unregistered) in reply to SomeCoder
    SomeCoder:
    Remember Lisa McPherson:
    If you've got Firefox, use the AdBlock Plus plugin; it saves Alex's bandwidth for ads you don't want to see.

    Off topic but is that how AdBlock works? Does it actually not download the offending material or does it download it but not display it?

    I'm just curious. I use AdBlock and I love it.

    You can set AdBlock to download but not display, or to not download. I don't know if AdBlock+ has that functionality.

  • (cs) in reply to SomeCoder
    SomeCoder:
    Remember Lisa McPherson:
    If you've got Firefox, use the AdBlock Plus plugin; it saves Alex's bandwidth for ads you don't want to see.

    Off topic but is that how AdBlock works? Does it actually not download the offending material or does it download it but not display it?

    I'm just curious. I use AdBlock and I love it.

    I believe, it rewrites the HTML for the page so that teh ads are never downloaded.

  • Tim Magee (unregistered)

    By any chance was this a program to calculate the answer to "who's on first"?

  • (cs)

    The ONOFFTABLE bit reminds me of some code my last roommate was writing. Except that that was the only table in the database... and the database was built in access.. to support a VB.Net app that used a separate access db as a backend.

    Oh the nightmares this will cause.. I think I need a drink.

  • tiago (unregistered) in reply to Marchuary

    No if they use the month number converted to integer to index the array (we agree the array begins at index 0, right?). Indexing the array is faster than substraction, and substraction will be far more cryptic. What you people don't get is that this was designed for clarity, not for performance (just look at the 10 if blocks) ;)

    It's self documenting code!

  • I was once a consultant.. (unregistered)

    This wasn't, by chance, a Canadian financial institution with a TLA, was it? Related to good old Wall St?

    I've seen a roughly 1800 line function with a name something like "doit", which copied values from one SQL db into another.. It had a 3-400 line while loop, IIRC...

  • Rob (unregistered)

    This code is eirily similar to a system I used to work on that was written in PHP, it used to use CURL requests on HTTP to get servers accessing databases, instead of accessing them directly, most variables where called things like $loop25 and there was a common occurrance of the variable $doit, which could have many numerical values which made one massive script do all sorts. Wierd thing is, I never knew the guy who coded it could write C.

  • jimmysixnuts (unregistered) in reply to ais523

    the system i'm currently working on uses a mixture of integers, smallints, tinyints, bits, and strings to represent boolean values. better still, its the same in the code.

Leave a comment on “I'll be back...”

Log In or post as a guest

Replying to comment #:

« Return to Article