Skip to content

Instantly share code, notes, and snippets.

View damianh's full-sized avatar
💥

Damian Hickey damianh

💥
View GitHub Profile
@damianh
damianh / LibLogMSOwinLogging.cs
Last active August 1, 2017 16:23
Using LibLog with Microsoft.Owin.Logging
namespace LigLogOwin
{
using System;
using System.Diagnostics;
using LibLogOwin.Logging;
using Microsoft.Owin.Logging;
using Owin;
public class Startup
{
@damianh
damianh / asyncatch.cs
Last active August 29, 2015 14:05
Simulating calling an async method in a catch block. < C# 6
Exception exception;
try
{
await Foo();
}
catch(Exception ex)
{
exception = ex;
}
if(exception != null)
@damianh
damianh / NEventStoreBoxstarter
Last active August 29, 2015 14:04
Boxstarter script to initialize a VM for NEventStore acceptance tests. START http://boxstarter.org/package/nr/url?http://goo.gl/6ExUZG
Set-ExplorerOptions -showFileExtensions
Enable-RemoteDesktop
choco install classic-shell
choco install GoogleChrome
choco install postgresql
choco install mysql
choco install pgadmin3
@damianh
damianh / Middleware.cs
Last active August 29, 2015 14:03
Static middleware template
using AppFunc = Func<IDictionary<string, object>, Task>;
using MidFunc = Func<
Func<IDictionary<string, object>, Task>,
Func<IDictionary<string, object>, Task>
>;
public static class MyMiddleware
{
public static MidFunc UseMyMiddleware()
{
@damianh
damianh / RequestIdMiddleware.cs
Created May 28, 2014 13:09
Owin Request Id middlware
namespace Owin
{
using System;
using System.Globalization;
using System.Threading;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>
>;
@damianh
damianh / NancyOwinSelfHostWindowsAuth.cs
Created April 8, 2014 03:10
Nancy owin self hosting with Microsoft.Owin.HttpListener and windows authentication on .NET 4.0 (Personal opinion: avoid windows NTLM auth in web applications, even intranet ones. Use standards based SSO.)
namespace ConsoleApplication1
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Principal;
using Microsoft.Owin.Hosting;
using Nancy;
using Owin;
@damianh
damianh / Rename-Project.psm1
Last active May 25, 2018 23:10
Renames a csproj - Project Name, DirectoryName, AssemblyName and references to the project
# Works for me. You may need to tweak it. Stick it in your powershell profile FTW
function Rename-Project
{
# designed to run from the solution directory where the project is a child directory
param(
[string]$projectName=$(throw "projectName required."),
[string]$newProjectName=$(throw "newProjectName required.")
)
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace Microsoft.Owin.FileSystems
{
/// <summary>
namespace TestinNancyWithOwinTesting
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Testing;
using Owin;
using Microsoft.Owin.Testing;
@damianh
damianh / WindowChromeExample.xml
Created June 26, 2013 12:04
The XAML in http://msdn.microsoft.com/en-us/library/system.windows.shell.windowchrome.aspx is copied from the Microsoft.Windows.Shell project but hasn't been updated to reflect the new namespace in .net 4.5. This is the correct XAML.
<Style TargetType="{x:Type local:MainWindow}">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MainWindow}">
<Grid>