Skip to content

Instantly share code, notes, and snippets.

using Ical.Net;
using Ical.Net.DataTypes;
public class ToText {
private static readonly string[] MonthNames = {
"January",
"February",
"March",
"April",
"May",
@paviad
paviad / SpawnAndWait.cs
Created September 8, 2021 17:25
How to spawn a process and consume standard output and error without hanging
var process = Process.Start(processStartInfo);
var stdErr = process.StandardError;
var stdOut = process.StandardOutput;
var resultAwaiter = stdOut.ReadToEndAsync();
var errResultAwaiter = stdErr.ReadToEndAsync();
await process.WaitForExitAsync();
@paviad
paviad / kb.md
Last active September 6, 2020 10:13
Angular, SSR, IdentityServer4, Identity and Web Api tips

Web + Auth + Api using IdentityServer4

Important Notes

  1. The authentication scheme name is stored in the cookie, so it must match between apps.
  2. With AddAuthentication() only the default scheme is used, regardless of how many schemes you register, unless you...
  3. Customize AddAuthorization() to consider themes other than the default. See the docs
  4. You can also use a forward selector in the default scheme to determine if another scheme needs to be used (but that's not usually the case), see this
  5. When using identity with identityserver replace IdentityServerConstants.ExternalCookieAuthenticationScheme with IdentityConstants.ExternalScheme globally, because that's what identity uses. See the first note [here](https://identityserver4.readthedocs.io/en/aspnetcore1/quickstarts/4_external_authenti
@paviad
paviad / also-log-json.js
Created August 16, 2020 14:23
Monkey-patch `console.log` to print JSON versions of objects
var ___console_log = console.log;
var ___seen = [];
var ___skipCycles = (key, val) => {
if (val != null && typeof val == 'object') {
if (___seen.indexOf(val) >= 0) {
return;
}
___seen.push(val);
}
return val;
@paviad
paviad / get-service-principal.cmd
Created July 7, 2019 10:24
Azure get service principal for ad client
az ad sp list --query "[?displayName=='%1'].{appId:appId,displayName:displayName,objectId:objectId}" --all