View http-load-test.ps1
This file contains 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
while ($true) { $r = wget -uri "http://somesite.com?q=1" -headers @{"Accept-Tenant"="Nz"}; echo $r.Content } |
View monitor-speed.ps1
This file contains 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
# 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; |
View TestCircuitBreaker.Controllers.HomeController.cs
This file contains 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
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; |
View loading-pem-ssl-windows-workaround.cs
This file contains 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
// See https://github.com/dotnet/runtime/issues/23749 | |
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"); | |
View main.go
This file contains 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) |
View yarn-env-bars.ps1
This file contains 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
$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 | |
gatsby |
View PublicKeyCryptographyExample.cs
This file contains 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
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
namespace PublicKeyCryptographyExample | |
{ | |
// | |
// https://yetanotherchris.dev/security/public-private-key-in-netcore-by-example/ | |
// |
View quote-of-the-day.ps1
This file contains 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
wget "http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en" | Select-Object -Expand Content | ConvertFrom-Json | Select-Object quoteText, quoteAuthor |
View base64-decode-jwt.cs
This file contains 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
// Add the following nuget package for Base64Url decoding: | |
// dotnet add package Microsoft.AspNetCore.WebUtilities | |
// This example JWT is taken from jwt.io | |
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 |
View aws.sh
This file contains 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
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 |
NewerOlder