Recent Coded Smorgasbord

Inspired by the Pop-up Potpourri, the examples presented here aren't necessarily "bad" code nor do they imply the miserable failure that we're all used to reading here. The examples are more-or-less fun snippets of code like ones that we've all written at one time or another.

Apr 2011

Important-Function(), IsNumber(), and More()

by in Coded Smorgasbord on

" "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..."}
	}
	}
}