- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Ajax, you know, they sent it out to bring back Flash's body.
Admin
Wasnt Ajax the war rocket of the bad guys in the Flash Gordon movie?
Admin
Ajax was a hero in the illiad, big guy, he got killed...
Admin
Its also a brand of washing powder, extremely corrosive
Admin
You guys are so stupid! If you don't know what something is then just don't say anything!
http://www.colgate.com/app/Colgate/US/HC/Products/HouseholdCleaners/Ajax.cvsp
sheesh!
Admin
What's even more of a WTF is that the leap year calculation is WRONG. Leap years are years that are divisible by 4, unless they're divisible by 100, unless they're divisible by 400. The year 1900 was not a leap year, 2000 was.
Admin
AJAX (Asynchronous JavaScript and XML) is really starting to piss me off, because I'm starting to hear demands that it be used in totally inappropriate places.
Places that make it obvious that the person has absolutely no idea what AJAX actually means, let alone what it does.
I'd have to go searching through my inbox, but I believe I've actually had someone seriously suggest that XML be replaced with AJAX. I'm really not sure where to start on that one.
And, of course, there were the numerous suggestions that web services be replaced with AJAX, never mind that AJAX is essentially a method of communicating with a web service.
Plus there are the people who've started to use AJAX to mean "any webpage with JavaScript on it" which is also annoying.
AJAX isn't really anything new - it's just a new term for an old trick.
Captcha: scooter (as in Libby?)
Admin
What's even more of a WTF is that the leap year calculation is WRONG. Leap years are years that are divisible by 4, unless they're divisible by 100, unless they're divisible by 400. The year 1900 was not a leap year, 2000 was.
Admin
so, Paul, what's the method for figuring out if a year is a leap year?
Admin
Ajax: a brand of dish detergent that everyone should use. It's cheap and gets the job done.
Admin
Usually your goal isn't to figure out whether a year is a leap year, but to do something like a calendar or date math. If you have to do an explicit leap year calculation for that in Javascript, you are doing something wrong.
That said, this will tell you whether the current year is a leap year.
var d = new Date(2008,5,4); d.setMonth(2,0); var isleap = d.getDate()-28;
Admin
get some number for years
if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) leap! else dont!
Admin
Correction whether NEXT year is a leap year.
Admin
OK, it's verbose, but it's legible.
Admin
I was about to comment on this... leap year isn't as simple as it seems.
Admin
That's a perfectly valid means of detecting leap years on the Julian Calendar.
Admin
I don't think Ajax KILLED Flash. I mean, you can make websites more interactive using Ajax, but Flash still has its place on the web.
(Yes, bad joke :) )
Admin
That's just amazing to see how many coders actually focus on number representation ( as a string ) instead of properties ( modulo, comparison to 0, integer truncation ... ).
Excusable for teenagers, but not for professionals. Not even non-programmers.
I remember similar cases in older WTFes, like checking if a number starts with "-".
Admin
") else document.write("Is not a leap year.
") if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) document.write("Is a leap year.
") else document.write("Is not a leap year.
") </script>
Admin
Some people snap when you tell them Feyenoord is better than AJAX....
Admin
Ajax of spades is my favourite playing card
Admin
WTF. You've already returned true on the mod 400, and never get to the mod 100 or mod 4 checks.
Admin
I AJAX would kill Flash, though. Flash is just evil, although not 100% evil. It would be 100% evil if the interior scripting language was Perl.
Admin
Well, almost never - it only happens for numbers which aren't divisible by 400, in fact. Still, there can't be many of those, can there?
Admin
You go to the calendar hanging on the wall, flip to the page that says "February" and look for the number "29." If you see it, then it's a leap year. If not, then it's not. Unless of course your calendar was printed wrong. Hmm...so maybe that's not so fool-proof either. That's odd...Come to think of it, my calendar doesn't have any 7's. Better check my phone to see if it has a 5.
Admin
Hope this is a joke
Admin
Please oh please tell me you're trolling or trying to be funny
Admin
Admin
Admin
Yeah, the idea is that you never get to the 100 or 4 checks.
The real WTF around here is usually the comments...
Admin
Hush now Jamie, it's ok.
If the if statement is only one line, you don't need braces.
Don't get all het up, it'll give you indigestion.
Admin
Um, pretty sure that's by design. If a leap year's any year divisble by 4, unless it's divisible by 100, unless it's divisble by 400, there's no point doing the mod 4 or mod 100 checks if it's divisible by 400.
captcha: riaa - speaking of people who just don't get it...
Admin
AND that logic only applies to the modern calendar, not the Julian calendar. So even if you're clever enough to handle Gregorian dates, you're still going to fail on a wide range of historical dates.
I try to teach people as a basic philosophy: the world is extremely complex. So complex, in fact, that we fail to see 99% (or more) of the complexity underlying our everyday lives.
By corollary, if you have to model the world in software, odds are it's going to be utterly complex and you're going to WTF it up in at least a few significant ways. (Think about all the arguments we have here -- among supposedly reasonable developers -- about things like dates, decimal math, hash functions, etc.)
So don't reinvent the wheel, because you're likely to do it completely ass-backwards and wrong. And any logic you do implement, make sure you explicitly state your assumptions.
Admin
Hello Jamie, could you check the code with year 2007 or 2008 and rethink your statement? For me, code seems ok. And if you do it with three ifs or with one is just a matter of taste.
Admin
Come on, everybody knows that Ajax is something you use to clean your dishes and toilets.
Admin
Am I the only one who wants to do something about those "var mints" in the uploadTime function? Possibly using a hunting rifle?
Admin
FYI in Spanish Ajax is pronounced with the j like an h so it is said like " a hacks" which pretty much sums it up.
Admin
I think you win..even though other people had similar logic, you were the only one to "correctly" order the conditions of the predicate from most common to least common.
75% of years aren't divisible by 4, 99% of years aren't divisible by 100, and 99.75% aren't divisible by 400. Some people check for that itty-bitty .25% slice first when they could be checking for the 25% slice first.
Then again, most people don't know what short-circuit evaluation is.
Admin
It's not just a matter of taste. You're fundamentally doing different things. You're doing at most 3 comparisons and 3 corresponding conditional branches. The other way to do it is at most 3 comparisons, 2 logical operations, and one conditional branch.
Admin
Well, there wouldn't be any point in checking whether if it is divisible by 100 and 4 if the year is already divisible by 400.
Admin
assuming one's piece of code will be out of service in 93 years from now, mod 4 is an adequate check. it's not correct but why bother..
Admin
Isn't be biggest WTF (in the uploading time estimate) to assume that always takes one second to transmit 3500 bytes?
Admin
JavaScript in general pisses me off. My company has a web-based provisioning app that insists on using JavaScript to validate all the form data before you submit it.
The developers on it set up the forms so that pressing enter in a textbox doesn't actually submit the form. They want me to have to press the submit button with my mouse, because that will "ensure" that I don't try to hack my way around the validation by turning JavaScript off....
I tell the developer, "umm, I can just look at the source and find the URL it's posting to, send whatever data I want that way." His response? "That's why we do the same validation on the server side".....Why? Why bother?
Admin
Asynchronous Javascript And XML.
The problem with Javascript is its byzantine methods of doing things, and the fact that the typing is painfully weak. Object Oriented programming (for example) is hacked on in Javascript, and sadly it really shows.
It's great that it's so easy to learn to use javascript, and I'd consider it an ideal language to teach programming concepts to high school students (delightfully instant feedback when you pair it with the DOM, no need to precompile), except that it's way too forgiving of what are usually mistakes. And, sadly, most of the tutorials and code snippets for javascript were programmed by people who consider things like mirc script the apex of computer science.
Admin
that is because 400 is always divisible by 4. It is impossible for 400 to be true and 4 to be false.
Admin
The equivalent to the Kelvin scale here is the Ussher scale, which is calibrated back to an origin of 9AM Oct 3 4004 "BC."
Ignoring the rounding errors caused by not starting on the boundary between 28 and 29 Feb 4004 BC, you therefore have to take the following into account:
(a) If the input is before -4004, the output is NaN. (I've always wanted to use that in integer arithmetic.) (b) For all other inputs, adjust by -4004 before applying the div 4, (mod 100 and mod 400) calculations. These are of course subtly different because of the irritating extra 4 that God chose to put in there.
You can ignore leap-seconds, the precession of the Earth's axis and the slow degeneration of the Earth's orbit for any sensible date in this range because the numbers involved are too small to matter. Which just goes to show how clever Ussher was, and that Intelligent Design is obviously correct.
And I'll bet they haven't factored that into VB.Net libraries ... just another reason to hate the goddamn language.
Admin
There is nothing hacked onto it; ECMAScript has no notion of being a "real" OOP language.
You have to use programming conventions about object factories and closures to emulate things you take for granted, like static/class methods and properties, mixins and private methods/data. But you can simulate almost anything provided you adhere to some generally accepted practices.
For the user of objects, it's pretty clear cut. It's harder for the class writer than say, Java or C#, or even perl.
But it's lovely in that: hey, everything's a hash. Makes manipulating and displaying text data trivial, and that's what it should be used for. (Thank god for Perl REs in JS 1.3)
Admin
I don't know javascript, so don't know if this is available, but couldn't you just do:
// Feb 1, yyyy GregorianCalendar gc = new GregorianCalendar(yyyy,1,1); if (gc.isLeapYear()) { // leap } else { // not }
or am I just missing the point?
Admin
Not really optimized, though... this code will do three comparsions for most years. Checking in reverse order most years require only 1 comparsion, or 2 in some cases:
I love pointless optimisations :-)
Admin
Another WTF. Without knowing (and understanding) how the software will be used, you can't make this assumption. Any date computation prior to Mar 1, 1900 will fail.