Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stopthatastronaut/be67e94f0bbfcdfea5a9b50bb8f9a1d2 to your computer and use it in GitHub Desktop.
Save stopthatastronaut/be67e94f0bbfcdfea5a9b50bb8f9a1d2 to your computer and use it in GitHub Desktop.
Get-SpongeBob. A powershell snippet for quick transposed caps spongebob memeification
# 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