Skip to content

Instantly share code, notes, and snippets.

View serbrech's full-sized avatar
🤙
Working from home

Stéphane Erbrech serbrech

🤙
Working from home
View GitHub Profile
@serbrech
serbrech / gist:e45617cceafcb1ffba25
Last active August 29, 2015 14:07
EquivalenceFail.cs
using FluentAssertions;
using NUnit.Framework;
namespace EquivalentTest
{
[TestFixture]
public class EquivalenceTest
{
[Test]
public void Test()

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@serbrech
serbrech / grant_to_all_db.sql
Created April 14, 2015 10:18
useful script to grant rights
SET NOCOUNT ON;
DECLARE @user_name SYSNAME
, @login_name SYSNAME;
SELECT @user_name = '',
@login_name = ''
SELECT '
USE ' + QUOTENAME(NAME) + ';
public static MvcHtmlString CompassUrl(this HtmlHelper helper, string compassUrl)
{
//...
var anchorBuilder = new TagBuilder("a");
anchorBuilder.Attributes.Add("target", IsCompassContext(helper) ? "_parent" : "_blank");
anchorBuilder.Attributes.Add("href", compassUrl);
//...
}
private static bool IsCompassContext(HtmlHelper helper)
public interface IIssueDataFetcher
{
void Fetch(Action<IssueData> callback);
IIssueDataFetcher WithId(int id);
IIssueDataFetcher IncludeContainers();
IIssueDataFetcher IncludeContainerStatuses();
IIssueDataFetcher IncludeContainerCategories();
IIssueDataFetcher IncludeAll();
}
@serbrech
serbrech / rubykoans triangle.rb
Created April 5, 2011 18:55
My ruby koans triangle implementation. Is there a "rubyer" way to write this?
def guard(a, b, c)
if a < 0 || b < 0 || c < 0
raise TriangleError, "a triangle should not have a side with a negative value."
end
if a == 0 && b == 0 && c == 0
raise TriangleError, "A triangle should not have all its side equal to 0."
end
if (a + b) <= c || (b + c) <= a || (a + c) <= b
raise TriangleError, "Any two sides of a triangle should add up to more than the third side."
end
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
def triple?(dice, val)
dice.count {|die| die == val} >= 3
end
def get_triple_bonus(dice)
return 0 if dice.empty?
return 350 if triple? dice, 5
return 700 if triple? dice, 1
@serbrech
serbrech / TestBase.cs
Created August 21, 2011 18:42
Silverlight MSTest TestBase
public class TestBase
{
private Exception _exception;
[TestInitialize]
public void TestInitialize()
{
try
{
Initialize();
@serbrech
serbrech / KeyGestureCommandTrigger.cs
Created August 31, 2011 12:30
KeyGestureBehavior
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using PagePlanner.Windows.Controls.TriggerActions;
namespace PagePlanner.Windows.Controls.Behaviours.KeyGestures
{
@serbrech
serbrech / app.rb
Created November 6, 2011 15:48
facebook canvas sinatra by heroku
require "sinatra"
require "mogli"
enable :sessions
set :raise_errors, false
set :show_exceptions, false
# Scope defines what permissions that we are asking the user to grant.
# In this example, we are asking for the ability to publish stories
# about using the app, access to what the user likes, and to be able