Skip to content

Instantly share code, notes, and snippets.

View mikeminutillo's full-sized avatar
🏠
Working from home

Mike Minutillo mikeminutillo

🏠
Working from home
View GitHub Profile
@mikeminutillo
mikeminutillo / Bootstrap.cs
Created August 8, 2012 07:29
Use Fake implementations at debug time
var builder = new ContainerBuilder();
builder.AddModule(new ModuleA());
builder.AddModule(new ModuleB());
builder.AddModule(new DebugFakesModule());
var container = builder.Build();
// Will be FakeEmailService if compiled with DEBUG
@mikeminutillo
mikeminutillo / DataDictionary.cs
Created August 10, 2012 08:46
LINQPad DataDictionary
var ignoredColumns = new[] {
"CreatedBy",
"CreatedDate",
"ModifiedBy",
"ModifiedDate",
"LogicallyDeletedBy",
"LogicallyDeletedDate",
"LastModified"
};
@mikeminutillo
mikeminutillo / Sample Output
Created August 30, 2012 04:50
LinqPad script to give a nice schedule for TechEd AU 2012
Tuesday
---------------
3:00 PM -> 3:30 PM
Arena 1A Stuff Developers will Want to See
Arena 2 Windows Server 2012 - Prepare to be Amazed
@mikeminutillo
mikeminutillo / Core.cs
Created September 18, 2012 07:55
Arbitrary Attachments on Arbitrary Objects
interface IHaveAttachments { }
interface IAttachment<T> where T : IHaveAttachments {
void AttachTo(T obj);
}
class AttachmentsModule : Autofac.Module
{
private static readonly MethodInfo _attach = typeof(AttachmentsModule).GetMethod("Attach", BindingFlags.Static | BindingFlags.NonPublic);
@mikeminutillo
mikeminutillo / gist:4015997
Created November 5, 2012 08:23
How to determine the Wednesday's in a given date range
void Main()
{
var start = new DateTime(2012, 10, 1);
var end = new DateTime(2012, 10, 31);
var days = from d in start.UpTo(end)
where d.DayOfWeek == DayOfWeek.Wednesday
select d;
@mikeminutillo
mikeminutillo / gist:4016067
Created November 5, 2012 08:38
How to split a list into ‘chunks’ (Fun Code)
void Main()
{
var items = new List<string>{ "A", "B", "C", "D", "E", "F", "G", "H", "I" };
items.Chunk(2).Dump();
}
public static class Ext
{
public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunkSize)
@mikeminutillo
mikeminutillo / gist:4212342
Created December 5, 2012 04:52
Dynamic Dispatch
void Main()
{
DoTheThing(1);
DoTheThing(2);
DoTheThing("Banana");
}
public static void DoTheThing(object o)
{
DoTheThingInternal((dynamic)o);
@mikeminutillo
mikeminutillo / CalendarDates.cs
Last active December 10, 2015 14:39
A way to generate the dates that need to appear on a calendar page
void Main()
{
var refDate = DateTime.Today.AddMonths(-1);
var start = refDate.StartOfMonth().Backwards().FirstOrDefault (d => d.DayOfWeek == DayOfWeek.Monday);
var end = refDate.EndOfMonth().Forwards().FirstOrDefault (d => d.DayOfWeek == DayOfWeek.Sunday);
start.UpTo(end).ToArray().Dump();
}
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Web.DataVisualization.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Web.dll</Reference>
<Namespace>System.Web.UI.DataVisualization.Charting</Namespace>
<Namespace>System.Drawing</Namespace>
</Query>
void Main()
{
var r = new Random();
@mikeminutillo
mikeminutillo / dicetowervideoclassifier.cs
Created April 9, 2013 04:58
Loads all of the videos uploaded by "thedicetower" and categorizes them
void Main()
{
var entries = GetEntries().Cache("from-youtube");
(from e in entries
let category = Categorize(e.Title)
group e by category into g
orderby g.Key descending
select new
{