Skip to content

Instantly share code, notes, and snippets.

View oguzhaneren's full-sized avatar
🐍
it depends

Oğuzhan Eren oguzhaneren

🐍
it depends
View GitHub Profile
@benfoster
benfoster / pipeline.cs
Created June 23, 2016 07:24
c# Pipeline
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PipelineDemo
{
// http://www.rantdriven.com/post/2009/09/16/Simple-Pipe-and-Filters-Implementation-in-C-with-Fluent-Interface-Behavior.aspx
public interface IFilter<TContext>
{
@davidfowl
davidfowl / Example1.cs
Last active February 11, 2026 04:57
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@gregoryyoung
gregoryyoung / gist:a3e69ed58ae066b91f1b
Created June 24, 2015 13:25
Event Sourcing as 3 functions.
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
@imjasonh
imjasonh / markdown.css
Last active September 3, 2025 22:12
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@dlidstrom
dlidstrom / IndexTests.cs
Created March 30, 2015 10:44
Indexer with tests
public class Indexer
{
private readonly Dictionary<string, List<string>> terms =
new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, List<string>> docsTerms =
new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
public void Index(string docId, string text)
{
List<string> docTerms;
@maartenba
maartenba / DomainTemplateRoute - GetVirtualPath
Last active May 15, 2023 07:30
ASP.NET MVC 6 / ASP.NET 5 Domain Routing + Tenant Middleware
public string GetVirtualPath(VirtualPathContext context)
{
foreach (var matcherParameter in _matcher.Template.Parameters)
{
context.Values.Remove(matcherParameter.Name); // make sure none of the domain-placeholders are appended as query string parameters
}
return _innerRoute.GetVirtualPath(context);
}
@fschmied
fschmied / gist:418e38425f83fb81b833
Created January 6, 2015 19:52
Catch-up subscription
public class EventSubscriber : IEventSubscriber
{
private IReadModelPersistence _persistence;
public void CatchUpAndSubscribe (IEventBus eventBus, IEventStore eventStore)
{
CatchUpUntilNow(eventStore);
eventBus.Subscribe (this);
CatchUpUntilNow(eventStore);
}
internal class MassTransitDispatcher : IObserver<ICommit>
{
private readonly IServiceBus _bus;
public MassTransitDispatcher(IServiceBus bus)
{
_bus = bus;
}
public void Dispose()
@copypastedeveloper
copypastedeveloper / TransactionalInvoker
Created June 12, 2014 03:13
example of how to make just about anything transaction aware
public class TransactionalInvoker : IEnlistmentNotification
{
bool _inTransaction;
readonly List<Action> _commitActions = new List<Action>();
public void Invoke(Action action)
{
if (_inTransaction)
{
_commitActions.Add(action);
readonly ICollection<Action> _transactionCallbacks = new Collection<Action>();
public override int SaveChanges() {
int r;
try {
ExecuteDomainEvents();
r = base.SaveChanges();
} catch (Exception) {
_transactionCallbacks.Clear();
throw;