Skip to content

Instantly share code, notes, and snippets.

View ReubenBond's full-sized avatar
🌞
building

Reuben Bond ReubenBond

🌞
building
View GitHub Profile
@ReubenBond
ReubenBond / FrequencyFilter.cs
Created April 13, 2024 23:07
Filtered Space-Saving
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Orleans.Runtime.Placement.Rebalancing;
// Implementation of "Filtered Space-Saving" from "Finding top-k elements in data streams"
// by Nuno Homem & Joao Paulo Carvalho (https://www.hlt.inesc-id.pt/~fmmb/references/misnis.ref0a.pdf).
internal abstract class FrequencyFilter<TKey>(int capacity) where TKey : notnull
{
@ReubenBond
ReubenBond / ConcurrentLruGrainDirectoryCache.cs
Last active April 5, 2024 22:10
BitFaster.Caching Orleans IGrainDirectoryCache implementation
using BitFaster.Caching;
using BitFaster.Caching.Lru;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.Runtime;
using Orleans.Runtime.GrainDirectory;
using System.Diagnostics.CodeAnalysis;
namespace Orleans.BitFasterCaching.GrainDirectoryCache;
@ReubenBond
ReubenBond / ClusterManifestTemplate.xml
Last active March 29, 2024 14:27
Speedy Service Fabric Dev Cluster Upgrades
<?xml version="1.0" encoding="utf-8"?>
<!--
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
The settings used within this ClusterManifest are expressly for use only
within a developer single-box environment. Any use of these settings outside
of that environment are highly likely to produce incorrect, and misperforming
@ReubenBond
ReubenBond / LongRunningReminderGrain.cs
Created January 17, 2024 16:46
Orleans Grain Long Running Reminder
#nullable enable
using Orleans.Runtime;
namespace MyGrains;
public class MyLongRunningReminderGrain : Grain, IRemindable
{
private readonly CancellationTokenSource _shutdownCancellation = new();
private Task? _backgroundTask;
@ReubenBond
ReubenBond / CpuUsage.cs
Created January 17, 2024 16:45
.NET CPU Usage EventCounter
using System.Diagnostics.Tracing;
using System.Security.Cryptography;
using System.Text;
public class Program
{
public static void Main(string[] args)
{
var listener = new SystemRuntimeEventCounterListener();
Task.Run(async () =>
@ReubenBond
ReubenBond / Disable-AutomaticallyDetectSettings.ps1
Created November 23, 2011 01:04
Disable 'Automatically detect settings' in Internet Explorer's proxy settings dialog.
# Disable 'Automatically detect proxy settings' in Internet Explorer.
function Disable-AutomaticallyDetectProxySettings
{
# Read connection settings from Internet Explorer.
$regKeyPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\"
$conSet = $(Get-ItemProperty $regKeyPath).DefaultConnectionSettings
# Index into DefaultConnectionSettings where the relevant flag resides.
$flagIndex = 8
{
"name": "Dactyl Manuform (5x7)",
"vendorProductId": 1145910583,
"macros": [
"{KC_LCTL,KC_LEFT}",
"{KC_LCTL,KC_DOWN}",
"{KC_LCTL,KC_UP}",
"{KC_LCTL,KC_RGHT}",
"",
"",
@ReubenBond
ReubenBond / HostedServiceCommunicationListener.cs
Last active December 1, 2022 21:10
Service Fabric IHostBuilder integration
namespace YOUR_NAMESPACE
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
/// <summary>
/// Service Fabric <see cref="ICommunicationListener"/> which integrates with an <see cref="IHost"/> instance.
@ReubenBond
ReubenBond / ObserverWithReturn.csproj
Created March 20, 2022 19:36
Orleans grain observer (IGrainObserver) which returns results
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>ObserverWithReturn</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

Recommendations: