Skip to content

Instantly share code, notes, and snippets.

View karenpayneoregon's full-sized avatar
🎯
Focusing

Karen Payne karenpayneoregon

🎯
Focusing
View GitHub Profile
@patriksvensson
patriksvensson / TypeWriter.cs
Last active August 31, 2024 18:53
Spectre.Console typewriter
using Spectre.Console;
using Spectre.Console.Rendering;
var renderable = new Markup("[yellow]H[/]ello [blue]W[/]orld");
foreach (var segment in SplitSegments(renderable))
{
AnsiConsole.Write(new SegmentRenderable(segment));
Thread.Sleep(Random.Shared.Next(100, 500));
}
@davidfowl
davidfowl / MinimalAPIs.md
Last active October 24, 2024 13:39
Minimal APIs at a glance
@paolofulgoni
paolofulgoni / EFCoreEnums.csproj
Created September 15, 2019 20:45
Enums in EF Core
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RootNamespace>EFCoreEnums</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
[{
"question": "A flashing red traffic light signifies that a driver should do what?",
"A": "stop",
"B": "speed up",
"C": "proceed with caution",
"D": "honk the horn",
"answer": "A"
}, {
"question": "A knish is traditionally stuffed with what filling?",
"A": "potato",
@JcBernack
JcBernack / BigDecimal.cs
Last active September 14, 2024 17:18
BigDecimal
using System;
using System.Numerics;
namespace Common
{
/// <summary>
/// Arbitrary precision decimal.
/// All operations are exact, except for division. Division never determines more digits than the given precision.
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d
/// Based on https://stackoverflow.com/a/4524254
@adamtal3
adamtal3 / FileAsync.cs
Created April 8, 2015 20:51
FileAsync - AsyncFile - Asynchronous System.IO.File alternative
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// An async alternative to System.IO.File common usages
/// </summary>
public static class FileAsync
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.