Skip to content

Instantly share code, notes, and snippets.

@ShawInnes
ShawInnes / LocalDbTestHelper.cs
Created July 14, 2014 06:00
LocalDb helper for unit testing with EF
public class LocalDb : IDisposable
{
public static string DatabaseDirectory = "Data";
public string ConnectionStringName { get; private set; }
public string DatabaseName { get; private set; }
public string OutputFolder { get; private set; }
public string DatabaseMdfPath { get; private set; }
public string DatabaseLogPath { get; private set; }
public LocalDb(string databaseName = null)
@ShawInnes
ShawInnes / MonoCecilReferenceCount.cs
Created July 11, 2014 06:38
Mono.Cecil Get Method Reference Count
private static int GetReferenceCount(Type type, string undesiredTypeName)
{
UriBuilder uri = new UriBuilder(type.Assembly.CodeBase);
string path = Uri.UnescapeDataString(uri.Path);
AssemblyDefinition assemblyDefinition = AssemblyDefinition.ReadAssembly(path);
TypeDefinition vm = assemblyDefinition.Modules.SelectMany(m => m.GetTypes().Where(p => p.FullName == type.FullName)).Single();
int referenceCount = vm.Methods.Where(p => p.HasBody)
.SelectMany(p => p.Body.Instructions.Where(i => i.OpCode.Code == Mono.Cecil.Cil.Code.Call &&
((Mono.Cecil.MethodReference)i.Operand).DeclaringType.FullName.Equals(undesiredTypeName))).Count();
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Collections.Generic;
class NullShadowBuilder : View.DragShadowBuilder
{
const int centerOffset = 52;
int width, height;
public NullShadowBuilder (View baseView) : base (baseView)
{
}
public override void OnProvideShadowMetrics (Point shadowSize, Point shadowTouchPoint)
@ShawInnes
ShawInnes / TestSetup.ps1
Created June 3, 2014 01:06
NUnit Test Goodness
# Paste this into Package Manager Console of Visual Studio
foreach ($thing in @("NUnit", "NUnit.Extensions", "NUnitTestAdapter", "Shouldly")) { Install-Package $thing }
@ShawInnes
ShawInnes / sff2014.md
Last active August 29, 2015 14:00
Spanish Film Festival 2014

Spanish Film Festival 2014

Film Date Time Venue Seat Suncorp
Living is Easy... Thu 1 May 7.00pm Barracks H10
Barcelona Summer Night Fri 2nd May 8.45pm Barracks H10
Alpha Sat 3rd May 4.00pm Barracks H10
Zip & Zap... Sun 4 May 1.45pm Barracks H10 2pm
The Forest Mon 5 May 8.45pm Barracks H10
@ShawInnes
ShawInnes / ReleaseNotes.cs
Last active August 29, 2015 13:57 — forked from PaulStovell/ReleaseNotes.py
C# Version of Paul Stovell's Release Notes Builder.
//
// Fork of https://gist.github.com/PaulStovell/9593947
// Uses: https://github.com/octokit/octokit.net
// NuGet: Install-Package Octokit
//
var connection = new Connection(new ProductHeaderValue("ReleaseNotesGenerator"));
connection.Credentials = new Credentials(Util.GetPassword("github.username"), Util.GetPassword("github.password"));
var apiConnection = new ApiConnection(connection);
@ShawInnes
ShawInnes / Startup.cs
Created February 26, 2014 07:07
OWIN Authentication Startup.cs
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
using Owin.Security.Providers.GitHub;
using Owin.Security.Providers.LinkedIn;
using Owin.Security.Providers.Yahoo;
using Owin.Security.Providers.Reddit;
using Microsoft.Owin.Security.WsFederation;
using Microsoft.Owin.Security.Cookies;
@ShawInnes
ShawInnes / packages.config
Created February 26, 2014 07:06
All NuGet Packages for All
<package id="Microsoft.Owin.Security" version="3.0.0-alpha1" targetFramework="net451" />
<package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net451" />
<package id="Microsoft.Owin.Security.WsFederation" version="3.0.0-alpha1" targetFramework="net451" />
<package id="Owin.Security.Providers" version="1.3" targetFramework="net451" />
@ShawInnes
ShawInnes / AssemblyVersion.tt
Created February 22, 2014 13:43
Automatic AssemblyVersion File - T4 Template
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="EnvDTE" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="System.IO" #>
<#
var hostServiceProvider = (IServiceProvider)Host;
var dte =
(EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE));
var activeSolutionProjects = (Array)dte.ActiveSolutionProjects;