Skip to content

Instantly share code, notes, and snippets.

View Kritner's full-sized avatar

Russ Hammett Kritner

View GitHub Profile
@Kritner
Kritner / sp_who2__toTableVariable.sql
Created December 16, 2015 15:06
SQL to create a table variable that will hold sp_who2 information so it's queryable
-- Create a variable table to hold the results of sp_who2 for querying purposes
DECLARE @who2 TABLE (
SPID INT NULL,
Status VARCHAR(1000) NULL,
Login SYSNAME NULL,
HostName SYSNAME NULL,
BlkBy SYSNAME NULL,
DBName SYSNAME NULL,
Command VARCHAR(8000) NULL,
@Kritner
Kritner / gist:8e734313797f83cb7cdec19a6402d5b9
Last active June 8, 2016 13:27
Is this the mediator pattern?
public interface IGetData
{
IEnumerable<MyData> Execute();
}
public interface IProcessData
{
IEnumerable<MyProcessedData> Execute(IEnumerable<MyData> data);
}
@Kritner
Kritner / OriginalIdeaFoo.cs
Last active December 13, 2016 13:25
How to test potentially complicated internals of a class?
// Pretend more profound implementation, where the privates are actually involved and complicated.
public class Foo
{
public object DoThing()
{
return DoAPartOfThing();
}
public object UndoThing()
@Kritner
Kritner / Alphabetical.cs
Last active December 13, 2016 13:26
Alphabetical method ordering vs Newpaper method ordering
public class Foo
{
public virtual void Entry()
{
Zed();
for (int round = 1; round < 10; round++)
{
Bwar();
Aroo();
Rakanishu();
@Kritner
Kritner / ComplicatedBusiness.cs
Last active December 13, 2016 13:26
Many constructor parameters or a wrapper class for constructor parameters?
public class Foo
{
public Foo(IService1 service1, IService2 service2, IService3 service3, IService4 service4, IService5 service5)
{
// ...
}
}
@Kritner
Kritner / TestingAssemblyLocation.cs
Last active December 13, 2016 13:27
Testing Assembly location
// This seems to work with the differences between NUnit runner, ReSharper runner, and dotCover runner - have not yet tested w/ team city dotCover.
/// <summary>
/// NUnit test runner and ReSharper test runner start from different directories. Get a consistent start directory for the runners.
/// </summary>
/// <example>
/// ReSharper:
/// C:\Users\myUser\Documents\project\test\NameSpace.Tests\bin\Release\
/// Nunit:
/// C:\Users\myUser\Documents\project\test\NameSpace.Tests\
@Kritner
Kritner / generics.cs
Created December 21, 2016 17:30
Generics vs interfaces? What does it get me?
public interface IFoo { }
public class Something<TFoo>
where TFoo : IFoo
{
public void DoSomething(TFoo foo)
{
}
}
@Kritner
Kritner / Main.cs
Last active March 9, 2017 14:34
Changed loop max within loop body
using System;
public class Program
{
public static void Main()
{
Thing thing = new Thing();
for (int i = 0; i < thing.GetIterations; i++)
{
@Kritner
Kritner / Original.cs
Last active May 31, 2017 18:48
List of tuples for factory branching removal
public interface IFoo { }
public class FooOne : IFoo { }
public class FooTwo : IFoo { }
public class FooFourtyTwo : IFoo { }
public class FooFace : IFoo { }
public class FooNull : IFoo { }
public class Whatever
{
public IFoo GetFoo(bool someFlag, string someLabel)
@Kritner
Kritner / Old.cs
Last active June 2, 2017 12:29
Old vs new (Tuples)
private readonly List<Tuple<bool, string, IFoo>> myTypes = new List<Tuple<bool, string, IFoo>>()
{
new Tuple<bool, string, IFoo>(true, "Test", new FooOne()),
new Tuple<bool, string, IFoo>(true, "blah blah", new FooTwo()),
new Tuple<bool, string, IFoo>(false, "Test", new FooFourtyTwo()),
new Tuple<bool, string, IFoo>(false, "blah blah", new FooFace()),
};
public void Thinger()
{