Skip to content

Instantly share code, notes, and snippets.

@milnak
milnak / ICalToText.ps1
Created November 9, 2022 07:06
Convert an online ICAL to a text representation
# Powershell: No Rules calendar (ICAL import)
[cmdletbinding()] # Support -Verbose
Param(
# Google Calendar URL.
# Calendar Settings > Calendar Details > Calendar Address > ICAL
# Settings for my calendars > [Calendar Name] > Integrate calendar > Public address in iCal format
[string]$ICalUrl = 'https://calendar.google.com/calendar/ical/FILL_THIS_IN/public/basic.ics',
# If False, then only events after the current day are displayed.
[switch]$AllEvents = $False,
@milnak
milnak / DownloadLatestPS.ps1
Last active August 15, 2024 18:07
Download Latest PowerShell: PowerShell script to download latest PowerShell x64 MSI from github
Function DownloadLatestPS {
Param([Parameter(Mandatory=$true)][string]$Folder)
$json = curl -s 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest' | ConvertFrom-Json
$ps = $json.assets | Where-Object name -Like 'PowerShell-*-win-x64.msi'
"Downloading: {0}" -f $ps.name
$oldpp = $progresspreference
$progresspreference = 'SilentlyContinue'
@milnak
milnak / ffmpeg-normalize-all.cmd
Last active November 16, 2022 17:14
Normalize mp3 and flac files in currently directory using ffmpeg-normalize
@echo off
REM Normalize mp3 and flac files in currently directory using ffmpeg-normalize
REM https://github.com/slhck/ffmpeg-normalize/
setlocal
goto :main
:normalize_file
setlocal
@milnak
milnak / sfv.ps1
Created December 2, 2022 08:57
SFV tool: Adaptation of SFVCON to PowerShell #crc #sfv
# TODO:
# sfv.exe takes in a file that can include a path.
#
# sfv.exe supports -rep, -noperc
#
# sfv seems to have a filename truncation routine where it puts ellipses. Not sure what the logic is.
# should be:
# │ [ 4/ 23] Info/05 - Roxy Music - While My Hear...ng.dsf_report.png MISS
# │ [ 5/ 23] Info/07 - Roxy Music - Take A Chance W...dsf_report.png MISS
# not:
@milnak
milnak / ffmpeg-normalize-all.ps1
Last active August 15, 2024 18:08
Script to normalize MP3 and FLAC: Uses ffmpeg-normalize and ffmpeg
# Normalize mp3 and flac files in current directory using ffmpeg-normalize
# scoop install ffmpeg
$ffmpeg = 'ffmpeg.exe'
# scoop install python
# pip3.exe install ffmpeg-normalize
$ffmpeg_normalize = 'ffmpeg-normalize.exe'
function Get-MeanVolume {
Param([Parameter(Mandatory = $true)][string]$File)
@milnak
milnak / rclone-music.ps1
Last active August 15, 2024 18:08
rclone folder: Copy music folder from my OneDrive to enScore music folder using rclone
Param(
[switch]$List,
[switch]$Check,
[switch]$Clone
)
# Copy music folder from my OneDrive to enScore music folder using rclone
$source = 'onedrive:"Documents/Band Charts/Pazific"'
$dest = "$env:LocalAppData\Packages\54636JonathanVardouniotis.enScoreSheetMusicReader_3p6s0exh8v0we\LocalState\SheetMusic\Pazific"
@milnak
milnak / code.ps1
Last active August 15, 2024 18:09
Launch vscode with wildcards: PowerShell script to launch vscode, supporting wildcards
# Launch vscode with wildcards
function Get-UninstallPath {
Param(
[Parameter(Mandatory=$true)][string]$ProductId
)
$regPath = "/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/$ProductId"
# Check user location first
$path = Get-ItemProperty -Path "HKCU:$regPath" -Name 'InstallLocation' -ErrorAction SilentlyContinue
@milnak
milnak / regex-reference.md
Last active August 15, 2024 18:08
Regular Expression Language - Quick Reference: Adapted from Microsoft Learn

Regular Expression Language - Quick Reference

Adapted from Microsoft Learn

Character Escapes

The backslash character (\) in a regular expression indicates that the character that follows it either is a special character (as shown in the following table), or should be interpreted literally.

Escaped character Description Pattern Matches
@milnak
milnak / TrToObject.ps1
Last active December 23, 2022 07:47
Parse HTML TR to PowerShell PSCustomObject
# TODO: Should also capture Cycle notes, e.g.
# <td height="26">5 (+1 if page crossed)</td>
$uri = 'https://www.nesdev.org/obelisk-6502-guide/reference.html'
$content = (Invoke-WebRequest -Uri $uri).Content
$regex = '(?s)'
# <tr>
$regex += '<tr>.*?'
# <td width="30%" height="24"><a href="addressing.html#IMP">Implied</a></td>
@milnak
milnak / extract-cue.ps1
Last active August 15, 2024 18:07
Extract audio files from CUE file: Uses ffmpeg.exe as a helper
# https://wiki.hydrogenaud.io/index.php?title=Cue_sheet
Param(
# Path to CUE file
[Parameter(Mandatory = $true)][string]$CuePath
)
function Parse-Cue {
Param([Parameter(Mandatory = $true)][string]$CuePath)
# Top level object. Includes File array.