This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SharpLab tools in Run mode: | |
• value.Inspect() | |
• Inspect.Heap(object) | |
• Inspect.Stack(value) | |
• Inspect.MemoryGraph(value1, value2, …) | |
*/ | |
using System; | |
using System.Runtime.InteropServices; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
BadMethod(1,2); | |
BadMethod(2,1); // bang! | |
GoodMethod(2,1); // tadam | |
var uid = (UserId)1; | |
var accid = (AccountId)2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
public class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var summary = BenchmarkRunner.Run<PoolBench>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌──count()─┐ | |
│ 11849659 │ | |
└──────────┘ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |