Skip to content

Instantly share code, notes, and snippets.

View jeremydmiller's full-sized avatar

Jeremy D. Miller jeremydmiller

View GitHub Profile
@jeremydmiller
jeremydmiller / gist:ade21091e00bdf1917b4
Created October 27, 2014 21:10
HtmlTag is "reentrant"
// I can build the tag object, then alter it later
// before rendering it
// makes conventions and more complex html helpers a lot
// easier
var tag = new HtmlTag("div");
tag.AddClass("foo").AddClass("bar");
tag.RemoveClass("foo");
tag.ToString().ShouldContain("bar");
public class HelloWorldFubuRegistry : FubuRegistry
{
public HelloWorldFubuRegistry()
{
IncludeDiagnostics(true);
HomeIs<HomeInputModel>();
Actions
.IncludeClassesSuffixedWithController();
FubuApplication
.For<HelloWorldFubuRegistry>()
.StructureMap(() => new Container())
.Bootstrap(RouteTable.Routes);
@jeremydmiller
jeremydmiller / gist:837065
Created February 21, 2011 13:39
This is what happens
//This feels filthy. Need to make sure we don't overwrite this, and it doesn't get executed when we don't
//want it to, and ... the airbag blows up in my face. Need to clean it up after we are sure this is what
//we want.
@jeremydmiller
jeremydmiller / gist:901627
Created April 4, 2011 13:28
Greasing the generic wheel
// Extension method in FubuCore
public static T CloseAndBuildAs<T>(this Type openType, params Type[] parameterTypes)
{
var closedType = openType.MakeGenericType(parameterTypes);
return (T) Activator.CreateInstance(closedType);
}
// Ahem, uncompleted spike somewhere in FubuMVC I need to strip out or finish...
@jeremydmiller
jeremydmiller / gist:1205989
Created September 9, 2011 11:30
Making an html convention for passwords
public class MyFubuRegistry : FubuRegistry
{
public MyFubuRegistry()
{
HtmlConvention<PasswordConvention>();
}
}
public class PasswordConvention : HtmlConventionRegistry
{
try
{
return true;
}
catch
{
return false;
}
public static class ReaderWriterLockExtensions
{
public static void Write(this ReaderWriterLockSlim rwLock, Action action)
{
rwLock.EnterWriteLock();
try
{
action();
}
finally
public static class ReaderWriterLockExtensions
{
public static void Write(this ReaderWriterLockSlim rwLock, Action action)
{
rwLock.EnterWriteLock();
try
{
action();
}
finally
using BodyAction = Func<
Func< //next
ArraySegment<byte>, // data
Action, // continuation
bool>, // continuation was or will be invoked
Action<Exception>, //error
Action, //complete
Action>; //cancel
using BodyDelegate = System.Func<System.Func<System.ArraySegment<byte>, // data