- 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
I cant understand php, but i hope tha this snippet doesn't search on google for the app page the user had requested ^^'
Admin
Why not? It's brillant! Hard Coding is for little heads that can't think ahead two weeks. Sure, you could write your own service to handle requests for the address of other services, but that would basically be a search engine. Why waste time trying to out-google google ?!?!?!
Admin
That code is self documenting...
Would you rather have a manual with huge bold text that said QUIT NOW OR YOU WILL BECOME ONE OF US, ONE OF US, GOOGLE GOBBLE, ONE OF US!
on a side note, I know little PHP, but I was able to figure out what it was doing...
Admin
{in a "back-handed" sort of way}
Admin
A lesson well learned, there is no such thing as a minor change. Allow 3 to 4 times as much time as you think it's going to take and you'll be fine.
Admin
Fifth!
Admin
You'll see what this code is used for the day google decides to redesign its results page...
Admin
i admit, after almost 20 seconds of looking at teh codez, i had to close my eyes.
The googles, they do nothing.
captcha: damnum
Admin
You know, you shouln't try to contradict Hofstadter's Law..
Admin
Why does the constructed search url include 'safe=off'?
I wonder what sort of content the Google search is designed to locate ..
Admin
The lesson being: seppuku.
Admin
That's exactly cleaner than some php code...and it's in a class!!!
Admin
The real WTF is that there are still [software development] virgins out there.
Admin
BTW... The problem with this code is that google changed
in results for
I am maintaining a php app that was coded the same way... the easiest way to fix it and maintain it for a long time is to change the DAMN strpos to find results for regexp !
Admin
Of course, everyone knows that when you put several statements on one line, your code runs faster!
But then there's that big block in the middle that's heavily indented... that's going to be a problem there, all that whitespace will block up the CPU pipeline (they clog even easier than Internet tubes).
Admin
Okay Jess, I don't want to hurt you feelings but if you can't read that code TRWTF was your hiring. Plus, the original developer seems to be quite a lazy ass but he's likely to be more capable to get things done. Sorry, but that CodeSOD is boring.
Admin
Ooh! Minified PHP code - it saves lots of bandwidths!
Admin
I wonder if the author of this project is the same guy who wrote/customized my soon-to-be-ex employer's "ERP" (using that term loosely) system? While my project is written in VBScript and Classic ASP, the rest of the signs are pretty darn close.
We need to shoot people like this, on sight. They ruin this field for the rest of us who actually know what the fuck we are doing.
Admin
There are people who know what they are doing? This has yet to be be proven. I don't know what I'm doing over 99% of the time because my PM's don't know what they are doing... Where do you work at and are you hiring more programmers? :)
Admin
Obviously, the right way to do this would be to take the Google search page, parse it as HTML, and run XPath or similar over it... //*[@class="g"]//a[@class="l"]/@href - suddenly the change from from
to
Admin
I'm way to tired to even work out what that does. But even if I was awake, I don't think it would help.
Admin
So is this now a place to post WTF code that we are trying to figure out at work, and get the community to figure it out for us? Wish I'd known that a few years ago; would have saved me some head scratching.
OTOH, it seems only one step above "send me teh codez, plz".
Admin
My first thought on seeing this was "this is autogenerated code".
To play Devil's advocate, I've got compilers and code generators that spit out stuff like this when it's the best way to reduce the amount of code a human has to read and write overall. They might be a directory elsewhere with some Wasabi code in it ;-D
(Except my generated files usually have a comment at the top SAYING what autogenerated it and where the original source can be found...)
Admin
HA yep there really are tons of l33t coders out there who genuinely believe that several statements packed on one line actually makes the code faster. 1 letter variables and zero comments sheesh. Darth Vader coder: 'If you only knew the power of the spaghetti code.' Me: 'Nooooo...I'll never join yooooou.'
Admin
We never learned what the "minor change" was. So far there has been a lot of searching though files and code, but no changing. So the change might still be minor.
Admin
I ran this through zend studio real fast, it doubled the lines of code, whoever wrote that snippet has no idea what whitespace is.
Admin
Admin
Admin
Admin
SpectateSwamp would be proud.
Admin
That said, the article gets the jist... But the WTF wasn't that I couldn't read the code. The WTF was that there were gigs of content (literally), broken up into more files than I could sift through, and not a single comment anywhere therein. That code wasn't what I was looking for, it was just an example.
Take a look at the file list:
(and so on). It'd be nice if I could have assumed that "engines.php" was the file being used and all the other ones were just backups, but unfortunately, as I found out later, that wasn't the case. (It was a couple months ago, but I recall engines--.php being the current file. Notably, it had similar content as the rest, but vastly different code)So yeah, the code in the submission is readable. Sure, I know exactly what it's doing just by looking at it. But, imagine sifting through hundreds of files, thousands of lines long, all formatted in that way. Multiple statements per line, variable declarations (with no comments) that are 2-3 characters... no spacing... screwy indentation...
Also, the project manager refused to give me ftp access in fear that I'd steal all his code (and would have dropped me if he caught me using scp, or similar). While formatting could have been autocorrected in an IDE, in this project it was vi or finding a new client.
Since no one on -his- team knew anything about ANY of the code (he hadn't even hired a single programmer to maintain it), after finishing up the work he had asked for, "find a new client" is just what I did.
Admin
That's what you get for being a web programmer.
Admin
A friend once told me that you should multiply all software time estimates by a factor of pi to get a more reasonable estimate (pi/2 if you've done it before).
Admin
Admin
Admin
Admin
it sure does save ALOT of bw for tdwtf and viewers...
and yes mate, anywhere there's info transfer, there's bw - cpu-mem and such... dont patronize us n00bs!
Admin
sorry for posting twice... so that's what the quote button's for...
it sure does save ALOT of bw for tdwtf and viewers...
and yes mate, anywhere there's info transfer, there's bw - cpu-mem and such... dont patronize us n00bs!
Admin
0hh d00d, j00 c0uldn'7 b 4ny m0r3 wr0ng... 3v3ry c00l ch4p 0nl1n3 kn0wz w07'z 7h1z R34lly 5ux
and for the cooler peeps...
0## d00d, j00 c0|||d||'7 b 4||'/ |/|0r3 //r0||6... 3/3r'/ c00| c#4p 0|||1||3 |<||0//2 //07'2 7#12 R34||'/ 5|_|x
Admin
And you call your self a programmer?
It checks the position of a given page in the google SERP's.
Looks much like mine code ... tho I've put comments almoust every second line since I've first time forgotten what the code did a year after finishing it.
Admin
... and YOU call YOURSELF a programmer??
Admin
I don't know what YOU do for living, but if you code every day, you can't remember any detail of how you implemented things without taking a long, deep look at it.
Admin
10 HOME 20 SWEET 30 GOTO 10
Admin
I must disagree. If you wrote your code well in the first place, you, or any other programmer, should be able to come back in 1 or 2 or 10 year's time and still understand what it is meant to do.
And by "writing your code well" I mean: Process:
Code:
Admin
I -did- submit that I didn't know if it was being used... and TBH, I still don't know if a lot of it was. I don't tend to spend my time obsessing over other people's garbage.
I did what I was asked to do, but signing up for a "small" project like that is -not- a mistake I plan on making again.
Admin
The only real problem here is that google does not use XHTML, so this is not, in the strictest sense, a valid solution. HTML is not a subset of XML, so XPATH is not guaranteed to work in all situations.
Use a regular expression and call it a day.
Admin
Well, the "parse the HTML" step would obviously have to involve a tag soup parser at some point... Google's HTML isn't valid, after all. But I maintain that once the HTML is parsed into a document tree, the fact that it's not really XML shouldn't matter, and XPath'll work.
Also: That's certainly not the only real problem with the suggestion. Seriously.
Also also: The non-joking real way to do it is with this. Or something like it (I'm not sure if that's the exact right project, but there'll be something on that site that does what they want).
Admin
The Real WTF is that Alex will take this as more evidence that PHP is a horrible terrible language instead of blaming the poor demented soul who actually wrote the code.
Admin
Actually what it stands for is:
"You bought a TRS-80 Mod III with 16k RAM for $1,000 and the Commodore64 just came out? You're f**ked!"
Admin