Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
馃攺
;每每每每rules

Chris S. yetanotherchris

馃攺
;每每每每rules
View GitHub Profile
@yetanotherchris
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
yetanotherchris / loading-pem-ssl-windows-workaround.cs
Created December 26, 2020 16:00
Loading PEM SSL certificates in Kestrel (Windows work-around)
// 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");
@yetanotherchris
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 (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@yetanotherchris
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
gatsby
@yetanotherchris
yetanotherchris / PublicKeyCryptographyExample.cs
Last active March 3, 2025 07:12
Public key cryptography by example in .NET Core
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/
//
@yetanotherchris
yetanotherchris / quote-of-the-day.ps1
Created November 3, 2020 10:14
Quote of the day Powershell script
wget "http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en" | Select-Object -Expand Content | ConvertFrom-Json | Select-Object quoteText, quoteAuthor
@yetanotherchris
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 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
@yetanotherchris
yetanotherchris / aws.sh
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
@yetanotherchris
yetanotherchris / vue-js-net-core.md
Last active December 21, 2023 18:18
Vue JS with ASP.NET Core - basic example

Vue JS with ASP.NET Core

These notes come with much appreciation from Packt's ASP.NET Core 2 and Vue.js, adapted for my use.

.NET Core currently (2.2) only ships with a React and Angular project template. There is a Vue one but it uses Typescript and for some unknown reason doesn't compile when you perform a "dotnet run".

Install the dotnet template

  • dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
  • dotnet new vue
@yetanotherchris
yetanotherchris / roadkill-ui-notes.md
Created September 8, 2019 16:48
Deconstructing views/components/services needed in Roadkill V3

This is based off the UI of Roadkill v2, with no new functionality or design.

Editor view

Global UI elements

These options could be in a hamburger bar:

  1. Page last edited by ____ on _____
  2. Page info dialog - added by + on, last edit by + on, title, tags, dates