Skip to content

Instantly share code, notes, and snippets.

View megasuperlexa's full-sized avatar
♠️
Focusing

megasuperlexa

♠️
Focusing
View GitHub Profile
@megasuperlexa
megasuperlexa / Dockerfile
Last active June 28, 2024 08:49
Docker that extends existing .net app image with memory dump tools (Debian)
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS tools-install
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-sos
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-trace
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-dump
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-counters
FROM {your-image-location-and-name:1.1.1-release-1.0.0}
USER 0
@megasuperlexa
megasuperlexa / git-prunelocal
Created June 21, 2024 14:50 — forked from leshill/git-prunelocal
Prune local tracking branches that have been removed upstream. Place file in your path (perhaps `~/bin` or `~/scripts`).
#!/bin/bash
#
# Prune local tracking branches that have been removed upstream.
# Your remote tracking branches can be removed automatically by setting `fetch.prune` to true or running `git fetch -prune`.
# Another command to clean up your remote tracking branches is `git remote prune <remote>`.
#
# Author: @leshill
# https://gist.github.com/leshill/9a1088a17f94cef24831
if [[ $# = 1 && $1 == '-n' ]]; then
@megasuperlexa
megasuperlexa / csv-splitter.sh
Last active June 13, 2024 07:00
CSV splitter
#!/bin/bash
#split csv file with header into separate files based on key column (input should be sorted by key column)
if [ $# -eq 0 ]; then
echo "Usage: $0 <input_csv_file>"
exit 1
fi
INPUT_CSV="$1"
┌──count()─┐
│ 11849659 │
└──────────┘
@megasuperlexa
megasuperlexa / Program.cs
Created March 17, 2024 08:59
Array pool perf
using System.Buffers;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public class Program
{
private static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<PoolBench>();
}
using System;
BadMethod(1,2);
BadMethod(2,1); // bang!
GoodMethod(2,1); // tadam
var uid = (UserId)1;
var accid = (AccountId)2;
/*
SharpLab tools in Run mode:
• value.Inspect()
• Inspect.Heap(object)
• Inspect.Stack(value)
• Inspect.MemoryGraph(value1, value2, …)
*/
using System;
using System.Runtime.InteropServices;
@megasuperlexa
megasuperlexa / 1.cs
Last active March 23, 2018 09:12
Memoize example
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
public static class Program
{
public static Func<T, V> MemoizeExt<T, V>(this Func<T, V> f) => a =>
new ConcurrentDictionary<T, V>().GetOrAdd(a, f);
public static Func<T, V> Memoize<T, V>(Func<T, V> f) => a =>