Skip to content

Instantly share code, notes, and snippets.

View bradwilson's full-sized avatar
🤘
All metal, all the time!

Brad Wilson bradwilson

🤘
All metal, all the time!
View GitHub Profile
@bradwilson
bradwilson / SampleTest.cs
Created March 15, 2026 22:57
Showing a single large test instead of multiple small tests
[Fact]
public async Task v2_and_v3()
{
var source = /* lang=c#-test */ """
using System.Runtime.InteropServices;
using Xunit;
public class TestClass {
[Theory]
[InlineData("abc", 1, null)]
7-Zip 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
Scanning the drive for archives:
1 file, 11606158 bytes (12 MiB)
Listing archive: C:\Dev\xunit\xunit\artifacts\packages\xunit.v3.runner.console.4.0.0-pre.7-dev.nupkg
--
Path = C:\Dev\xunit\xunit\artifacts\packages\xunit.v3.runner.console.4.0.0-pre.7-dev.nupkg
@bradwilson
bradwilson / ClearType.reg
Created January 3, 2025 19:15
Registry files for turning grayscale font smoothing on/off in Windows 10/11
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingGamma"=dword:00000000
"FontSmoothingContrast"=-
"FontSmoothingOrientation"=dword:00000001
"FontSmoothingType"=dword:00000002
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DISPLAY1]
@bradwilson
bradwilson / polyfill.cs
Last active July 12, 2024 22:41
Polyfill for `required` property support
#if !NET7_0_OR_GREATER
namespace System.Runtime.CompilerServices
{
/// <summary/>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
internal sealed class RequiredMemberAttribute : Attribute
{ }
/// <summary/>
@bradwilson
bradwilson / bat.ps1
Last active July 27, 2024 01:46
Replace cat with bat in PowerShell (and my personal bat config file)
# This is to replace PowerShell's 'cat' with 'bat'. Install from here: https://github.com/sharkdp/bat
#
# This code goes into my $profile. If you put this into a separate file, you will need to dot source
# that file so that the function shows up in the global namespace. I only replace the cat alias,
# so Get-Content still performs its standard behavior.
#
# I use a pipeline to capture all the file content (so you can do things like `dir *.ps1 | cat` as well
# as `cat *.ps1`). If there's a single file, then the contents are displayed raw; if there are multiple files,
# then it uses bat's header to discriminate the content of multiple files from each other. I also replicated
# a few of the more common (for me) command line switches that I'd want to use to influence bat's behavior,
@bradwilson
bradwilson / get-mkvinfo.ps1
Last active January 27, 2024 08:08
get-mkvinfo.ps1 (automating mkvmerge)
param(
[Parameter(ValueFromPipeline)]$values,
[switch]$All
)
# It's worth noting that this script is useful for me, because I speak English. So I show all audio
# tracks and just the English subtitle tracks, and just make note when one of my rips includes non-
# English subtitle tracks (usually indicting I forgot to reduce the things I ripped).
#
# This is a pipeline-compatible script, so my usage is typically:
@bradwilson
bradwilson / EnumerableExtensions.cs
Last active January 21, 2024 16:45
Enumerable/AsyncEnumerable conversions
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
internal static class EnumerableExtensions
{
public static IAsyncEnumerable<T>? ToAsyncEnumerable<T>(IEnumerable<T>? data) =>
data == null ? null : ToAsyncEnumerableImpl(data);
async static IAsyncEnumerable<T> ToAsyncEnumerableImpl<T>(IEnumerable<T> data)
@bradwilson
bradwilson / Benchmark.cs
Last active January 10, 2024 07:10
Benchmarking OfType() vs. custom WhereNotNull() to discard null values
using System;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Running;
public static class EnumerableExtensions
{
static readonly Func<object, bool> notNullTest = x => x is not null;
@bradwilson
bradwilson / disable-ipv6.reg
Created December 11, 2023 02:23
Disable IPv6 on Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters]
"DisabledComponents"=dword:000000ff
@bradwilson
bradwilson / custom.css
Last active November 22, 2023 05:30
Refined GitHub custom CSS
pre,
pre code,
.blob-code,
.blob-code-content,
.blob-code-marker,
.cm-editor .cm-line,
.react-blob-print-hide,
.react-code-text {
font-family: 'MonaspiceNe NFM', monospace !important;
}