Skip to content

Instantly share code, notes, and snippets.


James Crowley jamescrowley

View GitHub Profile
ashtonkj / CustomModelBinder.fs
Created Sep 9, 2014
WebApi Default Args Binder
View CustomModelBinder.fs
type CustomBinder() =
interface IModelBinder with
member this.BindModel(actionContext:HttpActionContext, bindingContext :ModelBindingContext) =
let qs = HttpUtility.ParseQueryString(actionContext.Request.RequestUri.Query)
bindingContext.Model <-
if (qs.AllKeys |> Seq.exists(fun q -> q.ToLower() = bindingContext.ModelName.ToLower())) then
qs.[bindingContext.ModelName] |> Some
View MenuExperiments.cs
// Experimental stuff until we get a better picture of how to approach page tree, levels, subpages and such
public class MenuBuilder : IMenuBuilder
private readonly IPages _pages;
private readonly IContextualMenu<Page> _pagesMenu;
private readonly Page _currentPage;
public MenuBuilder(IPages pages, IContextualMenu<Page> pagesMenu, Page currentPage)
CoreyKaylor / ModelUrlResolutionCache.cs
Created Jan 5, 2012
Transforms InputModel for FubuMVC into the route for asset files, this makes routes refactor friendly and safe from route changes
View ModelUrlResolutionCache.cs
public class ModelUrlResolutionCache : IModelUrlResolver
static Cache<string, string> _inputModelTypeCache;
public ModelUrlResolutionCache(IUrlRegistry urlRegistry, BehaviorGraph graph)
if (_inputModelTypeCache == null)
_inputModelTypeCache = new Cache<string, string>(inputModel =>
var inputType = Type.GetType(inputModel)
View Edit.cshtml
@model EditUserModel
@using (Html.BeginForm())
@Html.HiddenFor(m => m.Id)
@Html.TextBoxFor(m => m.FirstName)
@Html.TextBoxFor(m => m.LastName)
@Html.DropDownListFor(m => m.CountryId, Model.Countries)
View DownloadDataBehavior.cs
public class DownloadDataModel
public string Data { get; set; }
public string Filename { get; set; }
public string MimeType { get; set; }
public class DownloadDataBehavior : BasicBehavior
private readonly IFubuRequest _request;
pagebrooks / JsonNetResult.cs
Created Dec 7, 2012
Angular Compatible Date Formatting with JSON.NET
View JsonNetResult.cs
public class JsonNetResult : JsonResult
private readonly static JsonSerializerSettings Settings;
private readonly static IsoDateTimeConverter _dateTimeConverter;
static JsonNetResult()
_dateTimeConverter = new IsoDateTimeConverter();
// Default for IsoDateTimeConverter is yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK
_dateTimeConverter.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFK";
gregoryyoung / gist:4406378
Last active Dec 10, 2015
Sample Event Producer for Projections Demos
View gist:4406378
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using EventStore.ClientAPI;
namespace marketdata
mbenford / Bootstrap.bat
Created May 27, 2013
Bootstrap script to register a Tentacle with an Octopus server and deploy a release to its environment/role. Requires a Tentacle installer and Octo.exe in the same directory of the script.
View Bootstrap.bat
start /wait msiexec /i Octopus.Tentacle.<version>.msi /quiet INSTALLLOCATION=C:\Octopus
cd C:\Octopus\Agent
tentacle configure --appdir="C:\Applications" --port=10933 --trust=<server-thumbprint>
tentacle new-certificate
tentacle install
tentacle register-with --server=<server-url> --environment=<environment> --role=<role> --apikey=<some-user-apikey>
octo deploy-release --project=<project-name> --deployto=<environment-to-deploy> --version=<version-to-deploy> --server=<server-url> --apikey=<some-user-apikey>
mattwarren / gist:1214297
Created Sep 13, 2011
Faceted search SO example
View gist:1214297
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using Raven.Client;
using Raven.Client.Linq;
PaulStovell / Group.cs
Created Mar 31, 2012
Hierarchies in RavenDB
View Group.cs
public class Group
public Group()
Users = new List<string>();
ChildGroups = new List<string>();
public string Id { get; set; }
public string Name { get; set; }