Skip to content

Instantly share code, notes, and snippets.

Nikos Baxevanis moodmosaic

Block or report user

Report or block moodmosaic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@moodmosaic
moodmosaic / ApiControllerRegistration.cs
Created Mar 15, 2012
Post: Using the Web API Dependency Resolver with Castle Windsor
View ApiControllerRegistration.cs
foreach (Type controller in typeof(OrderController).Assembly.GetTypes().Where(type => typeof(IHttpController).IsAssignableFrom(type)))
{
// https://github.com/srkirkland/Inflector/blob/5fd4c818dd172bbe276fb210f25c2e2ceaff019e/Inflector/Inflector.cs
string name = Inflector.Pluralize(controller.Name.Replace("Controller", ""));
container.Register(Component
.For(controller)
.Named(name)
.LifestylePerWebRequest());
}
@moodmosaic
moodmosaic / BuildHttpSelfHostServer.cs
Created May 11, 2012
Draft: Minimum code required to initialize Windsor and return a new HttpSelfHostServer instance. (Work in-progress.)
View BuildHttpSelfHostServer.cs
private static HttpSelfHostServer BuildHttpSelfHostServer(string baseAddress)
{
var configuration = new HttpSelfHostConfiguration(baseAddress);
configuration.DependencyResolver =
new WindsorDependencyResolver(
new WindsorContainer()
.Install(new WebWindsorInstaller()));
configuration.Routes.MapHttpRoute(
@moodmosaic
moodmosaic / MatchWithTimeout.cs
Created Nov 15, 2012
Regular Expression Denial of Service
View MatchWithTimeout.cs
using System;
using System.Text.RegularExpressions;
using System.Threading;
internal class Program
{
private static void Main()
{
bool isMatch = IsMatch(
"1298-673-4192",
@moodmosaic
moodmosaic / WarmCrocConf
Last active Dec 11, 2015
My selection for #WarmCrocConf (subject to change)
View WarmCrocConf
Day 1
10:00-11:00 [D] Grokking Git by seeing it
11:00-12:00 [C] Make your system administrator friendly with PowerShell
14:00-15:00 [B] NuGet (Anti-)Patterns: Tales from the trenches
15:00-16:00 [D] Building Agnostic Clients Through the Power of http || [C] F# in the Brave New World
17:00-18:00 [D] Scaling Backbone Applications With Marionette
18:00-19:00 [C] Organize your chickens: NuGet for the enterprise
@moodmosaic
moodmosaic / Equality_Behaves_As_Expected.cs
Last active Dec 15, 2015
A discussion branch for a question about Likeness on Stack Overflow.
View Equality_Behaves_As_Expected.cs
// http://stackoverflow.com/questions/15558873/trouble-using-autofixtures-createproxy-to-use-likeness-semanticcomparison-feat
[Fact]
public void Equality_Behaves_As_Expected()
{
var template = new Fixture().Create<Band>();
var createdBand = new Band
{
Brass = template.Brass,
@moodmosaic
moodmosaic / Test_With_InlineAutoMockDataAttribute.cs
Last active Dec 16, 2015
A discussion branch for a question on Stack Overflow about using AutoFixture declaratively.
View Test_With_InlineAutoMockDataAttribute.cs
// http://stackoverflow.com/questions/16145284/autofixture-how-to-express-the-following-code-declaratively/16145954?noredirect=1#16145284
public class Tests
{
[Theory]
[InlineAutoMockData(@"-o=C:\Temp\someFile -p=1")]
[InlineAutoMockData(@"-p=1 -o=C:\Temp\someFile")]
public void ParseMissingParameterShouldReturnCorrectResult(
string argsString,
SomeClass sut)
@moodmosaic
moodmosaic / Ploeh.AutoFixture.js
Last active Dec 18, 2015
Node.js sample adapter-module for AutoFixture via Edge.js
View Ploeh.AutoFixture.js
var create = require('edge').func(function () {/*
//#r "Ploeh.AutoFixture.dll"
using System;
using Ploeh.AutoFixture;
public class Startup
{
public async System.Threading.Tasks.Task<object> Invoke(object request)
View AutoFoqSynthesizeReturnValuesCustomization.fs
open Ploeh.AutoFixture
open Ploeh.AutoFixture.Kernel
open System
type internal AutoFoqSynthesizeReturnValuesCustomization() =
member this.Customize fixture =
(this :> ICustomization).Customize fixture
interface ICustomization with
member this.Customize fixture =
match fixture with
@moodmosaic
moodmosaic / SemanticEqualityComparisonInFSharp.fs
Last active Dec 30, 2015
Compare complex object graphs with SemanticComparer<T>.
View SemanticEqualityComparisonInFSharp.fs
module SemanticEqualityComparisonInFSharp
open System
open System.Reflection
open Ploeh.SemanticComparison
open Xunit
open Xunit.Extensions
[<CustomEquality; NoComparison>]
type StructuralType =
@moodmosaic
moodmosaic / GreedyFactoryMethods.cs
Last active Jan 2, 2016
AutoFixture strategy for invoking Factory Methods with most parameters based on Twitter discussion on https://twitter.com/madstt/status/420850414641090560
View GreedyFactoryMethods.cs
internal class GreedyFactoryMethodQuery : IMethodQuery
{
public IEnumerable<IMethod> SelectMethods(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
return from mi in type.GetMethods(
BindingFlags.Static | BindingFlags.Public)
where mi.ReturnType == type
You can’t perform that action at this time.