Skip to content

Instantly share code, notes, and snippets.

@ThioJoe
ThioJoe / DisableUSBPowerManagement.ps1
Last active April 22, 2024 09:41
PowerShell script to disable Windows power management on all currently connected serial ports, including most (if not all) USB devices and adapters.
# PowerShell script to disable Windows power management on all currently connected serial ports, including USB adapters
# In simpler terms, it prevents Windows from turning off connected serial devices to save power.
# Equivalent to right-clicking on a serial port device in Device Manager > Properties > "Power Management" Tab > Unchecking "Allow the computer to turn off this device to save power."
$hubs = Get-CimInstance -ClassName Win32_SerialPort | Select-Object Name, DeviceID, Description
$powerMgmt = Get-CimInstance -ClassName MSPower_DeviceEnable -Namespace root\wmi
foreach ($p in $powerMgmt) {
$IN = $p.InstanceName.ToUpper()
foreach ($h in $hubs) {
@neverUsedGithub
neverUsedGithub / graphql-parser.d.ts
Created July 25, 2023 06:38
A type-level graphql lexer & parser & ts converter.
// Utility
type GetFirstCharacter<Text extends string> = Text extends `${infer First}${infer Rest}` ? First : never;
type StringStartsWith<Source extends string, Char extends string> = Source extends `${infer First}${infer Rest}`
? First extends Char
? true
: false
: false;
type SliceStringFirst<Source extends string> = Source extends `${infer First}${infer Rest}`
? Rest
: never;