" "I found a function called 'Important-Function' in a colleague's PowerShell script," wrote B. Versteylen, "after expanding the function, I discovered this."

Function Important-Function()
{
#Hehehehehehe ^^
$logTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss" #Just so it looks the same as a regular log entry :+
$randomNumber1Method = New-Object  System.Random
$randomNumber1 = $randomNumber1Method.Next(1,100) 
If ($randomNumber1 -EQ 30) 
	{
	$randomNumber2Method = New-Object System.Random
	$randomNumber2 = $randomNumber2Method.Next(1,15) 
	Switch ($randomNumber2) 
	{ 
     1 {Write-Host $logTime "Watching a colleague pick his nose..."}
     2 {Write-Host $logTime "Solving a binary sudoku puzzle..."}
     3 {Write-Host $logTime "Hoping to return anything useful..."}
     4 {Write-Host $logTime "Slapping random people with a trout..."}
     5 {Write-Host $logTime "Surfing porn sites on the internet..."}
     6 {Write-Host $logTime "Pondering the next move..."}
     7 {Write-Host $logTime "Formatting the hard drive..."}
     8 {Write-Host $logTime "Dividing by `$null..."}
     9 {Write-Host $logTime "Getting a cup of coffee..."}
    10 {Write-Host $logTime "Trying to fit a square into a circle..."}
    11 {Write-Host $logTime "Yawning as a cow races by..."}
    12 {Write-Host $logTime "Milking a goat..."}
    13 {Write-Host $logTime "Playing rock-scissors-paper..."}
    14 {Write-Host $logTime "Reading a manual on WMI..."}
    15 {Write-Host $logTime "Thinking about Jessica in Berlin..."}
	}
	}
}

 

"I found this in the middle of a Ruby on Rails project that I'm working on," writes Matt Grande, "I'm tempted to set it to true..."

class Skynet < ActiveRecord::Base
  # DO NOT SET TO TRUE!
  def self.is_aware(aware)
    if aware
      return "Must DESTORY John Connor!"
    else
      return "2:13am EDT August 29, 1997..."
    end
  end
end

  Gabor Varnagy writes, "now this is what I call defensive programming."

int PrBoolFlag(bool inbool, bool &value) {
  int retval;
  value = false;
  if ( (inbool == true) || (inbool == false) ) {
    value = inbool;
    retval = 0;
  } else {
  	printf("\n???SW.ERROR:Printer/PrIntDpi: illegal 0 \n");
    retval = CPERR_BoolArgBad;
  }
return retval;
} 

 

"I was reviewing some old code for a website we're revamping, and I came across this Javascript window popup function," wrote Don. "It appears to just be a 'fun-fuscated' version of an old Macromedia function."

function Commodores(Once,Twice,Three,Times,Lady){
    Lionel = (screen.width) ? (screen.width-Three)/2 : 0;
    Richie = (screen.height) ? (screen.height-Times)/2 : 0;
	Easy = 'height='+Times+',width='+Three+',top='+Richie+',left='+Lionel+',scrollbars='+Lady+',resizeable'
   window.open(Once,Twice,Easy)
 }

 

"I worked on a large retail chain's project to rewrite their portal system from scratch," Rehan wrote, "while I'm sure the new will end up like the old some day, there were a few gems I found, including this:"

1.ToString()

 

"I worked with a French programmer for a while, and noticed that he said 'merde' quite often," Paul wrote, "I never bothered to look it up, since it was pretty obvious it was some explicitive that was meant 'damn' or something like that."

"But then, while the French coder and I were trying to understand the interface, he hacked together a header file and guffawed, 'ze code is merde!'. After seeing what he typed in, I suddenly understood the true meaning of the word."

// No time to change this for the moment
//
//         (   )
//      (   ) (
//       ) _   )
//        ( \_
//      _(_\ \)__   Merde!
//     (____\___))
//

#define please_do_not_vomit
#include "sys.ho"
#undef please_do_not_vomit

 

"I was doing maintenance work on a client's flash game, when I found this," wrote Carlos Barbosa, "seems that the coder really liked Ladytron's Destroy Everything You Touch."

private function "destroyEverythingYouTouch" {

    today();

    destroyMe();

}

 

"On my team, we encourage everyone to use debug assertions generously," Blake writes, "most assertions are well thought-out and useful, and have actually found some decent bugs. But then one day while going through some older portions of the codebase, I stumbled across this beautiful snippet."

Debug.Assert(value <= Int32.MaxValue);

Blake continued, "...and yes, value was an int, not a uint. I guess he just wanted to make sure the universe was still functioning properly. "

 

Paul shared this creative snippet of VB.NET.

Bool IsNumber (string str) 
{ 
  return str _
    .Replace ("0", "") _
    .Replace ("1", "") _
    .Replace ("2", "") _
    .Replace ("3", "") _
    .Replace ("4", "") _
    .Replace ("5", "") _
    .Replace ("6", "") _
    .Replace ("7", "") _
    .Replace ("8", "") _
    .Replace ("9", "") _
    .Length == 0;
}