Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CoreyKaylor
CoreyKaylor / Main.kt
Created June 17, 2018 17:22
ktor structured logging - relies on logstash-logback-encoder
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]")
})
}
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseServices(services =>
{
services.AddMvc();
services.SetupOptions<MvcOptions>(x =>
public class ViewDataForActivation
{
[Activate]
public ViewDataDictionary ViewData { get; set; }
}
using MvcSample.Web.Models;
namespace MvcSample.Web
{
public class HomeController
{
public User Index()
{
var user = new User
{

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@CoreyKaylor
CoreyKaylor / CustomerEndpoints.fs
Last active August 29, 2015 13:57
F# FubuMVC Endpoints Hypothetical
module CustomerEndpoints
let ``GET /customers/list`` (repository: ICustomerRepository) =
repository.List
|> Seq.map customerToViewRecord
type GetCustomerInput = {Id: int;}
let ``GET /customers/{Id}`` (repository: ICustomerRepository) (input: GetCustomerInput) =
repository.Get input.Id |> customerToViewRecord
@CoreyKaylor
CoreyKaylor / SendEmailBehavior.cs
Created February 18, 2013 15:44
Gimped sample of sending an email with fubu
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 / FeatureToggleRegistry.cs
Last active December 13, 2015 20:19
StructureMap magic to make AppSettings suck less.
public class FeatureToggleRegistry : Registry
{
public FeatureToggleRegistry()
{
Scan(x =>
{
x.TheCallingAssembly();
x.Convention<SettingsConvention>();
});
}
@CoreyKaylor
CoreyKaylor / FeatureSettings.cs
Last active December 13, 2015 20:19
Feature toggle boilerplate
public class FeatureSettings
{
public bool SpecialFeatureEnabled { get; set; }
public bool SomeOtherFeatureEnabled { get; set; }
}
@CoreyKaylor
CoreyKaylor / Home.cshtml
Created February 16, 2013 23:55
View for ContentExtension feature toggle.
@model FeatureToggleSample.HomeModel
<!DOCTYPE html>
<html>
<head>
<title>Toggling Features</title>
</head>
<body>
<div>