Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
It's complicated

Jonathan Oliver joliver

💭
It's complicated
View GitHub Profile
@joliver
joliver / main.go
Last active Dec 2, 2020
Go v1.11 net.Listener SO_REUSEPORT or SO_REUSEADDR example
View main.go
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"
View gist:40291313605971545a0c1f6a3040d4c3
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
Simple Disruptor Example
View disruptor.go
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.
View gist:10545280
### 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 Oct 25, 2011
NServiceBusCommitDispatcher
View gist:1311195
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 Sep 18, 2011
RavenDB TransactionScope Issue
View Simplified--No Nested Transactions
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 Apr 5, 2011
Blog--CQRS: Out of Sequence Messages and Read Models
View DDL.sql
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 Mar 18, 2011
EventStore Fluent Builder API
View gist:875528
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 Jan 18, 2011
Bug in Json.NET 4.0r1?
View gist:784370
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*!
View gist:745817
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";
You can’t perform that action at this time.