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
// Copyright 2022 Ryan Crosby | |
// This code is licensed under the MIT license | |
// | |
// Methods to convert a byte array to hex, using new Span<T> | |
// | |
// C# no-alloc optimization that directly wraps the data section of the dll (similar to string constants) | |
// https://github.com/dotnet/roslyn/pull/24621 | |
private static ReadOnlySpan<byte> HexAlphabetBytes => new byte[16] |
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
syntax on | |
set background=dark | |
set showcmd | |
set showmatch | |
set mouse= |
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
// Copyright 2021 Ryan Crosby | |
// This code is licensed under the MIT license | |
using Microsoft.AspNetCore.Html; | |
using Microsoft.AspNetCore.Mvc.Rendering; | |
using Microsoft.AspNetCore.Mvc.ViewFeatures; | |
using Microsoft.Extensions.DependencyInjection; | |
using System; | |
using System.Linq.Expressions; |
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
// Copyright 2021 Ryan Crosby | |
// This code is licensed under the MIT license | |
/// <summary> | |
/// Variations of the EnsureSuccessStatusCode() extension method for capturing and retreiving the HTTP Status Code and Response Body. | |
/// </summary> | |
public static class HttpResponseMessageExtensions | |
{ | |
public const string StatusCodeKey = "StatusCode"; | |
public const string ResponseBodyKey = "ResponseBody"; |
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
using System.Threading; | |
using System.Threading.Tasks; | |
public static class CancellationTokenExtensions | |
{ | |
public static async Task WhenCancelled(this CancellationToken cancellationToken) | |
{ | |
TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>(); |
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 IntExtensions | |
{ | |
public static uint GetNextPowerOfTwo(this uint input) | |
{ | |
--input; | |
input |= input >> 1; | |
input |= input >> 2; | |
input |= input >> 4; | |
input |= input >> 8; | |
input |= input >> 16; |
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
// Copyright 2021 Ryan Crosby | |
// This code is licensed under the MIT license | |
using System; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
// ... | |
public static class PathGlobbingHelpers |
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
#!/bin/bash | |
# Dynamic DNS auto-update script for CloudFlare API | |
# Version 3 - Ryan Crosby 2023 | |
# | |
# Supports IPv4 and IPv6 (A and AAAA records) | |
# | |
# Requires curl and jq | |
echo "Dynamic DNS auto-update script for CloudFlare API" |
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
# Powershell script to automatically open a putty window for each serial port on the computer | |
param ( | |
[string]$baud = "115200" | |
) | |
$serialreg = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM | |
foreach ($thisname in $serialreg.GetValueNames()) | |
{ |
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
# Script to switch between wired LAN and WiFi on Surface Book and MS Dock. | |
# Initially, one should be disabled and the other enabled. The script will then flip their states. | |
[string]$wifi_ifdesc = 'Marvell AVASTAR Wireless-AC Network Controller' | |
[string]$eth_ifdesc = 'Surface Ethernet Adapter #2' | |
if((Get-NetAdapter -InterfaceDescription $wifi_ifdesc).Status -eq 'Disabled') { | |
# Switch to Wifi | |
Write-Output 'Switching to WiFi' | |
OlderNewer