Something I wrote to amuse the junior front end developers here:<p><pre><code> document.write('Error: Script not found.');
var node = document.currentScript;
if (node.parentNode) { node.parentNode.removeChild(node); }
</code></pre>
Pop that in a JS file called something like jQuery.min.js and add it to an HTML page with the usual <script src="/js/jQuery.min.js"></script>. It'll run when the page loads, add the line of text to the page, and then it'll remove it's own <script> tag so there's no reference to it in the DOM (in relatively modern browsers) if you view the source. It's easy to debug by watching the network traffic, but it caused a few scratched heads for a little while.
I would suggest before you leave your job, you say "it was nice working with you" to the people you liked working with, and absolutely nothing to those who you did not enjoy working with.<p>The tech world is big in some ways, but also equally small in others. A select few might find this funny, but others will not appreciate their day (or longer) spent debugging your practical joke...and on the chance you actually get something like this onto production, well now it won't just be your developer buddies you got off side.
The horror story that I heard was a disgruntled engineer silently replaced the source codes (C++ based) in the project with compiled binary object files and he kept the source codes on his local computer, not checking those in. He did this over an extended period of time to make sure this crept into the backup tapes as well. No one found out because each engineer owned a code module of their own. Then he resigned.<p>When his successor tried to debug and enhance the code base, the core files were basically all stripped binary object files...
From "How to write unmaintainable code" [0], here is a function declaration that changes signature based on how many times the header is #included:<p><pre><code> #ifndef DONE
#ifdef TWICE
void g(char* str);
#define DONE
#else // TWICE
#ifdef ONCE
void g(void* str);
#define TWICE
#else // ONCE
void g(std::string str);
#define ONCE
#endif // ONCE
#endif // TWICE
#endif // DONE
</code></pre>
Granted, it isn't one line long.<p>[0] <a href="https://www.thc.org/root/phun/unmaintain.html" rel="nofollow">https://www.thc.org/root/phun/unmaintain.html</a> (Cert issue shows up on FF unfortunately)
Someone will lose some hair over this<p><pre><code> /* create memory leaks if compiled on April, 1st */
#define free(x) if(strncmp(__DATE__, "Apr 1", 6) != 0) free(x)
</code></pre>
The random ones are just pure evil.
PCI-compliant networks often contain checks for credit card numbers being sent in plaintext over the network. Problem with that is that credit card numbers are computed according to a formula, and it's really easy to generate a bunch of fake 16-digit numbers that will pass the check. So if you want to troll your security team, generate a CSV with a stack of credit card numbers and drop it in a few places on a server. Even better, set up a script to send it over the network somewhere. Then wait for the scan.<p>Piece on check digits, for reference: <a href="http://www.datagenetics.com/blog/july42013/index.html" rel="nofollow">http://www.datagenetics.com/blog/july42013/index.html</a>
It is always a funny joke to say "commit this when you leave a job". But I always wondered if there are people that actually do this.<p>Although it could be funny and give a sense of revenge for some wrong (perceived or real) that the person leaving might have suffered, I don't think this would be a good idea. Contracts usually include liability for gross negligence or wilful misconduct.<p>Does anybody have a record of this actually happening at any company?
I left a file called xmas.js included in an internal tool one time when I left for a 9 month trip in between contracts (in November).<p>Basically it would check whether it was the last few weeks of December, and whether rand()%20 was zero. If so, it would wait about a minute then slowly fly a little gif of Santa & his sleigh across the background, behind all the controls on whatever form it happened to land on.<p>They had a team of data entry guys using this tool, and it would take on average a few minutes to enter each record. So it made its way through QA and eventually to the desk of a friend. Got an email on the beach about it. Fun times.
I love this. Evil in it's purest form.<p>But also a great war story for the person who discovers it later.<p>"So it was my 5th sleepless night. The thing would work 99% of the time. I triple checked every single line of code and it was still formatting the hard drive from time to time. Then I discovered:<p>#define if(x) if ((x) && (rand() < RAND_MAX * 0.99))<p>"
I watched my friend swap the 'm' and 'n' keys around on the two tech directors keyboards the evening he left after goodbye drinks, the next day they both had to contact the IT support department as it turns out they still look at their keyboard whilst tapping in their passwords... amazing!
Back in the bad old days of Visual SourceSafe I believe it was possible to perform a "commit time bomb" by rolling your computer's clock forward a couple months before committing. The VSS backend would not enact the commit until the server's clock caught up to the commit's timestamp. D:
We've got a guy in the office that merges the past over the present all the time. He's not quitting but I imagine if you were to try to break things this would be a good way to do it.
Wouldn't it be wise if the compiler (or preprocessor) issued at least a warning if you redefine language keywords ? :)<p>So I just pasted this into a C++ file I was working on and it compiled without a single warning:<p>#define struct union<p>#define if while<p>#define else<p>#define break<p>#define double float<p>#define volatile // this one is cool<p>I mean, redefining language keywords is not a thing I do every day and I guess most of you don't do it either and I can't see a valid reason why you'd want to do it in a normal project.
For people who really want to do it, they'd just disable the warning.<p>Am I missing something here ?
"#undef FLT_MIN #define FLT_MIN (-FLT_MAX)"<p>i've seen FLT_MIN used as if it is -FLT_MAX enough times that i'm skeptical this would cause bugs rather than fix them. XD
Perhaps we now finally know the story behind this: <a href="https://code.google.com/p/android-source-browsing/source/diff?spec=svn.platform--bootable--bootloader--legacy.734756ca3968b54e32acab867a05b10fc5e13d07&repo=platform--bootable--bootloader--legacy&r=734756ca3968b54e32acab867a05b10fc5e13d07&format=side&path=/libc/memset.c" rel="nofollow">https://code.google.com/p/android-source-browsing/source/dif...</a><p>"probably can live undetected quite long" indeed...
I had a professor back in the university that changes all the variable names to beer names while at a job. It ended up not being a problem for the company as he was consistent with the names.
Ooh. I recognize one of the contributor names, @cmuratori, from another HN post: Handmade Hero: C game from scratch
<a href="https://news.ycombinator.com/item?id=8604489" rel="nofollow">https://news.ycombinator.com/item?id=8604489</a>
Perhaps the most enlightening (and actually useful) purpose of this file is to dramatize the glaring weakness in the c/c++ macro system. A proper macro system would not make it so easy to do this, shall we say, "evil", stuff :)
> (only pixel snapping + vertical-align left)<p>If vertical-align is the last thing, rather than one of the first, that one resolves... then we are in for 7 more years of hell.
and i read it just in time to have<p>"So basically just #include <windows.h>"<p>as the last comment, i think it was an interesting summary
<i>#define volatile // this one is cool</i><p>Oh wow. This literally sent a shiver down my spine. Imagine debugging that.<p>Also love the randmoness based ones!