Skip to content

Instantly share code, notes, and snippets.

View analogrelay's full-sized avatar
💖

Ashley Stanton-Nurse analogrelay

💖
View GitHub Profile
@analogrelay
analogrelay / AnalogTerm.itermcolors
Created October 17, 2022 19:21
AnalogTerm Color Scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.12156862765550613</real>
@analogrelay
analogrelay / ruby_oddities.rb
Last active March 29, 2021 18:29
Ruby Pop Quiz
names = [ "aaron", "abbot", "betty", "brian" ]
def starts_with_a(name)
return name.start_with? "a"
end
puts "filtering"
def filter_by_method(a)
a.select { |n| starts_with_a n }
@analogrelay
analogrelay / AzureFunctionsLoggingProvider.cs
Last active August 14, 2018 16:08
Azure Functions Logging Provider
public static class AzureFunctionsLoggerBuilderExtensions
{
public static void AddAzureFunctions(this ILoggingBuilder logging, TraceWriter writer)
{
logging.Services.AddSingleton(writer);
logging.Services.AddSingleton<ILoggerProvider, AzureFunctionsLoggerProvider>();
}
}
public class AzureFunctionsLoggerProvider : ILoggerProvider
@analogrelay
analogrelay / CommandLineException.cs
Last active March 22, 2024 11:50
My Command Line Template
using System;
using System.Runtime.Serialization;
namespace MyTool
{
[Serializable]
internal class CommandLineException : Exception
{
public CommandLineException()
{
@analogrelay
analogrelay / EventSourcesAndCountersOhMy.md
Last active September 13, 2021 07:58
EventSource/EventCounters patterns
@analogrelay
analogrelay / SampleMetric.cs
Last active September 19, 2017 20:57
Sample IMetric implementation for aggregated data.
using Microsoft.Extensions.Logging;
namespace MetricsSample
{
internal class SampleMetric : IMetric
{
private object _lock = new object();
private int _count;
private double _sum;
@analogrelay
analogrelay / DynamicHubSketch.cs
Last active June 14, 2017 03:26
Hub<anything>
// Treat Client Proxies kinda like Formatters; Hub<T> just tries to get an IClientProxyFactory<T> from DI and invokes it.
// We provide one for `dynamic` and another that can be registered as an open-generic and generated code at runtime.
// Users can provide custom implementations for anything.
public interface IClientProxy {
Task InvokeAsync(string method, params object[] args);
}
public interface IClientProxyFactory<T> {
T CreateProxy(IClientProxy proxy); // <-- may need some caching logic
@analogrelay
analogrelay / ReadAtLeastAsync.cs
Created September 27, 2016 23:49
ReadAtLeastAsync Helper
using System.Threading;
using System.Threading.Tasks;
using Channels;
namespace Microsoft.Extensions.WebSockets.Internal
{
public static class ChannelExtensions
{
public static ValueTask<ReadableBuffer> ReadAtLeastAsync(this IReadableChannel input, int minimumRequiredBytes) => ReadAtLeastAsync(input, minimumRequiredBytes, CancellationToken.None);
@analogrelay
analogrelay / .gitignore
Created August 31, 2016 21:30
WebSocket Repro Client
node_modules/
@analogrelay
analogrelay / WebsocketDecoder.ts
Last active December 4, 2017 20:51
WebSocket Decoder Script
document.writeln('<input style="width: 600px" id="hexcode" type="text" placeholder="hex values" />');
document.writeln('<button onclick="decode()">Decode</button>');
document.writeln('<div id="result" />');
var opcodes = [
'Continuation',
'Text',
'Binary',
'RESERVED',
'RESERVED',