Skip to content

Instantly share code, notes, and snippets.

View Aaronontheweb's full-sized avatar
🚀
Shipping!

Aaron Stannard Aaronontheweb

🚀
Shipping!
View GitHub Profile
@Aaronontheweb
Aaronontheweb / genericparent.cs
Last active July 5, 2024 18:32
GenericChildPerEntityParent Actor
// -----------------------------------------------------------------------
// <copyright file="GenericChildPerEntityParent.cs" company="Akka.NET Project">
// Copyright (C) 2015-2023 .NET Petabridge, LLC
// </copyright>
// -----------------------------------------------------------------------
using Akka.Actor;
using Akka.Cluster.Sharding;
namespace Sdkbin.NuGet.Actors.Utility;
@Aaronontheweb
Aaronontheweb / grafana-loadbalancer.yaml
Last active June 13, 2024 14:02
MicroK8s observability load balancers
apiVersion: v1
kind: Service
metadata:
name: grafana-loadbalancer
namespace: observability
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: grafana
ports:
@Aaronontheweb
Aaronontheweb / configure-docker-drives.sh
Last active June 12, 2024 16:23
Raspberry PI External SSD Scripts
#!/bin/bash
# create the docker data drive
mkdir /mnt/docker-base
# allow the root service account, which docker runs as, to own this directory and have write permissions
chown -R root:root /mnt/docker-base
chmod 701 /mnt/docker-base
# create a `daemon.json` file for the docker runtime
@Aaronontheweb
Aaronontheweb / spec.md
Last active June 10, 2024 19:09
Technical Spec Template

Engineering Spec

💡 Use this template to help structure new engineering projects into specifications. Make sure you attach this spec to the right project - if it’s not a flagship technology then it goes under "Other Projects"

Abstract

Problem statement - what is the nature of the issue we’re going to try to solve with this specification?

@Aaronontheweb
Aaronontheweb / HOWTO.md
Last active June 6, 2024 19:23 — forked from ramonsmits/HOWTO.md
Install .NET 8 on Raspberry pi
@Aaronontheweb
Aaronontheweb / Program.cs
Created April 12, 2024 13:23
Akka.NET - Deleting Older Snapshots in Akka.Persistence actors that ONLY use the SnapshotStore
async Task Main()
{
var actorSystem = ActorSystem.Create("Sys");
var persistentActor = actorSystem.ActorOf<ExamplePersistentActor>("exampleActor");
var watch = persistentActor.WatchAsync();
// Sending multiple "save" commands to create snapshots
persistentActor.Tell("save-1");
await Task.Delay(TimeSpan.FromSeconds(1)); // spacing out snapshots, time-wise
@Aaronontheweb
Aaronontheweb / docker-compose.yml
Created March 8, 2024 19:21
Jaeger docker compose
version: '3.7'
services:
jaeger:
image: jaegertracing/all-in-one:1.55
hostname: jaeger
restart: always
ports:
- '16686:16686'
- '5775:5775/udp'
@Aaronontheweb
Aaronontheweb / projections.cs
Last active March 5, 2024 16:08
Read Journal Provider
Command<ProjectionStarting>(_ =>
{
// TODO: seeing multiple of these being logged, which makes me think there's a problem with our Akka.Streams graph
_log.Info("Projection for Tag [{0}] is starting from Offset [{1}] - instance [{2}] rand [{3}]", NuGetPersistenceTags.NuGetProductTag,
CurrentState.LastOffset.AsLong(), Self.Path.Uid, Random.Shared.Next());
Sender.Tell(ProjectionAck.Instance);
});
Command<ProjectionCompleted>(_ =>
{
@Aaronontheweb
Aaronontheweb / mumurhash.linq
Created May 7, 2023 17:32
LINQPad Query to Visualize MurmurHash Distributions
// requires the `Akka` NuGet package to be installed in the query
int entitiesPerNodeFactor = 100;
List<string> nodes = Enumerable.Range(0, 10).Select(c => $"hostname-{c}").ToList();
Dictionary<string, int> entityToNodeAllocations = nodes.ToDictionary(c => c, k => 0);
var entityIds = Enumerable.Range(0, nodes.Count * entitiesPerNodeFactor).Select(e => $"entity-{e}");
foreach(var e in entityIds){
var hashCode = MurmurHash.StringHash(e);
@Aaronontheweb
Aaronontheweb / delivery.linq
Last active February 15, 2024 18:05
Akka.Delivery stream
async Task Main()
{
var actorSystem = ActorSystem.Create("Sys");
var producerSettings = ProducerController.Settings.Create(actorSystem);
using var cts = new CancellationTokenSource();
var (queue, producerController) = StreamConstruction.CreateProducerStream<IMessageProtocol>(actorSystem, producerSettings, "myproducer", cts.Token);
var myConsumer = actorSystem.ActorOf(Props.Create(() => new ConsumerActor(producerController)), "consumer");