Skip to content

Instantly share code, notes, and snippets.

View andrewabest's full-sized avatar

Andrew Best andrewabest

View GitHub Profile
@andrewabest
andrewabest / Parser.cs
Created February 4, 2022 00:43
A basic function-applying token replacement implementation with Sprache
void Main()
{
var input = "Hello #{Greeting | Upper} #{Greeting | Upper}, How do you like #{DayOfWeek | Lower}";
var variables = new Dictionary<string, string>()
{
{ "Greeting", "hello" },
{ "DayOfWeek", "Wednesday" }
};
@andrewabest
andrewabest / CreateCertificateAuthorityCert.bat
Last active November 2, 2021 06:29
Create a cert authority and client certificate for development using makecert.exe
:: Courtesy of http://www.digitallycreated.net/Blog/38/using-makecert-to-create-certificates-for-development
:: To see what certificates you currently have on your PC, open MMC (Run->mmc.exe), click "File->Add/Remove Snap-in", select Certificates from the left list, click "Add". Select "My user account", which will mean the snapin will show certificates that are stored specifically for your Windows user account. Select Certificates from the list again and "Add" it, then this time select "Computer account". This snapin will show certificates belonging to the machine specifically, and will apply across all accounts. Press Finish, then OK. I suggest you Save this MMC arrangement, so you can get back to it more easily in the future (File->Save).
:: Expand "Certificates (Local Computer)\Trusted Root Certification Authorities\Certificates". This folder shows you all the Certificate Authorities that your computer trusts.
:: So now we need to create our own Certificate Authority certificate. Open the Visual Studio
@andrewabest
andrewabest / Conversion.bat
Created February 10, 2016 03:29
Convert a crt + p7b (from godaddy) to pfx
echo off
:: download OpenSSL if you don't have it for the below
:: Conver the p7b into PEM format
openssl pkcs7 -in mydomain.p7b -print_certs -out mydomain.pem
:: Combine this with the crt server certificate and private key into a PFX
openssl pkcs12 -export -in mydomain.crt -inkey mydomain.key -certfile mydomain.pem -out mydomain.pfx
@andrewabest
andrewabest / ContinuousDeploymentWithGitVersionAndGitFlow.md
Last active October 28, 2020 10:21
How to use GitVersion for semantic versioning with TeamCity and Octopus Deploy

Setting up TeamCity and Octopus with GitVersion

Assumptions

  • You are using GitFlow
  • You want to deploy a new version of your software every time a commit is made to the develop branch
  • You are using Octopack to package your application for deployment

Instructions

@andrewabest
andrewabest / create.bat
Created April 21, 2020 05:40
Creates and packages a dotnet web app for deployment testing via Octopus
dotnet new mvc --auth None -f netcoreapp3.1
dotnet build
dotnet publish
octo pack --Id=MyApp.Test --format=Zip --Version=1.0.0 --basePath=./bin/Debug/netcoreapp3.1/publish
@andrewabest
andrewabest / Startup.cs
Created February 1, 2017 06:32
Packages and Startup for WebAPI 2.2 on Owin + IIS hosting
[assembly: OwinStartup(typeof(Startup))]
namespace Api
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
@andrewabest
andrewabest / MustConformToOneOf.cs
Last active January 30, 2020 02:53
MustConformToOneOf - Strongly Typed Conventions spike
void Main()
{
typeof(NonConforming).MustConformToOneOf(new PropertyConventionSpecification[] {
new PropertiesMustHavePrivateSettersConventionSpecification(),
new PropertiesMustHavePublicSettersConventionSpecification()
});
}
public class NonConforming
{
@andrewabest
andrewabest / Notes.md
Last active January 2, 2020 10:59
Kubernetes on Windows - detangling the mess

Kubernetes on Windows

The tooling for K8s on Windows has come a long way over the last couple of years and is starting to stabilise. Minikube 'just works' and you no longer need to fight it (stopping the cluster works now, yay!).

However the tooling has also become so prolific it tends to end up in various places on your machine nested inside other tools. So lets straighten that out.

Kubectl

Windows ends up with a mess of kubectl versions kicking around - VS 2019 has its own, Docker for Windows has its own, Azure Dev Spaces has its own, you may have downloaded the MSI, you may have installed it via Chocolatey.

@andrewabest
andrewabest / readme.md
Last active December 3, 2019 13:42
Setting up GitVersion in TeamCity

Project Stuff

Firstly - we will use the CommandLine utility to do our versioning - this lets us check the versioning behaviour locally before pushing, which can be super handy!

Install-Package GitVersion.CommandLine

Then, configure gitversion

.\packages\GitVersion.CommandLine.3.5.2\tools\GitVersion.exe init

@andrewabest
andrewabest / Instructions.md
Last active November 4, 2019 09:32
Git setting up and fixing line endings

UPDATE

Step 1 & 2 are no longer enough, as git will nag about irreversable conversions regardless of you asking it to convert things.

See This issue for an explanation.

Tl;Dr: git config --global core.safecrlf false

Step 1: