Created
May 1, 2018 00:36
-
-
Save stopthatastronaut/be67e94f0bbfcdfea5a9b50bb8f9a1d2 to your computer and use it in GitHub Desktop.
Get-SpongeBob. A powershell snippet for quick transposed caps spongebob memeification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://knowyourmeme.com/memes/mocking-spongebob | |
# | |
# This snippet lives in my profile for quick access | |
Function Get-Spongebob | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[string] | |
$in | |
) | |
Function Get-UpperOrLower | |
{ | |
param($in) | |
$r = Get-Random -max 100 -min 0 | |
if($r%2) | |
{ | |
return $in.ToUpper() | |
} | |
else | |
{ | |
return $in.ToLower() | |
} | |
} | |
$output = @() | |
$inarra = $in.ToCharArray() | |
$inarra | % { | |
# Randomly transpose into upper or lower, unless it's an L or an I | |
# L should always be upper. I always lower. Otherwise you risk ambiguity :D | |
$ch = $_.ToString() | |
switch ($true) | |
{ | |
{ $ch -eq "I" } { $output += "i" } | |
{ $ch -eq "L" } { $output += "L" } | |
default { $output += (Get-UpperOrLower $ch) } | |
} | |
Write-Verbose ($output -join "") | |
} | |
return $output -join "" | |
} | |
Get-SpongeBob -in "It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife" | |
# outputs (randomly varied) | |
# iT is a tRuth uniVERSALLY ackNOWLEDged, tHat A SiNGLE MAN in pOssEsSiOn oF A gooD FORtUnE, must BE iN waNt OF A WifE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment