Skip to content

Instantly share code, notes, and snippets.

@abdullin
abdullin / 2012-12-10-btw-outline.md
Created December 10, 2012 04:54
Being The Worst

Topic Context

  • Module 1
    • The worst welcome E001
    • Messaging basics E002
    • Commanding your words E003
    • Event sourcing basics E004
    • Aggregating stories E005
    • Community Code and questions 1 E006
    • Re-Factory E007
  • Frameworks over forms is a design obsession E008
@abdullin
abdullin / gist:3724348
Created September 14, 2012 20:00
Advanced A+ES with domain services
// This is slightly advanced usage scenario of Lokad A+ES tests, that shows
// setting up test implementations of domain services in ES+friendly way
// (really simple) that also prints out in the specifications. Price is an
// instance of IPricingService, used by Application service, while Clock
// is a static singleton actually.
[Test]
public void with_multiple_entries_and_previous_balance()
@abdullin
abdullin / lock_user.cs
Created September 14, 2012 14:01
Rough cuts of improved Simple Testing
// sample unit test for a command "LockUser"
public class lock_user : user_syntax
{
static readonly UserId id = new UserId(1);
static readonly SecurityId sec = new SecurityId(1);
static readonly TimeSpan fiveMins = TimeSpan.FromMinutes(5);
[Test]
@abdullin
abdullin / cqrs-search.html
Created February 2, 2012 16:51
Snippet that does AJAX search over a denormalized projection (handled by server) in async
// Snippet that shows AJAX search over a denormalized projection (handled by server) in async
// for sending commands in async - just do the AJAX post to server
// for getting changes - just poll the server for view version
// for cases when polling is expensive - use web sockets.
<script type="text/javascript">
$(document).ready(function () {
$('#searchButton').click(function () {
GetData($('#searchbox').val());
/// <summary>
/// Creates convention-based routing rules
/// </summary>
public sealed class RedirectToDynamicCommand
{
readonly IDictionary<Type, Wire> _dict = new Dictionary<Type, Wire>();
sealed class Wire
{
public MethodInfo Method;
@abdullin
abdullin / SimpleMessage.cs
Created October 24, 2011 11:37
SimpleMessage
/// <summary>
/// Source: https://gist.github.com/1308830
/// This simple envelope includes only:
/// <code>
/// Header - int32
/// TotalLength - int32
/// IdLength - int32
/// UTF8-encoded message ID - byte[IdLength]
/// ContractLength - int32
/// UTF-encoded contract name 0 byte[ContractLength]
@abdullin
abdullin / TestMessageSerialization.cs
Created October 12, 2011 18:51
Sample of using Specifications to test serializers
/// <summary>
/// This class scans all available specifications for messages used
/// then performs round-trip via specified serializer,
/// and then does the structural comparison of resulting values
/// </summary>
[TestFixture]
public sealed class TestMessageSerialization
{
static Group[] ListMessages()
{
@abdullin
abdullin / Program.cs
Created October 6, 2011 18:27
Wiring Lokad-CodeDSL in a MightyMoose style.
// This is a hacky sample (that works for me) of alternative way to use Lokad-codeDSL
// or any similar way of generating message contracts on-the-fly. Original approach was
// with using T4 template, that would rebuild cs files from DSL representation, whenever
// we hit Ctrl-S.
// This approach works almost exactly like this (Ctrl-S to rebuild), but does not require VS
// to run or does not require unloading VS to change the underlying generator code.
// in fact it is extremely boring. Lolcats from MightyMoose could be used to improve the situation, though.
// any takers? :)
@abdullin
abdullin / WebRole.cs
Created July 6, 2011 05:17
Sample of running AppEngine inside the Web Role (for Lokad.CQRS v2.0)
// Sample of running AppEngine inside the Web Role, essentially merging
// 1 worker role and 1 web role (for Lokad.CQRS v2.0)
// For explanation see: http://abdullin.com/journal/2011/7/6/lokadcqrs-can-make-windows-azure-cheaper-for-you.html
public class WebRole : RoleEntryPoint
{
CqrsEngineHost _host;
readonly CancellationTokenSource _source = new CancellationTokenSource();
public override bool OnStart()
{
@abdullin
abdullin / TimerService.cs
Created June 28, 2011 08:43
Sample of a timer service for powering up sagas (for Lokad.CQRS v2.0)
// the gist is discussed in: http://groups.google.com/group/lokad/browse_thread/thread/4d39dc299037ea09
// This is a sample of a timer service for powering up sagas (for Lokad.CQRS v2.0)
// register it in CqrsHostBuilder like this:
// hostBuilder.Advanced.ConfigureContainer(cb => cb.RegisterType<TimerService>().As<IEngineProcess>());
public sealed class TimerService : IEngineProcess
{
readonly IMessageSender _sender;
public TimerService(IMessageSender sender)
{