Skip to content

Instantly share code, notes, and snippets.

View jasonmitchell's full-sized avatar

Jason Mitchell jasonmitchell

View GitHub Profile
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>();

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:

fromCategory('MyOldStreamCategory')
.whenAny(function (s, e) {
var newStreamName = e.streamId.replace('MyOldStreamCategory', 'MyNewStreamCategory');
emit(newStreamName, e.eventType, e.data, e.metadata);
})
@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"
}
@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 / 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 / BasicMiddleware.cs
Last active August 29, 2015 14:25
Sample code demonstrating the basics of writing OWIN middleware. Associated blog article: http://json.codes/blog/basics-of-writing-owin-middleware/
using System.Threading.Tasks;
using Microsoft.Owin;
public class BasicMiddleware : OwinMiddleware
{
public BasicMiddleware(OwinMiddleware next) : base(next)
{
}
define('module-id', ['array', 'of', 'dependencies'], function (array, of, dependencies) {
// Module definition
});
@using Quickstart.Web.Extensions
@model Quickstart.Web.Models.Person
@section scripts
{
<script type="text/javascript" src="/Scripts/moment.min.js"></script>
<script type="text/javascript" src="/Scripts/knockout.bindings.date.js"></script>
<script type="text/javascript">
var viewModel = ko.mapping.fromJS(@Html.Raw(Model.ToJson()));
ko.applyBindings(viewModel);
@model Quickstart.Web.Models.Person
@section scripts
{
<script type="text/javascript" src="/Scripts/ViewModels/AjaxModelLoading.js"></script>
<script type="text/javascript">
var viewModel = new AjaxModelLoading("@Url.Action("AjaxModelLoading")");
ko.applyBindings(viewModel);
viewModel.getRandomModel();