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 / settings.json
Last active April 16, 2024 16:14
Ubuntu color scheme for Windows Terminal
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [
{
"command": "copy",
"keys": "ctrl+shift+c"
},
{
"command": "paste",
@bradwilson
bradwilson / profile.ps1
Last active March 21, 2024 07:24
Downloadable files for bradwilson.io/blog/prompt/powershell
######## POSH-GIT
# ... Import-Module for posh-git here ...
# Background colors
$GitPromptSettings.AfterStash.BackgroundColor = 0x5F5FAF
$GitPromptSettings.AfterStatus.BackgroundColor = 0x5F5FAF
$GitPromptSettings.BeforeIndex.BackgroundColor = 0x5F5FAF
$GitPromptSettings.BeforeStash.BackgroundColor = 0x5F5FAF
@bradwilson
bradwilson / bat.ps1
Created March 17, 2024 21:34
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 / 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 / gist:c0e4994f976e757bc7d5
Last active February 1, 2024 15:37
Tweaks to make to VMware .vmx files
# Disables touchscreen emulation
touchscreen.vusb.present = "FALSE"
# Enables support for nested hypervisors
hypervisor.cpuid.v0 = "FALSE"
vhv.enable = "TRUE"
vpmc.enable = "TRUE"
mce.enable = "TRUE"
vhu.enable = "TRUE"
@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 / 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;
}
@bradwilson
bradwilson / Cacheability.cs
Created January 23, 2014 20:53
Using chaining to create cached results in ASP.NET Web API v2
public enum Cacheability
{
NoCache,
Private,
Public,
}