Skip to content

Instantly share code, notes, and snippets.

@CoreyKaylor
CoreyKaylor / Main.kt
Created Jun 17, 2018
ktor structured logging - relies on logstash-logback-encoder
View Main.kt
fun main(args: Array<String>) {
val server = embeddedServer(Netty, port = 9000) {
intercept(ApplicationCallPipeline.Infrastructure) {
val requestId = UUID.randomUUID()
log.attach("req.Id", requestId.toString(), {
log.info("Interceptor[start]")
proceed()
log.info("Interceptor[end]")
})
}
@CoreyKaylor
CoreyKaylor / SendEmailBehavior.cs
Created Feb 18, 2013
Gimped sample of sending an email with fubu
View SendEmailBehavior.cs
public class SendEmailNowBehavior<TResponse> : IActionBehavior
where TResponse : RenderEmailBase
{
private readonly IOutputWriter _outputWriter;
private readonly IFubuRequest _fubuRequest;
private readonly IMailer _mailer;
public SendEmailNowBehavior(IOutputWriter outputWriter, IFubuRequest fubuRequest, IMailer mailer)
{
_outputWriter = outputWriter;
@CoreyKaylor
CoreyKaylor / Home.cshtml
Created Feb 16, 2013
View for ContentExtension feature toggle.
View Home.cshtml
@model FeatureToggleSample.HomeModel
<!DOCTYPE html>
<html>
<head>
<title>Toggling Features</title>
</head>
<body>
<div>
@CoreyKaylor
CoreyKaylor / FeatureSettings.cs
Last active Dec 13, 2015
Feature toggle boilerplate
View FeatureSettings.cs
public class FeatureSettings
{
public bool SpecialFeatureEnabled { get; set; }
public bool SomeOtherFeatureEnabled { get; set; }
}
@CoreyKaylor
CoreyKaylor / FeatureToggleRegistry.cs
Last active Dec 13, 2015
StructureMap magic to make AppSettings suck less.
View FeatureToggleRegistry.cs
public class FeatureToggleRegistry : Registry
{
public FeatureToggleRegistry()
{
Scan(x =>
{
x.TheCallingAssembly();
x.Convention<SettingsConvention>();
});
}
View Application.cshtml
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<header><h1>Hello from Layout</h1></header>
<div>
@RenderBody()
View gist:4243501
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
@CoreyKaylor
CoreyKaylor / web.config
Created Nov 19, 2012
Getting Started with FubuMVC Again
View web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
@CoreyKaylor
CoreyKaylor / Home.spark
Created Nov 18, 2012
Getting Started with FubuMVC Again
View Home.spark
<viewdata model="HelloWorld.Features.Home.HomeViewModel" />
<h1>Hello ${Model.Message}</h1>
@CoreyKaylor
CoreyKaylor / Global.asax.cs
Created Nov 18, 2012
Getting Started with FubuMVC Again
View Global.asax.cs
using System;
using FubuMVC.Core;
using FubuMVC.StructureMap;
using StructureMap;
namespace HelloWorld
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)