Skip to content

Instantly share code, notes, and snippets.

View andreabalducci's full-sized avatar

Andrea Balducci andreabalducci

View GitHub Profile
@andreabalducci
andreabalducci / CheckoutTest.cs
Last active October 25, 2017 06:53
Process Managers @ NStore | Work in progress
using System;
using System.Collections;
// ReSharper disable UnusedMember.Local
#pragma warning disable S1172 // Unused method parameters should be removed
#pragma warning disable S1144 // Unused private types or members should be removed
namespace NStore.Domain.Tests.ProcessManagerTests
{
public class CheckoutState
{
public bool PaymentReceived { get; private set; }
@andreabalducci
andreabalducci / drop_all_db.js
Created March 10, 2017 21:10
MongoDB :: Drop all databases
var admin = db.getSiblingDB('admin');
var dbs = db.adminCommand( { listDatabases: 1 } );
dbs.databases.forEach(function(db){
if(db.name !== 'admin' && db.name !== 'local'){
admin.getSiblingDB(db.name).dropDatabase();
}
})
@andreabalducci
andreabalducci / itdev.klc
Created February 28, 2017 10:25
Windows Italian Keyboard - Dev
KBD ITDev "Italian - Developer (backtick & tilde)"
COPYRIGHT "(c) 2017 Company"
COMPANY "Company"
LOCALENAME "it-IT"
LOCALEID "00000410"
@andreabalducci
andreabalducci / intro.ts
Created June 11, 2015 16:40
Typescript intro
// http://channel9.msdn.com/events/Build/2015/3-644
function sortByName(a){
var result = a.slice(0);
result.sort(function(x,y){
return x.name.localCompare(y.name);
})
}
sortByName(5);
{
swagger: "2.0",
info: {
version: "v1",
title: "Documenstore api",
description: null,
termsOfService: null,
contact: null,
license: null,
vendorExtensions: {}
@andreabalducci
andreabalducci / SecondLevelCacheTests.cs
Last active August 29, 2015 14:11
NHibernate: Test second level cache with Log4Net
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using James.Kernel.Model.Jobs;
using James.Tests.Support;
using James.Tests.Support.SampleData;
using log4net;
@andreabalducci
andreabalducci / CreateDocumentCommandHandler.cs
Last active August 29, 2015 14:08
Dealing with eventual consistency with read model "promises" with NEvenstore & MongoDb (WIP)
using Jarvis.DocumentStore.Core.CommandHandlers.HandleHandlers;
using Jarvis.DocumentStore.Core.Domain.Document.Commands;
using Jarvis.DocumentStore.Core.Domain.Handle;
using Jarvis.DocumentStore.Core.ReadModel;
namespace Jarvis.DocumentStore.Core.CommandHandlers.DocumentHandlers
{
public class CreateDocumentCommandHandler : DocumentCommandHandler<CreateDocument>
{
readonly IHandleMapper _mapper;
@andreabalducci
andreabalducci / init.js
Last active August 29, 2015 14:08
mongodb halloween party
db.halloween.drop()
tags = [];
[1,2,3,4].forEach(function(num){
tags.push(''+num);
db.halloween.insert({
num: NumberInt(num),
tags:tags
})
})
@andreabalducci
andreabalducci / list-events.js
Last active August 29, 2015 14:08
NEvenstore: list events
db.Commits.aggregate([
{$sort: {_id:1}},
{$unwind : "$Events"},
{$project : { _id:1, StreamId:1, event: '$Events.Payload.Body._t', body : '$Events.Payload.Body'}},
])
@andreabalducci
andreabalducci / BsonClassMapHelper.cs
Created September 30, 2014 08:56
Reset class map for unit testing
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MongoDB.Bson.Serialization;
namespace CQRS.Tests.DomainTests
{
public static class BsonClassMapHelper
{