Skip to content

Instantly share code, notes, and snippets.

View KevM's full-sized avatar

Kevin Miller KevM

View GitHub Profile
public interface IMessageConsumer<MESSAGE> : Consumes<MESSAGE>.All where MESSAGE : class
{ }
public class YourRegistry : Registry
{
public YourRegistry()
{
Scan(scan =>
{
[TestFixture]
public class topshelf_configuration_extension
{
[Test]
public void required_simple_services_should_be_registed_with_topshelf()
{
var container = new Container(c=>c.For<IRequiredService>().Use<TestRequiredService>());
var logger = MockRepository.GenerateMock<ILogger>();
var runConfiguration = RunnerConfigurator.New(config => config.ConfigureRequiredServices(container, logger));
@KevM
KevM / Takei-voicemail.txt
Created October 30, 2010 04:09
2010 Halloween episode of Community included George Takei gifting a voice mail greeting to all Kevins out there.
George Takei's totally random inclusion as a narrator was the type of non-sequitur humor that Community does so incredibly well.
Ending the episode by having him give the gift of an awesome voicemail message to everyone named Kevin.
"If your name's Kevin, here's a little freebie for your cellphone.
'Hi. Kevin can't come to the phone. He's on a spaceship with me, George Takei.Please leave a message.'"
http://ology.com/screen/nbcs-thursday-night-recap-community-office-and-outsourced
@KevM
KevM / HtmlConventionForDate.cs
Created December 15, 2010 16:49
My first html convention in FubuMVC. If the property is a datetime and ends with Date only output the date part of the datetime.
public class DovetailHtmlConventions : HtmlConventionRegistry
{
public DovetailHtmlConventions()
{
Displays
.If(def => typeof (DateTime).IsAssignableFrom(def.Accessor.PropertyType) && def.Accessor.Name.EndsWith("Date"))
.Modify((req, tag) =>
{
var date = (DateTime) req.RawValue;
tag.Text(date.ToShortDateString());
public class ModelMapSchemaValidationSource : IValidationSource
{
private readonly IContainer _container;
private readonly SchemaValidationVisitor _schemaValidationVisitor;
public ModelMapSchemaValidationSource(IContainer container, SchemaValidationVisitor schemaValidationVisitor)
{
_container = container;
_schemaValidationVisitor = schemaValidationVisitor;
}
@KevM
KevM / web.config.xml
Created January 11, 2011 20:21
Custom Errors Enabled
<customErrors defaultRedirect="~/500" mode="On">
<error statusCode="500" redirect="~/500" />
<error statusCode="403" redirect="~/403" />
<error statusCode="404" redirect="~/404" />
</customErrors>
public class Global : HttpApplication
{
protected void Application_OnError()
{
if (Context.IsCustomErrorEnabled && isAjaxRequest())
{
// By default, customErrors will cause a 302 redirect
// We really want a 500 response, so that the client request knows there was an error
error_without_redirect();
}
@KevM
KevM / MailMessageExtensions.cs
Created April 1, 2011 15:21
Extension class to make handling MailBee MailMessage IDs now that they have brackets in them.
using MailBee.Mime;
namespace Dovetail.Carrier.EmailServices
{
public static class MailMessageExtensions
{
public static string GetMessageIdSansBrackets(this string messageId)
{
return messageId.TrimStart('<').TrimEnd('>');
}
@KevM
KevM / email-config-tester.cs
Created June 8, 2011 21:11
Email account configuration test console utility
var container = new Container(x =>
{
x.AddRegistry<SettingsRegistry>();
x.AddRegistry<CommonsRegistry>();
x.AddRegistry<EmailServicesRegistry>();
});
var accountRepository = container.GetInstance<IEmailAccountRepository>();
var connectionManager = container.GetInstance<IMailBeeConnectionManager>();
var logger = container.GetInstance<ILogger>();
@KevM
KevM / with_timer.cs
Created June 29, 2011 19:24
Stopwatch wrapper
private T with_timer<T>(Func<T> action)
{
Stopwatch sw = Stopwatch.StartNew();
var result = action();
sw.Stop();
TimeSpan time = sw.Elapsed;
System.Console.WriteLine("Time: {0:00}:{1:00}:{2:00}.{3:000}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);