BenchmarkDotNet v0.13.6, macOS Ventura 13.4.1 (c) (22F770820d) [Darwin 22.5.0]
Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK 7.0.102
[Host] : .NET 7.0.2 (7.0.222.60605), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.2 (7.0.222.60605), X64 RyuJIT AVX2
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
SELECT | |
table_name, | |
pg_size_pretty(table_size) AS table_size, | |
pg_size_pretty(indexes_size) AS indexes_size, | |
pg_size_pretty(total_size) AS total_size | |
FROM ( | |
SELECT | |
table_name, | |
pg_table_size(table_name) AS table_size, | |
pg_indexes_size(table_name) AS indexes_size, |
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
public static string ToFormattedCapacityUnits(this ConsumedCapacity c) | |
{ | |
var sb = new StringBuilder(); | |
sb.Append($"{c.ReadCapacityUnits:N1} RCUs"); | |
sb.Append($"; {c.WriteCapacityUnits:N1} WCUs"); | |
sb.Append($"; {c.CapacityUnits:N1} total CUs"); | |
foreach (var (key, value) in c.GlobalSecondaryIndexes ?? new Dictionary<string, Capacity>()) | |
{ | |
sb.Append($"; GSI {key} {value.ReadCapacityUnits:N1} RCUs, {value.WriteCapacityUnits:N1} WCUs, {value.CapacityUnits:N1} total CUs"); |
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
var csvName = Assembly.GetExecutingAssembly().GetManifestResourceNames().Single(r => r.EndsWith("us_zipcodes.csv", StringComparison.Ordinal)); | |
using var fileContents = Assembly.GetExecutingAssembly().GetManifestResourceStream(csvName)!; | |
using var reader = new StreamReader(fileContents); | |
var lines = new List<string>(41686); | |
string? line = null; | |
while ((line = reader.ReadLine()) is not null) | |
{ | |
lines.Add(line); | |
} |
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
namespace SomeNamespace; | |
// Because doing anything non-trivial in C# requires the boilerplate anyway | |
public class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Hello, World!"); | |
} | |
} |
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
const int take = 3; | |
var range = Enumerable.Range(0, 10).ToList(); | |
var ptr = 0; | |
while (range.Skip(ptr).Take(take).Any()) | |
{ | |
foreach (var element in range.Skip(ptr).Take(take)) | |
Console.Write(element + ", "); | |
ptr += take; | |
} |
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
cat ugly.json | python3 -mjson.tool > pretty.json |
git remote prune origin
prunes tracking branches not on the remotegit branch --merged
lists branches that have been merged into the current branchxargs git branch -d
deletes branches listed on standard inputgit branch --merged | xargs git branch -d
plumbs everything together
Let's suppose you have an automated merge failure going from the prod branch (33.0) to the test branch (33.1). So you will want to merge prod into test.
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
public static class JsonSerializerUtils | |
{ | |
public static JsonSerializerOptions GetJsonSerializerSettings() | |
{ | |
#pragma warning disable 162 | |
#if DEBUG | |
return GetFormattedJsonSettings(); | |
#endif | |
return GetUnformattedJsonSettings(); |
NewerOlder