-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPowerUnko.psm1
131 lines (120 loc) · 3.45 KB
/
PowerUnko.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<#
.SYNOPSIS
Output fizzbuzz with unko
.EXAMPLE
Get-UnkoFizzBuzz -Begin 30 -End 1
#>
function Get-UnkoFizzBuzz
{
Param
(
[Parameter(Position=1)]
[Int32] $Begin = 1,
[Parameter(Position=2)]
[Int32] $End = 10
)
$FizzMessage = "💩 < Fizz!"
$BuzzMessage = "🍺 < Buzz!"
$FizzBuzzMessage = "💩🍺 < FizzBuzz!"
foreach ($i in $Begin..$End) {
switch ($i) {
{$i % 3 -eq 0} { Write-Output $FizzMessage };
{$i % 5 -eq 0} { Write-Output $BuzzMessage };
{$i % 15 -eq 0} { Write-Output $FizzBuzzMessage };
Default { Write-Output $i };
}
}
}
<#
.SYNOPSIS
Search CSV data for a word that means "poop"
.EXAMPLE
Get-UnkoDictionary -Name "う" -Language "Ja"
#>
function Get-UnkoDictionary
{
Param
(
[String] $Name,
[String] $Language
)
Import-Csv ./lib/unko.csv | Where-Object {
($_.Name -ILike "*${Name}*") -and ($_.Language -ILike "*${Language}*")
}
}
<#
.SYNOPSIS
Output king unko
#>
function Get-UnkoKing
{
Param
(
[Parameter(Position=1)]
[Int32] $Height = 10,
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Unko = "💩",
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Eye = "👁",
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Nose = "👃",
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Mouth = "👄",
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Crown = "👑",
[Parameter(ValueFromPipelineByPropertyName=$true)]
[String] $Space = " "
)
for ($i = 1; $i -lt $Height; $i++) {
switch ($i) {
1 {
# Output crown
$padding = [String] $space * [Int32] ($Height + 1)
Write-Output "${padding}${crown}${padding}"
}
3 {
# Output eye
$unkoWithEye = "${unko}${eye}${unko}${eye}${unko}"
$padding = [String] $space * [Int32] ($Height - ($i - 1))
Write-Output ("{0}({1}){2}" -f $padding, $unkoWithEye, $padding)
}
4 {
$unkoWithNose = "${unko}${unko}${unko}${nose}${unko}${unko}${unko}"
$padding = [String] $space * [Int32] ($Height - ($i - 1))
Write-Output ("{0}({1}){2}" -f $padding, $unkoWithNose, $padding)
}
5 {
# Output mouth
$unkoList = [String[]] @($unko) * [Int32] (2 * $i - 1)
$unkoList[4] = $mouth
$padding = [String] $space * [Int32] ($Height - ($i - 1))
Write-Output ("{0}({1}){2}" -f $padding, (-join $unkoList), $padding)
}
Default {
# Output unko
$repeatedUnko = [String] $unko * [Int32] (2 * $i - 1)
$padding = [String] $space * [Int32] ($Height - ($i - 1))
Write-Output ("{0}({1}){2}" -f $padding, $repeatedUnko, $padding)
}
}
}
}
<#
.SYNOPSIS
Set window title of your teminal to unko
#>
function Set-WindowTitleToUnko
{
$host.UI.RawUI.WindowTitle = (Get-UnkoDictionary).Name | Get-Random
}
<#
.SYNOPSIS
Show big unko on your terminal
#>
function Get-BigUnko
{
$base64Text = (Get-Content ./lib/bigunko.txt) -join ""
$bytes = [System.Convert]::FromBase64String($base64Text)
$unko = [System.Text.Encoding]::UTF8.GetString($bytes)
Write-Output $unko.Replace("\033", "$([char]0x1b)").Replace("\n", "")
}