Skip to content

Instantly share code, notes, and snippets.

View jasonmitchell's full-sized avatar

Jason Mitchell jasonmitchell

View GitHub Profile
@jasonmitchell
jasonmitchell / AutofacValidatorFactory.cs
Last active March 14, 2023 05:24
Integrating Fluent Validation with Web API using Autofac. Full example: https://github.com/jasonmitchell/fluentvalidation-webapi-autofac
using System;
using Autofac;
using FluentValidation;
namespace Sample.Web.Infrastructure
{
public class AutofacValidatorFactory : ValidatorFactoryBase
{
private readonly IComponentContext _context;
@jasonmitchell
jasonmitchell / AndSpecification.cs
Last active September 13, 2015 17:07
Generic Repository
namespace Sample.Repositories.Specifications
{
using System;
using System.Linq;
using System.Linq.Expressions;
internal class AndSpecification<T> : ISpecification<T>
{
private readonly ISpecification<T> left;
private readonly ISpecification<T> right;
@jasonmitchell
jasonmitchell / command-api.ps1
Last active July 25, 2023 00:20
PowerShell script for publishing websites to Azure using Kudu
$username = "$my-website"
$password = "password"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$apiUrl = "https://my-website.scm.azurewebsites.net/api/command"
$commandBody = @{
command = "del /S /F /Q .\\"
dir = "site\\wwwroot"
}
fromCategory('MyOldStreamCategory')
.whenAny(function (s, e) {
var newStreamName = e.streamId.replace('MyOldStreamCategory', 'MyNewStreamCategory');
emit(newStreamName, e.eventType, e.data, e.metadata);
})

Keybase proof

I hereby claim:

  • I am jasonmitchell on github.
  • I am jasonmitchell (https://keybase.io/jasonmitchell) on keybase.
  • I have a public key whose fingerprint is BD48 5BB9 3F4D 1463 BE4E CE8E C9BC 9458 59A1 B9DC

To claim this, I am signing this object:

class Order : Aggregate
{
static Order()
{
Given<Order, OrderStarted>((x, e) =>
{
x.Id = e.Id;
x.customerId = e.CustomerId;
x.status = OrderStatus.Open;
x.tickets = new List<Ticket>();
[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.
@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;
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 / 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