Skip to content

Instantly share code, notes, and snippets.

Bartosz Sypytkowski Horusiath

Block or report user

Report or block Horusiath

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Horusiath
Horusiath / Program.cs
Last active Oct 5, 2019
An interfaced generic-aware Akka.NET actor implementation
View Program.cs
using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
namespace AkkaDemos
{
public interface IGreeter
{
Task<string> Greet(IGreeter who);
@Horusiath
Horusiath / Main.fs
Last active Sep 4, 2019
Affine thread pool
View Main.fs
/// The MIT License (MIT)
///
/// Copyright (c) Bartosz Sypytkowski <b.sypytkowski@gmail.com>
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
@Horusiath
Horusiath / Demo.cs
Last active Sep 21, 2019
Custom Akka.NET Streams graph stage for prefetching elements, when the buffer comes close to the empty
View Demo.cs
using Akka.Streams;
using Akka.Streams.Stage;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
sealed class PreFetch<T> : GraphStage<SourceShape<T>>
@Horusiath
Horusiath / main.c
Created May 24, 2019
Demo of a simple custom virtual machine. Presentation available at https://www.slideshare.net/BartoszSypytkowski1/virtual-machines-how-they-work/
View main.c
#include <stdio.h>
#include <stdlib.h>
// stack will have fixed size
#define STACK_SIZE 1024
#define DEBUG_ENABLED 1
#define DBG if(DEBUG_ENABLED) printf
#define PUSH(vm, v) vm->stack[++vm->sp] = v // push value on top of the stack
#define POP(vm) vm->stack[vm->sp--] // pop value from top of the stack
#define NEXT(vm) vm->code[vm->pc++] // get next bytecode
@Horusiath
Horusiath / README.md
Last active Feb 17, 2019
Operation conflation of Commutative Replicated Data Types
View README.md

Operation conflation of Commutative Replicated Data Types

Intro to Commutative Replicated Data Types

Operation-based variant of CRDTs is based on idea, that instead of replicating the state (or its delta), we replicate the operations, and let the corresponding replica build eventually consistent state from operations only. A standardized API for such data types consist of several members:

  • initial: empty instance of CRDT object.
  • query: returns a value out of the CRDT object.
  • atSource: which returns a serializable operation. I.e. for a given Counter CRDT, its atSource function could return operations like inc(replicaId, delta) or dec(replicaId, delta).
  • downstream which is used to consume operations incoming from both local and remote sources to produce new state of the CRDT object.
@Horusiath
Horusiath / hyperion.md
Last active Nov 1, 2018
[DRAFT] Hyperion binary format
View hyperion.md

Hyperion

This is a draft for binary format and implementation proposal for Hyperion, a fast binary serializer for .NET. Currently Hyperion is in beta and uses non-standard binary format. This document aims to specify it. Before we do that, there are few important properties of the serializer we wish to maintain:

Polymorphic

Hyperion is polymorphic serializer, therefore it's tolerant for subtyping rules. Example using C# pseudo-code:

var serializer = new Serializer();
@Horusiath
Horusiath / CSharpBenchmark.cs
Last active Jul 1, 2018
Delegates vs. generic readonly structs
View CSharpBenchmark.cs
using System;
using BenchmarkDotNet.Attributes;
namespace Tachyon.Benchmarks.Core
{
// Instead of delegate, use interface.
interface IFunc<in I, out O>
{
O Invoke(I arg);
@Horusiath
Horusiath / Benchmark.cs
Last active May 14, 2018
Direct vs indirect enumerator call
View Benchmark.cs
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
namespace Benchmarks
{
public class EnumeratorBenchmarks
{
private const int SIZE = 1_000_000;
private static readonly int[] array = GetArray();
@Horusiath
Horusiath / Benchmark.cs
Last active Dec 5, 2017
Benchmarks for .NET collection creation
View Benchmark.cs
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using BenchmarkDotNet.Attributes;
namespace Hyperion.Benchmarks
{
public class HyperionConfig : ManualConfig
@Horusiath
Horusiath / Example.cs
Created Sep 27, 2017
Generic Google Protocol Buffers serializer for Akka.NET
View Example.cs
using System;
using Akka.Actor;
using Akka.Configuration;
using Akka.Serialization.Protobuf;
using ProtoBuf;
namespace App
{
/// <summary>
/// Interface used to recognize messages to be serialized by <see cref="ProtobufSerializer"/>.
You can’t perform that action at this time.