Skip to content

Instantly share code, notes, and snippets.

🎯
Lookin' for code in all the wrong places

Brandon Olin devblackops

🎯
Lookin' for code in all the wrong places
Block or report user

Report or block devblackops

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SlackWebSocketReceive.ps1
[cmdletbinding()]
param()
function Connect-SlackRtm {
[cmdletbinding()]
param(
[string]$Token
)
$loginData = @{}
@devblackops
devblackops / SlackRtmTlsBugRepo.ps1
Created Mar 5, 2020
Minimal reproduction of connecting to Slack's RTM websocket API to receive messages
View SlackRtmTlsBugRepo.ps1
[cmdletbinding()]
param()
function Connect-SlackRtm {
[cmdletbinding()]
param(
[string]$Token
)
$loginData = @{}
@devblackops
devblackops / tf_plan.txt
Created Jan 15, 2020
Azure Front Door Terraform plan output
View tf_plan.txt
# azurerm_frontdoor.fd will be created
+ resource "azurerm_frontdoor" "fd" {
+ cname = (known after apply)
+ enforce_backend_pools_certificate_name_check = true
+ id = (known after apply)
+ load_balancer_enabled = true
+ location = "eastus"
+ name = "XXXXX-fd1"
+ resource_group_name = "tf_XXXXX"
@devblackops
devblackops / TrackChromeUsage.ps1
Last active Dec 12, 2019
Track Chrome processes for graphing at the console.
View TrackChromeUsage.ps1
# Put these functions in the profile.ps1 to start and stop Chrome usage tracking.
# Display your Chrome usage by running "Show-ChromeUsage"
# Track Chrome usage
function Start-ChromeUsageTracking {
$job = Start-Job -Name ChromeTracker -ScriptBlock {
while ($true) {
$now = [datetime]::Now.ToString('s')
$tabs = (Get-Process chrome -ErrorAction SilentlyContinue).Count
$log = Join-Path ([IO.Path]::GetTempPath()) 'chrome_usage.csv'
View AzureAD_pwsh_repro.ps1
$tenant = '<tenant-id>'
$subscription = '<subscription-id>'
$clientId = '<client-id>'
$clientSecret = '<client-secret>'
# Log into Azure w/ Service Principal
$creds = [pscredential]::new($clientId, ($clientSecret | ConvertTo-SecureString -AsPlainText -Force))
Connect-AzAccount -TenantId $tenant -SubscriptionId $subscription -Credential $creds -ServicePrincipal > $null
# Get auth token
@devblackops
devblackops / rate_limiting_notice.ps1
Last active Jul 16, 2019
PoshBot middlware hook to notify chatty people in a Slack channel to use threaded conversations if they post too many messages in a short time interval
View rate_limiting_notice.ps1
<#
.SYNOPSIS
Suggest Slack threads for talkative users.
.DESCRIPTION
This middleware tracks how many messages (x) users send per (y) amount of time.
If a user goes over the threshold, we'll send a message suggesting that Slack threads should be used.
.NOTES
Based on https://stackoverflow.com/questions/667508/whats-a-good-rate-limiting-algorithm
#>
param(
@devblackops
devblackops / redalert.ps1
Last active Mar 25, 2020
Display highly visible notification if the last command failed in the Microsoft Terminal using PowerShell
View redalert.ps1
# Put this code in your PowerShell profile script
# This requires the MSTerminalSettings module which you can download with:
# Install-Module MSTerminalSettings -Scope CurrentUser -Repository PSGallery
Import-Module MSTerminalSettings
$msTermProfileName = 'pwsh' # Replace with whatever Terminal profile name you're using
$msTermProfile = Get-MSTerminalProfile -Name $msTermProfileName
$script:bombThrown = $false
function prompt {
if ($? -eq $false) {
@devblackops
devblackops / Get-MostCommonCommands.ps1
Created Jun 13, 2019
Get your most common PowerShell commands by inspecting your PSReadLine history
View Get-MostCommonCommands.ps1
$err=$null
[System.Management.Automation.PSParser]::Tokenize((Get-Content (Get-PSReadLineOption).HistorySavePath),[ref]$err) |
Where-Object {$_.type -eq 'command'} |
Select-Object Content | Group-Object Content |
Sort-Object Count, Name -Descending | Select-Object Count, Name -First 20
@devblackops
devblackops / gist:f8523fda1631b6b64de50ed89293d218
Created Apr 3, 2019
Terraform plan fails when Azure resource group has a ReadOnly management lock on it
View gist:f8523fda1631b6b64de50ed89293d218
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
random_string.stg_name: Refreshing state... (ID: none)
azurerm_resource_group.rsg: Refreshing state... (ID: /subscriptions/af5751f7-5e57-4492-a2cc-e8618f11110d/resourceGroups/scratch)
azurerm_storage_account.standard-storage: Refreshing state... (ID: /subscriptions/0f553e2c-4844-4a0f-bd62-...orage/storageAccounts/hnzj1vqqbqiaqli8)
Error: Error refreshing state: 1 error(s) occurred:
@devblackops
devblackops / prompt.ps1
Last active Aug 6, 2019
My basic prompt
View prompt.ps1
Import-Module posh-git
function prompt {
# The status of the last command run
$lastSuccess = $?
# Colors for prompt
$color = @{
Reset = "`e[0m"
Red = "`e[31;1m"
Green = "`e[32;1m"
You can’t perform that action at this time.