Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
All metal, all the time!

Brad Wilson bradwilson

🤘
All metal, all the time!
View GitHub Profile
@bradwilson
bradwilson / remove-all-boms.ps1
Created November 2, 2022 01:09
Quick script to find files with UTF-8 BOMs and rewrite them without the BOM
View remove-all-boms.ps1
param(
[string] $Folder = ".",
[string] $Filter = "*.*"
)
Get-ChildItem -Path $Folder -Recurse -File -Filter $Filter -Exclude @('obj','bin') | Foreach-Object {
$contents = [System.IO.File]::ReadAllBytes($_.FullName)
if ($contents.Length -gt 2 -and $contents[0] -eq 0xEF -and $contents[1] -eq 0xBB -and $contents[2] -eq 0xBF) {
Write-Host $_.FullName
[System.IO.File]::WriteAllBytes($_.FullName, $bytes[3..$($bytes.Length)])
@bradwilson
bradwilson / 1 - In Code.cs
Created August 18, 2020 23:21
Skip attribute: enable or no?
View 1 - In Code.cs
public class SampleTests
{
public bool SomeCondition => ...;
[Fact]
public void MySkipWhen()
{
Assert.SkipWhen(SomeCondition, "This is dynamically skipped when SomeCondition is true");
}
@bradwilson
bradwilson / settings.json
Last active June 5, 2023 17:10
Ubuntu color scheme for Windows Terminal
View settings.json
{
"$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 August 20, 2022 18:39
Downloadable files for bradwilson.io/blog/prompt/powershell
View profile.ps1
######## 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 / gist:be689377ea2a9f8d94bf2ca3a8424cbd
Last active February 10, 2019 21:34
Pop!_OS customizations
View gist:be689377ea2a9f8d94bf2ca3a8424cbd
Install applications:
- Beyond Compare
- Chromium
- dconf Editor
- GIMP
- Gnome Tweaks
- Htop
- Insync
- JetBrains Rider
- Remmina
@bradwilson
bradwilson / ConvertTo-MP3.ps1
Last active March 9, 2020 18:33
Converts FLAC/MP3 input, resamples down to ReplayGain levels, and converts to MP3. Requires on the path: flac, metaflac, ffmpeg, mogrify
View ConvertTo-MP3.ps1
param(
[string][Parameter(Mandatory=$true)]$InputFile,
[string][Parameter(Mandatory=$true)]$OutputFile,
[int]$SampleRate = 44100,
[string]$BitRate = "160k"
)
$ErrorActionPreference = "Stop"
$InputFile = [System.IO.Path]::Combine((Get-Location), $InputFile)
@bradwilson
bradwilson / normalize-names.ps1
Last active September 10, 2018 06:16
normalize-names.ps1
View normalize-names.ps1
param(
[string][Parameter(Mandatory = $true)] $Location,
[switch] $SkipFolderRename
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$oldEncoding = [Console]::OutputEncoding
$caseInsensitive = [StringComparison]"OrdinalIgnoreCase"
@bradwilson
bradwilson / docker-clean.ps1
Created February 7, 2018 00:36
Docker Cleanup
View docker-clean.ps1
(& docker images --all --quiet --filter 'dangling=true') | Foreach-Object {
& docker rmi $_ | out-null
}
(& docker ps --quiet --filter 'status=exited' ) | Foreach-Object {
& docker rm $_ | out-null
}
@bradwilson
bradwilson / .gitconfig
Last active January 22, 2023 21:51
~/.config/git/config
View .gitconfig
[user]
name = Brad Wilson
email = dotnetguy@gmail.com
signingkey = 0B7BD15AD1EC5FDE
[alias]
a = add -A
abort = rebase --abort
amend = commit --amend -C HEAD
bclean = "!f() { git switch ${1-main} && git branch --merged ${1-main} | grep -v ${1-main}$ | xargs git branch -d; }; f"
bdone = "!f() { git switch ${1-main} && git up && git bclean ${1-main}; }; f"
@bradwilson
bradwilson / .bashrc
Last active December 28, 2017 20:26
*nix startup scripts
View .bashrc
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\w\a\]$PS1"
;;