Skip to content

Instantly share code, notes, and snippets.

View JamesRandall's full-sized avatar

James Randall JamesRandall

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AzureFromTheTrenches.Commanding;
using AzureFromTheTrenches.Commanding.Abstractions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@JamesRandall
JamesRandall / BlobStorageMultipartStreamProvider.cs
Last active March 19, 2020 23:12
Azure Blob Container Web API Image Upload
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
@JamesRandall
JamesRandall / RedBlackTree.cs
Last active December 3, 2022 19:45
Red-Black Tree Implementation in C#
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace OpinionatedCode.Collections
{
public sealed class RedBlackTree<TKey, TValue>
{
private readonly RedBlackTreeNode<TKey, TValue> _leaf = RedBlackTreeNode<TKey, TValue>.CreateLeaf();
@JamesRandall
JamesRandall / RedirectNewtonsoftJson.ps1
Last active May 2, 2023 13:39
Powershell binding redirection
# Load your target version of the assembly
$newtonsoft = [System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll")
$onAssemblyResolveEventHandler = [System.ResolveEventHandler] {
param($sender, $e)
# You can make this condition more or less version specific as suits your requirements
if ($e.Name.StartsWith("Newtonsoft.Json")) {
return $newtonsoft
}
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies()) {
if ($assembly.FullName -eq $e.Name) {
@JamesRandall
JamesRandall / HttpEventListener.cs
Last active August 16, 2023 10:32
Http Tracing in .net
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Globalization;
namespace HttpTracing
{
public class HttpEventListener : EventListener
{