Skip to content

Instantly share code, notes, and snippets.

View jeremydmiller's full-sized avatar

Jeremy D. Miller jeremydmiller

View GitHub Profile
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
@jeremydmiller
jeremydmiller / gist:1827533
Created February 14, 2012 15:23
Polling for a condition -- only to be used in automated testing code
public static class Wait
{
public static void Until(Func<bool> condition, int millisecondPolling = 500, int timeoutInMilliseconds = 5000)
{
if (condition()) return;
var reset = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(o =>
{