Skip to content

Instantly share code, notes, and snippets.

View jasonmitchell's full-sized avatar

Jason Mitchell jasonmitchell

View GitHub Profile
Batch Size Simple Insert Execution Time (ms) Multi-Row Insert Execution Time (ms) Improvement
1 4 3 33%
10 15 4 275%
50 68 3 2167%
100 133 4 3225%
250 306 6 5000%
500 606 8 7475%
1000 1358 11 12,245%
2500 3527 28
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
public class CreateFolder
{
public string Name { get; set; }
}
public class DeleteFolder
{
public Guid Id { get; set; }
}
function Get-BasicAuthCredentials {
param (
$user = "admin",
$password = "changeit"
)
$basicAuthPair = "${user}:${password}"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($basicAuthPair))
$basicAuthValue = "Basic $encodedCreds"
return $basicAuthValue
@jasonmitchell
jasonmitchell / Commands.cs
Last active June 5, 2017 11:49
Event sourced handler
public class RequestReservation { }
public class ConfirmReservation { }
@jasonmitchell
jasonmitchell / 2113-https.yaml
Last active May 14, 2017 19:56
Gossip Request
MemDb: true
Log: ../2113-https-logs
IntIp: 127.0.0.1
ExtIp: 127.0.0.1
IntTcpPort: 1112
ExtTcpPort: 1113
IntHttpPort: 2112
ExtHttpPort: 2113
IntHttpPrefixes: https://*:2112/
ExtHttpPrefixes: https://*:2113/
@jasonmitchell
jasonmitchell / Description
Last active May 14, 2017 19:57
InvalidOperationException - "SslStream already authenticated"
Single node
Any HTTPS request from external source.
Some extra logging added
Still exists on mono 5.0.0
Curl to https://127.0.0.1:2113/ping
Response received
"SslStream already authenticated" logged
Navigate to https://127.0.0.1:2113 in a browser
MemDb: true
Log: .\2113-logs
IntIp: 127.0.0.1
ExtIp: 127.0.0.1
IntTcpPort: 1112
ExtTcpPort: 1113
IntHttpPort: 2112
ExtHttpPort: 2113
IntHttpPrefixes: http://*:2112/
ExtHttpPrefixes: http://*:2113/
@jasonmitchell
jasonmitchell / Aggregate.cs
Created April 1, 2017 22:09
Event Sourced Aggregates
using System;
using System.Collections.Generic;
namespace Aggregates
{
public abstract class Aggregate : IAggregate
{
private readonly Dictionary<Type, Action<object>> handlers = new Dictionary<Type, Action<object>>();
private readonly Queue<object> uncommittedEvents = new Queue<object>();
private int version;
[Fact]
public async Task ReadsEventsFromStream()
{
// Create a connection to the embedded event store.
using (var connection = EmbeddedEventStoreConnection.Create(_node, _connectionSettingsBuilder))
{
// Write some events - omitted for clarity
// When reading from a stream you can specify the start position and how many events to read.
// The maximum number of events that can be read in one call is 4096 to large streams would require reading in pages.