Skip to content

Instantly share code, notes, and snippets.

View SeidChr's full-sized avatar

Christian Seidlitz SeidChr

View GitHub Profile
@SeidChr
SeidChr / ws.ps1
Created March 19, 2021 14:57 — forked from byt3bl33d3r/ws.ps1
Async Websocket PowerShell client (producer/consumer pattern)
<#
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]'
@SeidChr
SeidChr / Write-Gradient.ps1
Last active February 4, 2021 21:04
Powershell Console Gradient Foreground
# 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
param(
[string[]] $videoId,
[switch] $setup,
[double] $trimPercentage = 0.015
)
function Ensure-Path
{
param([string]$Path)
if (!(Test-Path $Path)) {
@SeidChr
SeidChr / Set-VpnStatus.ps1
Created May 8, 2020 08:38
Connecting or disconnecting on a windows-based vpn (rasdial) with notification messages
param(
$vpnName,
[ValidateSet("Connect", "Disconnect")]
[string]
$action
)
switch ($action) {
"Disconnect" {
$vpn = Get-VpnConnection -Name $vpnName
@SeidChr
SeidChr / Set-SlackStatus.ps1
Last active October 24, 2023 11:48
Set Slack Status via Powershell
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'
@SeidChr
SeidChr / vpndisconnect.ps1
Created March 18, 2020 20:42
windows based vpn automatic reconnect
param($vpnName)
rasdial $vpnName /disconnect