Skip to content

Instantly share code, notes, and snippets.

View cilliemalan's full-sized avatar

Cillié Malan cilliemalan

View GitHub Profile
@cilliemalan
cilliemalan / minecraft.sh
Last active May 30, 2016 07:45
MSM init script for amazon linux
#!/bin/bash
# My script for provisioning a minecraft server
#
# wget -O - https://git.io/vrQol | bash
sudo yum -y update
# Download the default config file, update the user ID, and also add the -server switch which the MSM guys omitted\
sudo wget http://git.io/6eiCSg -O /etc/msm.conf
@cilliemalan
cilliemalan / Startup.Security.cs
Created July 14, 2016 08:49
A better load balancer HTTPS redirect
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Whatevs
{
@cilliemalan
cilliemalan / Server.md
Last active September 9, 2016 14:55
Creating ASP.Net Web API /w C# client

How to make an API Server

Step 1: New Project

Go to File -> New Project And create a Web Project:

img

Select Web API

img

@cilliemalan
cilliemalan / Coffee.md
Last active June 1, 2017 11:39
Rabbit Coffee Etiquette

Rabbit Coffee Etiquette

  • The Bottomless Pot—Whenever someone drinks the last Cup, he or she shall be held liable for making the next brew without delay.
  • Honour the Line—When one seeks brew but the elixir is not yet ready, the Cup shall be placed in the Line. The line shall be respected at all times. When the brew is ready the Cups in the line shall receive a full measure of bitter brew before those who come thereafter.
  • Four spoons—Four not excessively but nonetheless unmistakably heaped spoons. Weak coffee cannot be tolerated.
  • Sweet Italian—None but the timeless Sweet Italian Blend may pervade the percolator. The machine shall not be defiled by a lesser brew.
  • Always Hot—No brewed pot shall be allowed to cool. Turn on the top burner when placing a pot there.
  • Separation of the Stirrers—The weak spoon shall not share a receptacle with the mighty one. (put the milk spoon in the milk spoon holder and the non-milk spoon in the other one).
  • The Cup is Sacred—Each tru

OAuth server-server authentication

In order to communicate to a web service that has OAuth authentication, one may use the following procedures. Note that this is only for server to server communication on a service account. This is not for making calls on behalf of a client. So scopes and claims are typically not relevant in this context.

Authentication happens in two steps:

  • Getting a token
  • Making calls with that token
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace DataProcessorTemplate
{
/// <summary>
/// Program that counts the number of lines in which each word occurs.
@cilliemalan
cilliemalan / digest.js
Created May 15, 2017 11:36
how to digest a PEM key
/**
* returns a base64url based digest of a PEM file
* @param {*} key
*/
function digestKey(key) {
let meat = key.match(/^-{5}[A-Z ]+-{5}[\r\n]{1,2}([a-zA-Z0-9/+\r\n]+={0,3})[\r\n]{1,2}-{5}[A-Z ]+-{5}/)[1];
if (!meat) throw "unrecognized format";
meat = meat.replace(/[\r\n]{1,2}/g, '');
var buf = Buffer.from(meat, 'base64');
@cilliemalan
cilliemalan / LICENSE
Last active December 12, 2017 06:48
C++ base project
Copyright 2017 Cillié Malan
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
public class MyBackgroundService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// run until stoppingToken is cancelled???
}
}
public class MyBackgroundService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// run until stoppingToken is cancelled???
}
}