Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View joliver's full-sized avatar
💭
It's complicated

Jonathan Oliver joliver

💭
It's complicated
View GitHub Profile
@joliver
joliver / main.go
Last active September 27, 2023 22:30
Go v1.11 net.Listener SO_REUSEPORT or SO_REUSEADDR example
package main
// This is a super-quick example of how to set the socket options to allow port re-use for a single address/port on a host machine.
// This is most commonly used with things like hot reloads of configuration.
import (
"context"
"log"
"net"
"syscall"
@joliver
joliver / gist:40291313605971545a0c1f6a3040d4c3
Created April 26, 2017 03:24
Multi-core HAProxy Sample
listen frontend-secure
mode tcp
bind :443 tfo ssl crt /etc/ssl/private/
server forward-to-internal-via-pipe abns@haproxy-pipe send-proxy
bind-process 2-4
frontend frontend-aggregate
bind abns@haproxy-pipe accept-proxy
bind-process 1
@joliver
joliver / disruptor.go
Created May 24, 2014 05:23
Simple Disruptor Example
package main
import (
"fmt"
"runtime"
"time"
)
// the code below is loosely based upon: https://gist.github.com/tux21b/1218360
// it is only safe on 64-bit CPUs.
@joliver
joliver / gist:10545280
Created April 12, 2014 16:47
keybase.md
### Keybase proof
I hereby claim:
* I am joliver on github.
* I am joliver (https://keybase.io/joliver) on keybase.
* I have a public key whose fingerprint is B834 EF94 BA73 68A1 C02B 48BD 9C02 4FBE AC5B 8FE9
To claim this, I am signing this object:
@joliver
joliver / gist:1311195
Created October 25, 2011 03:16
NServiceBusCommitDispatcher
public sealed class NServiceBusCommitDispatcher : IPublishMessages
{
private const string AggregateIdKey = "AggregateId";
private const string CommitVersionKey = "CommitVersion";
private const string EventVersionKey = "EventVersion";
private const string BusPrefixKey = "Bus.";
private readonly IBus bus;
public NServiceBusCommitDispatcher(IBus bus)
{
@joliver
joliver / Simplified--No Nested Transactions
Created September 18, 2011 03:17
RavenDB TransactionScope Issue
using System;
using System.Diagnostics;
using System.Linq;
using System.Transactions;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Linq;
public class Program
{
@joliver
joliver / DDL.sql
Created April 5, 2011 04:11
Blog--CQRS: Out of Sequence Messages and Read Models
CREATE TABLE [dbo].[Messages]
(
[AggregateId] [uniqueidentifier] NOT NULL,
[Version] [int] NOT NULL CHECK ([Version] > 0),
[Inserted] [datetime] NOT NULL DEFAULT (GETUTCDATE()),
[Headers] [varbinary](max) NOT NULL,
[Payload] [varbinary](max) NOT NULL,
CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED ([AggregateId], [Version])
);
@joliver
joliver / gist:875528
Created March 18, 2011 02:35
EventStore Fluent Builder API
return EventStore.Wireup.Init()
.UsingSqlPersistence("EventStore")
.InitializeDatabaseSchema()
.UsingCustomSerializer(new JsonSerializer())
.Compress()
.EncryptWith(EncryptionKey)
.UsingAsynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(DispatchCommit))
.HandleExceptionsWith(DispatchErrorHandler)
.Build();
@joliver
joliver / gist:784370
Created January 18, 2011 12:27
Bug in Json.NET 4.0r1?
public void Test()
{
var serializer = new Newtonsoft.Json.JsonSerializer();
using (var memoryStream = new MemoryStream())
{
using (var bsonWriter = new BsonWriter(memoryStream))
serializer.Serialize(bsonWriter, 12345);
Console.Write("Stream length is: " + memoryStream.Length); // shouldn't be *0*!
namespace ConsoleApplication1
{
using System;
using System.Transactions;
using Raven.Client.Document;
public static class MainProgram
{
private const string RavenUrl = "http://localhost:8080";
private const string CustomDatabaseName = "MyDatabase";