Project Legacy Code
As developers, we have a bunch of stupendous stories about the time spent debugging legacy code. This blog is designed to highlight some of the most annoying / interesting / hair-rising / hilarious solutions of the past.
Friday, May 23, 2014
Too many comments!
$_____________________________ = "this variable is to separate the two commented code part";
Wednesday, May 21, 2014
Longest CSS selector ever
When more developers shit into the same CSS, well, things get complicated.
body.forum-archive.bbpress. archive.post-type-archive. post-type-archive-forum. logged-in.admin-bar.blog. customize-support .container.blog .header img.logo{ margin:0px; }
body.forum-archive.bbpress.
Tuesday, April 15, 2014
A function for array to object conversion
Ironically the title of this post is way longer than the function itself, which I've just found:
public static function arrayToObject($d) {
return (object) $d;
}
public static function arrayToObject($d) {
return (object) $d;
}
Monday, April 7, 2014
"NO TOUCHES"
You know how PHP works, great, that's a thing, but please. Don't torture me having to debug this.
$$$ENTITY_NAME=$e[$i]; //no touches
Yes, this guy used 3 freaking dollar signs the valid way. (I wouldn't post how the validity came out 'cuz of space). Now I can prove, egoism also exists in coding style.
$$$ENTITY_NAME=$e[$i]; //no touches
Yes, this guy used 3 freaking dollar signs the valid way. (I wouldn't post how the validity came out 'cuz of space). Now I can prove, egoism also exists in coding style.
Trust me, it's random!
Remember this soon-to-be-classic picture from xkcd?
There's a story for this, too. Not so obvious of course, but still rocks. Enjoy the new findings of Project Legacy Code:
$a = random8digit();
$b = random8digit();
$c = random8digit();
$d = random8digit();
for($i=0;$i<25;++$i){
$randomhash[$i] = $a.$b.$c.$d;
}
Trust me, they are chosen by a strong random value generator algorythm. This code is part of a free ecommerce script which -turns out- also has integrated parts of PayPal API. I would accept a bank transfer of random 8 digits :)
There's a story for this, too. Not so obvious of course, but still rocks. Enjoy the new findings of Project Legacy Code:
$a = random8digit();
$b = random8digit();
$c = random8digit();
$d = random8digit();
for($i=0;$i<25;++$i){
$randomhash[$i] = $a.$b.$c.$d;
}
Trust me, they are chosen by a strong random value generator algorythm. This code is part of a free ecommerce script which -turns out- also has integrated parts of PayPal API. I would accept a bank transfer of random 8 digits :)
Sunday, April 6, 2014
Remainders of an obfuscated PHP core library
Working with something that's built on an obsolete legacy core library is priceless. The functions themselves look like this
Simulating mouse button hold
... is the easiest using a simple recursive function which continuously does clicking, thought Mr. Legacy Coder, and found out, that the best jQuery implementation for this would be onclick="$(this).click();". Too bad, that this throws a Maximum call stack size exceeded error. Yea, there's always hope, that such script execution ends in a finite time. The key element of legacy code is always Magic. But this came to his mind, too - turns out from the following few lines: preventDefault() called after 3000 milliseconds timeout. #genius
Subscribe to:
Posts (Atom)