Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar

Chris S. yetanotherchris

View GitHub Profile
yetanotherchris / http-load-test.ps1
Created March 30, 2022 08:34
Powershell HTTP "load testing" (about 3-5 RPS)
while ($true) { $r = wget -uri "" -headers @{"Accept-Tenant"="Nz"}; echo $r.Content }
yetanotherchris / monitor-speed.ps1
Created March 14, 2022 15:08
Monitor internet speed test in Powershell
# choco install -y jq
# npm install --global fast-cli
while ($true)
$now = date;
$dateRow = $now.ToString("dd-MM-yyyy HH:mm");
$dl = fast -u --json | jq '.downloadSpeed';
echo "$dateRow, $dl" >> data.txt;
yetanotherchris / TestCircuitBreaker.Controllers.HomeController.cs
Last active August 21, 2021 14:16
Polly CircuitBreaker, Retry and Timeout configuration example for HttpClient and HttpClientFactory
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using TestCircuitBreaker.Models;
yetanotherchris / loading-pem-ssl-windows-workaround.cs
Created December 26, 2020 16:00
Loading PEM SSL certificates in Kestrel (Windows work-around)
// See
public static class CertHelper
// To generate a self-signed cert:
// dotnet dev-certs https -ep $pwd/selfsigned.pem --format Pem -np
public static X509Certificate2 GetCertificate()
X509Certificate2 sslCert = CreateFromPublicPrivateKey("certs/selfsigned.pem", "certs/selfsigned.key");
yetanotherchris / main.go
Last active November 27, 2020 17:44
Quote of the day in Go Lang (playing with Go for the first time)
package main
import (
yetanotherchris / yarn-env-bars.ps1
Last active November 21, 2020 15:18
Solution to yarn global add does not work on Windows (command not found)
$yarnPath = & yarn global bin
$path = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("PATH", "$path;$yarnPath", [System.EnvironmentVariableTarget]::User)
# Your yarn path should appear at the end of the path now
[System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
# Try a global command, for example gatsby. If you're using Visual Studio Code, you'll need to restart the IDE
yetanotherchris / PublicKeyCryptographyExample.cs
Last active January 12, 2023 09:25
Public key cryptography by example in .NET Core
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace PublicKeyCryptographyExample
yetanotherchris / quote-of-the-day.ps1
Created November 3, 2020 10:14
Quote of the day Powershell script
wget "" | Select-Object -Expand Content | ConvertFrom-Json | Select-Object quoteText, quoteAuthor
yetanotherchris / base64-decode-jwt.cs
Last active September 15, 2020 14:25
Base64 decode a JWT in C# .NET Core
// Add the following nuget package for Base64Url decoding:
// dotnet add package Microsoft.AspNetCore.WebUtilities
// This example JWT is taken from
string jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
string[] parts = jwt.Split('.');
foreach (string section in parts)
// The final (3rd) section is the JWT signature, so will appear as nonsense as it isn't JSON
yetanotherchris /
Created August 3, 2020 12:03
A few AWS command lines
aws s3api create-bucket --bucket MYBUCKET --create-bucket-configuration LocationConstraint=eu-west-1
aws s3api put-object --bucket MYBUCKET --key myfile.txt --body .\myfile.txt
aws dynamodb create-table --table-name {YOURTABLE} &
--attribute-definitions AttributeName={SOME-STRING-ID},AttributeType=S AttributeName={SOME-NUMBER-ID},AttributeType=N &
--key-schema AttributeName={SOME-STRING-ID},KeyType=HASH AttributeName={SOME-NUMBER-ID},KeyType=RANGE &
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5