Skip to content

Instantly share code, notes, and snippets.

using Ardalis.GuardClauses;
using Microsoft.Extensions.Logging;
public static class LoggerExtensions
{
/// <summary>
/// Begins a logical operation scope.
/// </summary>
/// <example>
/// <para>

Shell into an AWS cloud docker container (ecs / fargate) without ssh

Like [docker exec][1] or [docker compose exec][0]!

You want to think of it a little differently than the docker version though. With docker, you can exec into any container managed by your own docker engine. With aws, you can't. You have to start an exec capable container whenever you need to debug a docker image.

When to use this

using System;
using Xunit;
using Xunit.Abstractions;
namespace Example;
public class TypeChecking
{
private readonly ITestOutputHelper _testOutputHelper;
using System;
using System.Collections.Generic;
using System.IO;
using Serilog.Events;
using Serilog.Formatting;
namespace com.example
{
public class HighCardinalitySerilogFormatterConfig
{
@djeikyb
djeikyb / find_delete_bin_obj_dirs_dotnet.md
Last active March 17, 2022 19:26
find and delete dotnet's bin/ and obj/ dirs adjacent to csproj files

find and delete bin/ and obj/ dirs adjacent to csproj files

find . -iname '*.csproj' -type f -print0 | xargs -0 -I{} sh -c 'rm -r $(dirname {})/{bin,obj}'
  1. find files with the csproj suffix
  2. output using null termination to help safely handle file names
  3. xargs option -0 signals the input lines are null terminated
  4. xargs option -p could prompt before executing
  5. xargs option -I designates the placeholder string
  6. run in a new shell process, because i want to use shell expansion techniques AFTER interpolation occurs
@djeikyb
djeikyb / EnumSwitchException.cs
Last active October 29, 2021 00:25
An exception to throw in the default branch of a switch..case that ought to be exhaustive
using System;
namespace Example
{
/// <summary>
/// </summary>
/// <typeparam name="T">Must be an enum type</typeparam>
/// <remarks>
/// Follows the pattern of <see cref="SwitchExpressionException"/>
/// </remarks>
@djeikyb
djeikyb / XunitLogger.cs
Last active October 20, 2021 22:10
A barely functional logger to standard out for xunit
using System;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
namespace Example
{
public class XunitLogger<T> : ILogger<T>
{
private readonly ITestOutputHelper _outputHelper;
@djeikyb
djeikyb / HttpSpy.cs
Last active November 15, 2023 21:26
Spies on http interactions and logs the details
// License is 0BSD
// https://gist.github.com/djeikyb/b7d7b7afdc651396b90a5cb2279b58b9
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Mime;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
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 = jacob.certain@eikon.group
[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