Skip to content

Instantly share code, notes, and snippets.

View phillip-haydon's full-sized avatar
💭
Banana's are yellow.

Phillip Haydon phillip-haydon

💭
Banana's are yellow.
View GitHub Profile
@phillip-haydon
phillip-haydon / Blobbed.cs
Created February 28, 2012 23:35
NHibernate Custom User Type for serializing a property to JSON
[Serializable]
public class Blobbed<T> : IUserType where T : class
{
public new bool Equals(object x, object y)
{
if (x == null && y == null)
return true;
if (x == null || y == null)
return false;
@phillip-haydon
phillip-haydon / program.cs
Created March 4, 2012 11:50
RavenDB Projection Sample
using System;
using System.Collections.Generic;
using System.Linq;
using Raven.Abstractions.Indexing;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Indexes;
using Raven.Client.Linq;
namespace RavenDBProjectionTest
@phillip-haydon
phillip-haydon / gist:3798206
Created September 28, 2012 06:15
Dynamic Chained API (playing around to see possibilities)
using System;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using Raven.Client;
using Raven.Client.Document;
using Raven.Json.Linq;
namespace ChainedAPISample
@phillip-haydon
phillip-haydon / gist:4089657
Last active October 12, 2015 21:28
Custom Route Builder for Nancy
public class NancyModule : NancyModule<RouteBuilder>
{
}
public class NancyModule<T> where T : RouteBuilder
{
private static ConcurrentDictionary<Type, Func<object>> CompiledRouteBuilders = new ConcurrentDictionary<Type, Func<object>>();
public virtual T Get
{
@phillip-haydon
phillip-haydon / gist:4134416
Created November 23, 2012 07:47
Granular Route Extensions for Nancy
public class HomeModule : NancyModule
{
public HomeModule()
{
this.RequireClaim("stuff")
.For("GET")
.On("/test/{claim}")
.With(o =>
{
return "YAY";
namespace NooVerbs
{
public class MyBadgerModule : NooModuleBase
{
public MyBadgerModule()
{
this.Get["/"] = _ => "erm";
}
}
}
@phillip-haydon
phillip-haydon / JabbRAuthenticationCallbackProvider.cs
Created January 30, 2013 15:41
JabbRAuthenticationCallbackProvider used by JabbR, mirrored here for blog post to prevent dead-links in the future.
using System;
using JabbR.Infrastructure;
using JabbR.Models;
using JabbR.Services;
using Nancy;
using Nancy.Authentication.WorldDomination;
using WorldDomination.Web.Authentication;
namespace JabbR.Nancy
{
@phillip-haydon
phillip-haydon / gist:5040140
Created February 26, 2013 17:03
Create Message on Amazon SQS with WinRT
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using NUnit.Framework;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
class Program
{
static void Main(string[] args)
{
var bunchOfValues = new List<Banana>
{
new Banana(),
new Banana(),
new Banana(),
new Banana(),
@phillip-haydon
phillip-haydon / gist:5371088
Created April 12, 2013 10:24
.NET 4 gave us clean config files, then MVC + WebAPI produced this...
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>