Skip to content

Instantly share code, notes, and snippets.

View borland's full-sized avatar
🙃

Orion Edwards borland

🙃
View GitHub Profile
@borland
borland / gist:be26bee83d9d757da01a
Created February 14, 2016 17:41
Swift observable reachability framework which publishes values via an Observable instead of a wrapper class
//
// Reachability.swift
// iOSSwiftScratchApp
//
// Created by Orion Edwards on 15/02/16.
// Copyright © 2016 Orion Edwards. All rights reserved.
//
import Foundation
import SystemConfiguration
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
public class Program
{
static readonly string jsonExample = @"
{
""intValue"": 1,
class SingletonList<T> : IEnumerable<T>, IEnumerator<T>
{
[ThreadStatic]
static readonly SingletonList<T> TransientInstance = new SingletonList<T>();
public static SingletonList<T> Create(T value) => new SingletonList<T> { Value = value };
public static SingletonList<T> Transient(T value)
{
TransientInstance.Value = value;
#! /bin/bash
get_and_unzip () {
# package_name is
local URL="$1/$2/$2-$3.zip"
curl -s -o "$2.zip" "$URL"
unzip "$2.zip"
rm "$2.zip"
}
@borland
borland / AspnetCoreKdlConfiguration.cs
Created January 14, 2021 06:01
Experimental code for configuring an ASP.NET Core app using KDL rather than JSON
// NOTE: This requires you to have a reference to KDL for .NET, and import the kdl-net namespace
// https://github.com/borland/kdl-net
//
// Highly experimental, but it works.
//
// NOTE: Once you have this code in your project, you can use
//
// var config = new ConfigurationBuilder()
// .AddKdlFile("appsettings.kdl", optional: false, reloadOnChange: false)
//
@borland
borland / CertificateSigningService.cs
Created January 14, 2021 07:30
Given a public key, create a signed certificate tied back to a certificate authority; .NET Core using BouncyCastle
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Operators;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.X509;
using System;
using System.Diagnostics;
using System.Linq;