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
<# | |
References: | |
- https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket?view=netframework-4.5 | |
- https://github.com/poshbotio/PoshBot/blob/master/PoshBot/Implementations/Slack/SlackConnection.ps1 | |
- https://www.leeholmes.com/blog/2018/09/05/producer-consumer-parallelism-in-powershell/ | |
#> | |
$client_id = [System.GUID]::NewGuid() | |
$recv_queue = New-Object 'System.Collections.Concurrent.ConcurrentQueue[String]' |
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
# https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences | |
function Gradient { | |
param( | |
[string] $Start, | |
[string] $End, | |
[double] $Grade, | |
[string] $Text | |
) | |
$marker = [char]27 |
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
param( | |
[string[]] $videoId, | |
[switch] $setup, | |
[double] $trimPercentage = 0.015 | |
) | |
function Ensure-Path | |
{ | |
param([string]$Path) | |
if (!(Test-Path $Path)) { |
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
param( | |
$vpnName, | |
[ValidateSet("Connect", "Disconnect")] | |
[string] | |
$action | |
) | |
switch ($action) { | |
"Disconnect" { | |
$vpn = Get-VpnConnection -Name $vpnName |
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
param($token, $statusText, $emojiCode) | |
$baseUri = 'https://slack.com/api/users.profile.set' | |
$json = '{"status_text":"'+$statusText+'","status_emoji":"'+$emojiCode+'","status_expiration":0}' | |
$jsonEncoded = [uri]::EscapeDataString($json) | |
$uri = $baseUri + "?token=$token&profile=$jsonEncoded" | |
Invoke-WebRequest -Method Post -Uri $uri | Out-Null | |
param($statusText, $emojiCode) | |
$baseUri = 'https://slack.com/api/users.profile.set' |
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
param($vpnName) | |
rasdial $vpnName /disconnect |
NewerOlder