Skip to content

Instantly share code, notes, and snippets.

View bartelink's full-sized avatar

Ruben Bartelink bartelink

View GitHub Profile
public static TRes Match<T,TRes>(this FSharpOption<T> opt, Func<T,TRes> some, Func<TRes> none)
{
if (FSharpOption<T>.get_IsSome(opt))
return some.Invoke(opt.Value);
else
return none.Invoke();
}
@bartelink
bartelink / Consolidate-VSFindInFilesSpec.ps1
Last active January 4, 2016 09:09
Ugly hacky script to generate a VS Find in Files uber-Filter
# TODO dig out of registry instead of cutting and pasting from VS!
$x="*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc;*.cs;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css;*.vb;*.resx;*.xsd;*.wsdl;*.htm;*.html;*.aspx;*.ascx;*.asmx;*.svc;*.asax;*.config;*.asp;*.asa;*.cshtml;*.vbhtml;*.css;*.xml;*.xml;*.xsl;*.xslt;*.xsd;*.dtd;*.srf;*.htm;*.html;*.xml;*.gif;*.jpg;*.png;*.css;*.disco;*.txt;*.json;*.vb;*.resx;*.xsd;*.wsdl;*.htm;*.html;*.aspx;*.ascx;*.asmx;*.svc;*.asax;*.config;*.asp;*.asa;*.cshtml;*.vbhtml;*.css;*.xml;*.cs;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css"
$x+=";*.fs;*.json;*.ts"
# strip *.
$all = $x.Split( ";") | % { $_.Replace("*.","") }
#xml fins too much junk in obj dirs
@bartelink
bartelink / DiagnosticFeatures.fs
Last active December 24, 2015 12:58
My TickSpec.xunit boilerplate (just add .feature files as EmbeddedResources and group them into XXXFeatures.fs as in the example DiagnosticFeatures.fs file)
open TickSpec
open Features
module DiagnosticFeatures =
[<TickFact>]
let ConnectivityFeature () =
generateScenariosFromEmbeddedFeatureFile "Connectivity"
@bartelink
bartelink / gist:5671464
Created May 29, 2013 16:04
Ninject Scoping Learnings and Tests to accompany http://stackoverflow.com/a/15836383/11635
public static class NinjectScopingLearning
{
public static class InParentScope
{
[Fact]
public static void WorksIffParentScopeAllWayUp()
{
var kernel = new StandardKernel();
kernel.Bind<Root>().ToSelf().InSingletonScope();
kernel.Bind<Child>().ToSelf().InParentScope();
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Xunit.Extensions;
namespace Prototypes.AutoFixture.Xunit.Extensions
{
public class CompositeDataAttribute : DataAttribute
@bartelink
bartelink / describe_AClass.cs
Created September 14, 2012 09:01
Row test in NSpec
/*
output of the row test below
describe AClass
describe many variations
A should equal A
C should equal A - [Failed]
*/
//top level context to describe class
class describe_AClass
static class Program
{
static void Main()
{
var x = new { a=0, b=1 };
f( x );
}
static void f(dynamic x)
{
Console.WriteLine(x.b);
@bartelink
bartelink / PostProcessWhereIsACustomization.cs
Last active September 11, 2020 08:00
AutoFixture customization to allow insertion of arbitrary postprocessing logic a la Customize( c=>c.Do()) but in a global manner Revised for v3 (initally for v2)
namespace Ploeh.AutoFixture
{
using Kernel;
using System;
public class PostProcessWhereIsACustomization<T> : ICustomization
where T : class
{
readonly PostProcessSpecimensBehavior _behavior;
@bartelink
bartelink / ClassAutoData.cs
Created July 17, 2012 13:17
ClassAutoData spiking
[Theory]
[ClassAutoData( typeof( XProvider ) )]
public static void Scenario( X x, string y )
{
Console.WriteLine( x + "," + y );
}
public class ClassAutoDataAttribute : CompositeDataAttribute
{
public ClassAutoDataAttribute( Type @class )
@bartelink
bartelink / Get-GrepWinClipboardFiles.ps1
Created July 4, 2012 11:41
Get-GrepWinClipboardFiles. Example: Get-GrepWinClipboardFiles| %{ tf checkout $_ }
function Get-ClipboardText {
$command = {
add-type -an system.windows.forms
[System.Windows.Forms.Clipboard]::GetText()
}
powershell -sta -noprofile -command $command
}
function Get-GrepWinClipboardFiles() {
get-ClipboardText | ConvertFrom-Csv -del "`t" | %{ $_.Path+"\"+$_.Name }