Skip to content

Instantly share code, notes, and snippets.

View myarichuk's full-sized avatar

Michael Yarichuk myarichuk

View GitHub Profile
@myarichuk
myarichuk / MessageBus.cs
Last active February 15, 2023 09:00
Lightweight Message Bus
using namespace System.Threading.Channels;
public class MessageBus<T>
{
private readonly Channel<T> channel = Channel.CreateUnbounded<T>();
public void Subscribe(Action<T> handler)
{
var reader = channel.Reader;
Task.Run(async () =>
#!/bin/bash
sudo apt-get update
sudo apt-get -y install git libicu-dev build-essential curl libunwind8 gettext nano lldb wget
wget https://download.visualstudio.microsoft.com/download/pr/d52fa156-1555-41d5-a5eb-234305fbd470/173cddb039d613c8f007c9f74371f8bb/dotnet-sdk-3.1.101-linux-arm.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/da60c9fc-c329-42d6-afaf-b8ef2bbadcf3/14655b5928319349e78da3327874592a/aspnetcore-runtime-3.1.1-linux-arm.tar.gz
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.101-linux-arm.tar.gz -C $HOME/dotnet
tar zxf aspnetcore-runtime-3.1.1-linux-arm.tar.gz -C $HOME/dotnet
/*
Usage:
client = new DocumentClient(new Uri(Endpoint), Key);
_clientEventListener = new DocumentClientEventListener(client);
CreateDatabaseIfNotExistsAsync().Wait();
CreateCollectionIfNotExistsAsync().Wait();
_clientEventListener.Initialize();
@myarichuk
myarichuk / Program.cs
Created December 10, 2017 13:06
Dump Voron header contents into text files
FileHeader* one = stackalloc FileHeader[1];
FileHeader* two = stackalloc FileHeader[1];
if (!Win32Helper.TryReadFileHeader(one, "headers.one"))
throw new Win32Exception();
if (!Win32Helper.TryReadFileHeader(two, "headers.two"))
throw new Win32Exception();
var oneJson = RavenJObject.FromObject(*one);
@myarichuk
myarichuk / Program.cs
Created October 24, 2017 15:59
InvalidProgramException reproduction
using System;
using System.Collections;
using System.Collections.Generic;
namespace InvalidProgramExceptionReproduction
{
class Program
{
static void Main(string[] args)
{
@myarichuk
myarichuk / GetConflictStatus
Created August 28, 2017 15:09
GetConflictStatus
public static ConflictStatus GetConflictStatus(string remoteAsString, string localAsString)
{
if (remoteAsString == localAsString)
return ConflictStatus.AlreadyMerged;
if(string.IsNullOrEmpty(remoteAsString))
return ConflictStatus.AlreadyMerged;
if (string.IsNullOrEmpty(remoteAsString) || string.IsNullOrEmpty(localAsString))
return ConflictStatus.Update;