Skip to content

Instantly share code, notes, and snippets.

Avatar
🔏

Chris S. yetanotherchris

🔏
View GitHub Profile
@yetanotherchris
yetanotherchris / loading-pem-ssl-windows-workaround.cs
Created Dec 26, 2020
Loading PEM SSL certificates in Kestrel (Windows work-around)
View loading-pem-ssl-windows-workaround.cs
// 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 Nov 27, 2020
Quote of the day in Go Lang (playing with Go for the first time)
View main.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@yetanotherchris
yetanotherchris / yarn-env-bars.ps1
Last active Nov 21, 2020
Solution to yarn global add does not work on Windows (command not found)
View yarn-env-bars.ps1
$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 Nov 13, 2020
Public key cryptography by example in .NET Core
View PublicKeyCryptographyExample.cs
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 Nov 3, 2020
Quote of the day Powershell script
View quote-of-the-day.ps1
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 Sep 15, 2020
Base64 decode a JWT in C# .NET Core
View base64-decode-jwt.cs
// 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 Aug 3, 2020
A few AWS command lines
View aws.sh
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 Sep 19, 2019
Vue JS with ASP.NET Core - basic example
View vue-js-net-core.md

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 Sep 8, 2019
Deconstructing views/components/services needed in Roadkill V3
View roadkill-ui-notes.md

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
@yetanotherchris
yetanotherchris / git.sh
Created Jun 26, 2019
visualise github branch history
View git.sh
git log --oneline --graph --decorate --all