Skip to content

Instantly share code, notes, and snippets.

@vasilkosturski
vasilkosturski / addValueType.fs
Last active December 15, 2020 20:10
clash-of-styles-add-new-value-types
open System
type Value =
| MyInt of int
| MyRational of int * int
type Expression =
| MyValue of Value
| Addition of Expression * Expression
@vasilkosturski
vasilkosturski / DoubleDispatch.cs
Last active July 7, 2020 12:21
clash-of-styles-double-dispatch
using System;
namespace DoubleDispatch
{
class Program
{
static void Main(string[] args)
{
var expression = new Addition(
new MyInt(3),
@vasilkosturski
vasilkosturski / OperationsMatrixViaOop.cs
Created July 7, 2020 12:27
clash-of-styles-operations-matrix-via-oop
using System;
namespace OOPvsFP
{
class Program
{
static void Main(string[] args)
{
var expression = new Addition(
new MyInt(3),
@vasilkosturski
vasilkosturski / Visitor.cs
Last active August 9, 2020 07:32
clash-of-styles-the-visitor
using System;
namespace Visitor
{
class Program
{
public static void Main(string[] args)
{
var expression = new Addition(
new MyInt(1),
@vasilkosturski
vasilkosturski / DoubleDispatchMultimethods.cs
Created September 23, 2020 12:46
An example of Double Dispatch for the Multiple Dispatch (Multimethods) article.
using System;
namespace CSharpDoubleDispatch
{
class Program
{
static void Main(string[] args)
{
var op1 = new MyInt(5);
var op2 = new MyRational(2, 3);
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace StateMachineConceptual
{
class Program
{
static async Task Main()
{
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
public static class MyClass
{
[StructLayout(LayoutKind.Auto)]
[CompilerGenerated]
public struct AsyncTaskMethodBuilder
{
private IAsyncStateMachine _stateMachine;
private Action _moveNextRunner;
public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
where TAwaiter : ICriticalNotifyCompletion
where TStateMachine : IAsyncStateMachine
{
if (_stateMachine == null)
@vasilkosturski
vasilkosturski / KafkaClientWireshark.cs
Created November 7, 2022 06:22
Source code for the blog post "Kafka Networking via Wireshark"
using Confluent.Kafka;
using Confluent.Kafka.Admin;
namespace KafkaConnectivity;
public static class Program
{
private const int PartitionsCount = 2;
private const string TopicName = "my_topic";
private const string BootstrapServers = "localhost:9092,localhost:9093";
{
"title": "Root Schema",
"type": "object",
"default": {},
"required": [
"checked",
"dimensions",
"id",
"name",
"price",