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]")
})
}
View Startup.cs
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseServices(services =>
{
services.AddMvc();
services.SetupOptions<MvcOptions>(x =>
View ViewDataForActivation.cs
public class ViewDataForActivation
{
[Activate]
public ViewDataDictionary ViewData { get; set; }
}
View HomeController.cs
using MvcSample.Web.Models;
namespace MvcSample.Web
{
public class HomeController
{
public User Index()
{
var user = new User
{
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@CoreyKaylor
CoreyKaylor / CustomerEndpoints.fs
Last active Aug 29, 2015
F# FubuMVC Endpoints Hypothetical
View CustomerEndpoints.fs
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 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 / 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>();
});
}
@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 / 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>