Skip to content

Instantly share code, notes, and snippets.

View andreabalducci's full-sized avatar

Andrea Balducci andreabalducci

View GitHub Profile
@andreabalducci
andreabalducci / bootstrapper.cs
Created November 18, 2012 10:13
take 1 : inprocess engine
Container.Register(
Component
.For<ICommandDispatcher>()
.ImplementedBy<DefaultCommandDispatcher>(),
Component
.For<IEventBus>()
.ImplementedBy<InProcessEventBus>()
.LifeStyle.Singleton,
Component
.For<IEngine>()
public static IHtmlString SkinnedTextBoxFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, InputStyles styles = InputStyles.Normal, int size = 0)
{
var cssClasses = BuildClasses(styles, "input");
IDictionary<string, object> attrs = new Dictionary<string, object>();
attrs["class"] = cssClasses;
if (size > 0)
attrs["size"] = size;
string format = null;
if (typeof (DateTime).IsAssignableFrom(expression.ReturnType))
@andreabalducci
andreabalducci / mongodb_change_document_key.js
Created January 18, 2013 15:42
How to batch change a key on a mongodb collection
Run with
> mongo <server>/<db> mongodb_change_document_key.js
@andreabalducci
andreabalducci / eventstore_find_commits_by_aggregate_id
Created February 4, 2013 10:26
List commits from Eventstore + CommonDomain by aggregate ID
db.Commits.find({ "_id.StreamId" : CSUUID("<GUID_HERE>") }).sort({ "_id.CommitSequence" : 1 });
traceroute to 216.81.59.173 (216.81.59.173), 100 hops max, 60 byte packets
1 router1-dal.linode.com (67.18.7.161) 0.698 ms 0.685 ms 0.756 ms
2 xe-2-0-0.car03.dllstx2.networklayer.com (67.18.7.89) 0.341 ms 0.326 ms 0.311 ms
3 po101.dsr02.dllstx2.networklayer.com (70.87.254.77) 0.584 ms 0.663 ms 0.665 ms
4 po22.dsr02.dllstx3.networklayer.com (70.87.255.69) 0.809 ms 0.861 ms 0.947 ms
5 ae17.bbr02.eq01.dal03.networklayer.com (173.192.18.230) 0.501 ms 0.478 ms 0.451 ms
6 ae7.bbr01.eq01.dal03.networklayer.com (173.192.18.208) 0.475 ms 0.653 ms 10gigabitethernet3-1.core1.dal1.he.net (206.223.118.37) 6.020 ms
7 10gigabitethernet3-1.core1.dal1.he.net (206.223.118.37) 1.455 ms 1.581 ms 10gigabitethernet5-4.core1.atl1.he.net (184.105.213.114) 21.941 ms
8 10gigabitethernet5-4.core1.atl1.he.net (184.105.213.114) 22.013 ms 216.66.0.26 (216.66.0.26) 20.970 ms 21.238 ms
9 10.26.26.102 (10.26.26.102) 58.340 ms 56.423 ms 216.66.0.26 (216.66.0.26) 20.832 ms
@andreabalducci
andreabalducci / DomainModelRegistration.cs
Created April 10, 2013 14:11
mapping custom factory for mongodb c# driver deserialization
namespace APP.Domain
{
public class FactoryClassMap : BsonClassMap
{
public FactoryClassMap(Type classType, IDeserializationFactory factory) : base(classType)
{
Func<object> factoryDelegate = factory.Create;
MapCreator(factoryDelegate);
AutoMap();
}
@andreabalducci
andreabalducci / DynamicTest.cs
Last active December 16, 2015 22:39
strange behavior in vs2012 + r#
[TestFixture]
public class DynamicTest
{
public class Dto
{
public string Value { get; set; }
}
public Dto ToDto(dynamic d)
{
public class ResponseContentMd5Handler : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
System.Threading.CancellationToken cancellationToken)
{
HttpResponseMessage response = await base.SendAsync(request, cancellationToken);
if (response.IsSuccessStatusCode && response.Content != null)
{
response.Content.Headers.ContentMD5 = await MD5Helper.ComputeHash(response.Content);
@andreabalducci
andreabalducci / ElmahPipelineModule.cs
Created May 24, 2013 06:56
Elmah Pipeline Module for Signalr
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Elmah;
using Microsoft.AspNet.SignalR.Hubs;
namespace App.Website.Support.SignalrPipelineExtensions
{
@andreabalducci
andreabalducci / NullCommitDispatcher.cs
Created December 23, 2013 14:58
NEvenstore Null Commit Dispatcher
public static class NullDispatchSchedulerWireupExtensions
{
public static NullDispatchSchedulerWireup DoNotDispatchCommits(this Wireup wireup)
{
return new NullDispatchSchedulerWireup(wireup);
}
}
public class NullDispatchSchedulerWireup : Wireup
{