Skip to content

Instantly share code, notes, and snippets.

View afifmohammed's full-sized avatar
💭
(+2)(-3)

Afif Mohammed afifmohammed

💭
(+2)(-3)
View GitHub Profile
@lafar6502
lafar6502 / gist:8105682
Last active January 26, 2021 06:10
some messy code of a synchronization gateway that allows only a single thread of execution for all passed callbacks. It allows new callbacks to be enqueued while they are being executed by another thread. This implementation is almost certainly broken because I didn't care if it compiles at all and if all closure stuff is done correctly, but hop…
public class ConcurrentGateway
{
private ConcurrentQueue<Action> _workQueue = new ConcurrentQueue<Action>();
private int _writeLock = 0;
[ThreadStatic]
private static AutoResetEvent _waitEvent = new AutoResetEvent(false);
protected static AutoResetEvent GetThreadWaitEvent()
{
@tonymorris
tonymorris / PureIO.cs
Last active April 2, 2022 16:23
A demonstration of pure-functional I/O using the free monad in C#
using System;
namespace PureIO {
/*
C# does not have proper sum types. They must be emulated.
This data type is one of 4 possible values:
- WriteOut, being a pair of a string and A
- WriteErr, being a pair of a string and A
- readLine, being a function from string to A
@kijanawoodard
kijanawoodard / LastInWinsReplicationConflictResolver.cs
Created April 4, 2013 01:54
Last One Wins Raven Resolver - Updated for 2.x
using System;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Abstractions.Logging;
using Raven.Bundles.Replication.Plugins;
using Raven.Json.Linq;
namespace RavenConflictResolverPlugin
{
public class LastInWinsReplicationConflictResolver
@SzymonPobiega
SzymonPobiega / gist:5220595
Last active April 25, 2024 17:19
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@PaulStovell
PaulStovell / Tasks.cs
Last active January 27, 2016 17:48
An example using RavenDB's changes API to implement a queue of tasks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using Raven.Abstractions.Data;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
namespace OctoQueues