Skip to content

Instantly share code, notes, and snippets.

cat "$1" | base64 | perl -wp -e 's/(^.*$)/data:image\/jpeg;base64,$1/'
@djeikyb
djeikyb / 20210920.gitconfig
Created September 20, 2021 18:52
current gitconfig
[user]
name = Jacob Certain
email = [email protected]
[alias]
changelog = log --format='* %s%n%w(,4,4)%+b'
pick = cherry-pick
logg = log-oneline-graph
s = status --short --branch --untracked-files=all
l = log --graph --pretty=format:'%C(auto)%h %ad %d %s %C(white)[%aN]' --date='format:%b %d' --use-mailmap origin/master~10..HEAD
; ll = log --graph --pretty=format:'%C(auto)%h %ad %d %s %C(white)[%aN]' --date='format:%b %d' --remotes '@{upstream}' origin/master~10..HEAD
@djeikyb
djeikyb / MassTransitDispatchByMessageTypeParameter.cs
Last active August 30, 2021 22:40
Demonstrates how a single consumer could be used to apply domain logic to many different models that can be described by a common interface.
using System.Threading.Tasks;
using MassTransit;
using MassTransit.Mediator;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Sinks.SystemConsole.Themes;
namespace Trolley
{
@djeikyb
djeikyb / jwt
Last active December 23, 2021 01:35
decodes your jwt aka cli version of jwt.io
#!/bin/sh
SELF=${0##*/}
die() {
log "$@"
exit 1
}
log() {
@djeikyb
djeikyb / withSecrets
Created August 4, 2021 22:18
Launch an app with environment variables pulled from aws secrets manager
#!/bin/sh
SELF=${0##*/}
die() {
log "$@"
exit 1
}
log() {
private async IAsyncEnumerable<MemoryStream> YieldStreams(params byte[][] bs)
{
// The compiler turns async + yield return type T into the
// desired return type of IAsyncEnumerable<T>. But we don't
// actually have any async code, just need the type. Soooo
await Task.CompletedTask; // hack to evade compiler warning
foreach (var b in bs) yield return new MemoryStream(b);
}
@djeikyb
djeikyb / ClefToHoneycomb.cs
Last active June 29, 2021 20:19
Ports a dump of structured logs in clef form into honeycomb (ie you Extract from seq, this will Transform and Load)
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Json;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
@djeikyb
djeikyb / EventCentricSerilogFormatter.cs
Created May 25, 2021 22:24
Personal serilog console formatter that incentivizes high cardinality logs
using System.IO;
using Serilog.Events;
using Serilog.Formatting;
namespace com.example
{
public class EventCentricSerilogFormatter : ITextFormatter
{
private const string FgBrightWhite = "\x001B[97m";
private const string Reset = "\x001B[0m";
@djeikyb
djeikyb / Program.cs
Last active September 15, 2021 11:18
Example in-memory message pipeline with dotnet 5 and mediatr; includes request logging and root level exception handler Raw
using System;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using MediatR.Pipeline;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@djeikyb
djeikyb / xunit_logger.cs
Created April 14, 2021 21:23
the simplest possible bridge between xunit and microsoft's ilogger
using System;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
public class XunitLogger<T> : ILogger<T>
{
private readonly ITestOutputHelper _outputHelper;
public XunitLogger(ITestOutputHelper outputHelper)
{