Skip to content

Instantly share code, notes, and snippets.

@danielwertheim
danielwertheim / MyFactAttribute.cs
Created April 14, 2014 12:59
Custom xUnit attribute
public class MyFactAttribute : FactAttribute
{
public MyFactAttribute(params string[] scenarios)
{
if(!scenarios.Any() || IntegrationTestsRuntime.Environment.SupportsEverything)
return;
if (!scenarios.All(r => IntegrationTestsRuntime.Environment.HasSupportFor(r)))
Skip = string.Format("TestEnvironment does not support ALL test scenario(s): '{0}'.", string.Join("|", scenarios));
}
http://www.dustin.se/product/5010746863/sp-pov-buoy/
http://www.dustin.se/product/5010640729/sandisk-microsdxc-ultra-class-10-64-gb/
http://www.dustin.se/product/5010667590/gopro-hero3-black-edition/
http://www.dustin.se/product/5010672749/gopro-caps-doors-hero3/
@danielwertheim
danielwertheim / Program.cs
Created September 16, 2015 14:10
ReleaseDebugInlining
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace DebugVsRelease
{
class Constants
{
public const int Itterations = 1000000;
}
@danielwertheim
danielwertheim / Program.cs
Last active September 26, 2015 06:12
Some MongoDB and Proxies
using System;
using System.Collections.Concurrent;
using Castle.DynamicProxy;
using MongoDB.Bson;
namespace FunnyBunny
{
class Program
{
static void Main(string[] args)
@danielwertheim
danielwertheim / gist:1306558
Created October 22, 2011 22:21
ServiceStack ISet
JSON:
{"StructureId":"45748284fbfce011910a544249037e42","Names":{"First":"Daniel","Last":"Wertheim"},"Values":{"Value":{"Is":99},"Guid":"19adfa6da12748e09291aeb75e8ca23c","Int":42,"Long":142,"String":"String in ValuesContainer.","Double":1.33,"Decimal":3.14,"Bool":true},"NullValuesContainer":{"Guid":"60d977f995fc40fd9a7e6827e920370f","Int":42,"Long":142,"String":"String in NullValuesContainer.","Double":1.33,"Decimal":3.14,"Bool":true},"NullValuesContainerWithNulls":{},"ValuesInArray":[{"Is":1},{"Is":2},{"Is":3}],"ValuesInIList":[{"Is":31},{"Is":32},{"Is":33}],"ValuesInList":[{"Is":41},{"Is":42},{"Is":43}],"ValuesInISet":[{"Is":11},{"Is":12},{"Is":13}],"ValuesInHashSet":[{"Is":21},{"Is":22},{"Is":23}]}
NOTE! ValuesInIList is deserialized to member but ValuesInISet is not.
public class MyClass
{
public MyClass() {}
... ... ...
@danielwertheim
danielwertheim / IDbDataTypeTranslator
Created October 28, 2011 11:51
DbDataTypeTransaltor
public interface IDbDataTypeTranslator
{
string ToDbType(IIndexAccessor indexAccessor);
string ToDbType(Type dataType);
}
@danielwertheim
danielwertheim / Query.sql
Created November 6, 2011 20:43
Key-value querying
-- C# Predicate: item.SortOrder == 2 || (item.SortOrder == 1 && item.StringValue == "B").Take(2).SortBy(item => item.StringValue)
-- Existing rows
-- {"StructureId":"208fad84b608e111b21c544249037e42","SortOrder":2,"StringValue":"D"}
-- {"StructureId":"218fad84b608e111b21c544249037e42","SortOrder":2,"StringValue":"C"}
-- {"StructureId":"228fad84b608e111b21c544249037e42","SortOrder":1,"StringValue":"B"}
-- {"StructureId":"238fad84b608e111b21c544249037e42","SortOrder":1,"StringValue":"A"}
@danielwertheim
danielwertheim / gist:1423261
Created December 2, 2011 13:35
Boilerplate stuff for MSpec
public class AssemblyInitializer : IAssemblyContext
{
private static bool _isInitialized;
public void OnAssemblyStart()
{
if (_isInitialized)
return;
_isInitialized = true;
@danielwertheim
danielwertheim / gist:1431128
Created December 4, 2011 20:01
Git .ignore
#v0.12
# Dev stuff
[Aa]pp_[Dd]ata/
[Bb]uild/
[Bb]uilds/
[Oo]bj/
[Bb]in/
[D]ebug/
[Tt]est[Rr]esult/
[Tt]emp/
@danielwertheim
danielwertheim / Factory.cs
Created December 28, 2011 20:36
Some fun with private ctors
public static class Factory<T> where T : class
{
private static readonly Func<T> FactoryFn;
static Factory()
{
//FactoryFn = CreateUsingActivator();
FactoryFn = CreateUsingLambdas();
}