Skip to content

Instantly share code, notes, and snippets.

Drinking refreshing JWT tokens

Chris S. yetanotherchris

Drinking refreshing JWT tokens
View GitHub Profile
yetanotherchris / DynamoDbRepositoryTests.cs
Created Oct 17, 2018
Integration testing DynamoDB withamazon/dynamodb-local on Docker
View DynamoDbRepositoryTests.cs
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
using AutoFixture;
using Shouldly;
using Xunit;
namespace SomeTests
yetanotherchris / replace-service-in-servicecollection.cs
Created Oct 9, 2018
Replace type in ServiceCollection for testing
View replace-service-in-servicecollection.cs
public static class ServiceExtensions
public static ServiceCollection ReplaceWithFake<T>(this ServiceCollection services) where T : class
T fake = Substitute.For<T>();
var descriptor = new ServiceDescriptor(typeof(T), fake.GetType(), ServiceLifetime.Scoped);
return services;
yetanotherchris / OptionsExtension.cs
Last active Sep 12, 2018
IOptions extension method to bind both IOptions<T> and T as a singleton
View OptionsExtension.cs
public static class OptionsExtensions
public static IServiceCollection ConfigureOptionsAndInstance<T>(this IServiceCollection services, IConfigurationSection section)
where T : class, IOptions<T>, new()
services.AddSingleton<T>(provider => provider.GetService<IOptions<T>>().Value);
return services;
# All commit history, e.g. "[2018-04-15 12:39:15 +0100] Chris S. A bit more readme"
git log --pretty=format:'[%ai] %an. %s' --abbrev-commit > commits.txt
# 5 commits
git log --pretty=format:'[%ai] %an. %s' --abbrev-commit -5 > commits.txt
yetanotherchris /
Created Aug 1, 2018
Converting NUnit to XUnit
  • Get VS Code
  • Remove using NUnit.Framework;
  • Add using XUnit;
  • Replace all [Test] with [Fact]
  • Replace [SetUp] with a constructor
  • Replace Assert.That(actualValue, Is.EqualTo(value)); with Assert.Equal(expected, actual)
    • highlight Is.EqualTo(
    • Delete it
    • Select to the end of the line
    • Ctrl + X
yetanotherchris / create-user-and-database.sql
Created Jul 31, 2018
Create a Postgres user and database through the command line, using psql.exe
View create-user-and-database.sql
psql -c "create database roadkill;" -U postgres
psql -c "CREATE USER roadkill WITH PASSWORD 'secretpassword';" -U postgres
psql -c "ALTER USER roadkill WITH SUPERUSER;" -U postgres
yetanotherchris / appsettings.json
Last active May 27, 2018
.NET Core Examples: configuration binding and appsetting.json
View appsettings.json
"Smtp": {
"Host": "",
"Port": 587,
"UseSSL": true,
"Username": "bob",
"Password": "password",
yetanotherchris / install-vs-and-docker.ps1
Created Oct 27, 2017
Install Docker and Visual Studio 2017
View install-vs-and-docker.ps1
Set-ExecutionPolicy RemoteSigned -Confirm:$false -Force
iex ((new-object net.webclient).DownloadString(''))
# Stop prompting in Chocolately
choco feature enable -n allowGlobalConfirmation
choco install visualstudio2017community; choco install visualstudio2017-workload-netcoretools; choco install visualstudio2017-workload-netweb; choco install docker-for-windows;
yetanotherchris / install.ps1
Last active Oct 21, 2017
Installation script for tools running inside a Visual Studio 2017 VM on Azure
View install.ps1
# Check for admin
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent())
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $false)
Write-Error "Please run this scripts as an administrator"
exit 1
Set-ExecutionPolicy RemoteSigned -Confirm:$false -Force
iex ((new-object net.webclient).DownloadString(''))
yetanotherchris / whatsapp.linq
Last active Oct 20, 2017
WhatsApp message statistics. Needs LinqPad to run.
View whatsapp.linq
<Query Kind="Program">
// Open a chat, click "..." and email to yourself (no media)
void Main()
var messages = new List<Message>();
string file = File.ReadAllText(@"/wapp.txt"); // c:\wapp.txt
You can’t perform that action at this time.