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
| function Set-GitChanges { | |
| gaa | |
| gcam Staging | |
| ggp | |
| } | |
| Import-Module posh-git | |
| Import-Module git-aliases -DisableNameChecking | |
| Set-Alias -Name stage -Value Set-GitChanges |
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
| # PS> 20 | Get-RandomString -Alphanumeric $false -NoQuotes $true | |
| # PS> p({BFhlH*}KG#S{i{Ih5 | |
| function Get-RandomString { | |
| [OutputType([string])] | |
| param( | |
| [Parameter(Mandatory, ValueFromPipeline)] [int] $Length, | |
| [bool] $Alphanumeric = $true, | |
| [bool] $NoQuotes = $false | |
| ) |
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
| function Require-AzCliVersion { | |
| [OutputType([void])] | |
| param( | |
| [Parameter(Mandatory, ValueFromPipeline)] [ValidatePattern("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,9}$")] [string] $Version, | |
| [switch] $Fail | |
| ) | |
| $actual = ('az version' | Invoke-Expression | ConvertFrom-Json).'azure-cli' | |
| if ($actual -eq $Version) { | |
| "Azure CLI present in pinned version $Version" | Write-Verbose | |
| } else { |
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
| $tenantId = 'your_tenant_id' | |
| $clientId = 'your_client_id' | |
| $clientSecret = 'your_client_secret' | |
| $tokenResponse = (Invoke-WebRequest -Uri "https://login.microsoftonline.com/$tenantId/oauth2/token" ` | |
| -Method Post -UseBasicParsing ` | |
| -Body "grant_type=client_credentials&client_id=$clientId&client_secret=$clientSecret").Content | |
| "$(($tokenResponse | ConvertFrom-Json).access_token)`n" | Write-Host |
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
| [CmdletBinding()] | |
| param () | |
| Set-StrictMode -Version Latest | |
| $verbose = if ($PSBoundParameters.ContainsKey('Verbose')) { | |
| $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent } else { $false } | |
| "Verbose enabled: $verbose" | Write-Host |
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
| // inspired by https://www.youtube.com/watch?v=RWyZkNzvC-c&t=553s | |
| // $ dotnet fsi chaos.fsx | |
| // latency test | |
| // 0.919409 | |
| open System | |
| open System.Threading | |
| let chaos (name:string) (shouldChaos:unit -> bool) (chaos:unit -> unit) (service:unit -> 't) = | |
| if shouldChaos () then | |
| printfn "%s" name |
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
| // inspired by https://www.youtube.com/watch?v=RWyZkNzvC-c&t=553s | |
| // $ dotnet fsi chaos2.fsx | |
| // latency test | |
| // 0.969491 | |
| open System | |
| open System.Threading | |
| let chaos (name:string) (shouldChaos:unit -> bool) (chaos:unit -> unit) = | |
| fun (service:unit -> 't) -> | |
| if shouldChaos () then |
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
| // inspired by https://www.youtube.com/watch?v=RWyZkNzvC-c&t=553s | |
| // $ dotnet fsi chaos3.fsx | |
| // latency test | |
| // 0.490776 | |
| open System | |
| open System.Threading | |
| let chaosAsync (name:string) (shouldChaosAsync:unit -> Async<bool>) (chaosAsync:unit -> Async<unit>) = | |
| fun (serviceAsync:unit -> Async<'t>) -> | |
| async { |
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
| $aiAppId = '00000000-0000-0000-0000-000000000000' | |
| $aiApiKey = 'ehzgdrES4kBJNCuRUzcBfkuka5CGWkAr4hyhJ6y3' | |
| $result = Invoke-RestMethod -Uri "https://api.applicationinsights.io/v1/apps/$aiAppId/query" ` | |
| -Method Post -UseBasicParsing ` | |
| -Headers @{ | |
| 'x-api-key' = $aiApiKey | |
| 'content-type' = 'application/json' | |
| } ` | |
| -Body '{"query": "traces | where timestamp <= ago(1m) | limit 10"}' |
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
| @echo off | |
| setlocal enabledelayedexpansion | |
| ::Batch script to compare a file SHA256 checksum to a given one. | |
| ::Usage: checksum [FILE] [VALUE] | |
| set filepath=%1 | |
| set checksum=%2 | |
| set idx=0 |