The maintained version now lives at Thunderbolt Networking, part of scyto/homelab-docs.
Questions or troubleshooting? Continue the conversation here — a Q&A discussion where replies thread properly, answers can be marked, and everything is searchable. The 388 comments below stay exactly where they are as an archive.
| <# | |
| .SYNOPSIS | |
| Fast conversion of Microsoft Stream VTT subtitle file to SRT format. | |
| .DESCRIPTION | |
| Uses select-string instead of get-content to improve speed 2 magnitudes. | |
| .PARAMETER Path | |
| Specifies the path to the VTT text file (mandatory). | |
| .PARAMETER OutFile | |
| Specifies the path to the output SRT text file (defaults to input file with .srt). | |
| .EXAMPLE |
I've been recommending people use NerdFonts in their terminals for a while, but using the extra characters ends up being rather a pain. I have to look up characters in their web cheat-sheet, and then I either end up with a whole bunch of "$([char]0xf1ed)$([char]0xf00d)" in my profile scripts, which is impossible to read, or I have to translate the hex to decimal so I can type the ALT codes in my editor...
So today I fixed it, using PANSIES (the PowerShell ANSI Escape Sequences module).
In PANSIES output (i.e. via the Write-Host, or by using New-Text in a string), you can embed named entities like in html. But unlike HTML, Pansies entities are extensible. So I wrote a little script to re-use the css names for the nerd-font characters and generate entities.
| # escape=` | |
| ARG fromTag=latest | |
| ARG WindowsServerCoreRepo=mcr.microsoft.com/windows/servercore | |
| # Use server core as an installer container to extract PowerShell, | |
| # As this is a multi-stage build, this stage will eventually be thrown away | |
| FROM ${WindowsServerCoreRepo}:${fromTag} AS installer-env | |
| ARG PS_VERSION=6.2.0 | |
| ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip |
| function Sleep-Progress($seconds) | |
| { | |
| <# | |
| .SYNOPSIS | |
| Function to Start-Sleep with a progress bar | |
| .DESCRIPTION | |
| Runs the 'Start-Sleep' command using the with a progress bar. Time is passed to the function in seconds as an argument. | |
| .NOTES |
Caution
Due to the subject of this Gist there are a lot of spam/scam comments. I try to remove them all as soon as possible. I don't recommend you to click on any link in the comments
- Open a command prompt as Administrator
- In the command prompt, type the following:
- Office 2016 (32-bit) on a 32-bit version of Windows
cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus
| [no Search()] nuget.exe list | |
| [no Search()] nuget.exe list -allversions | |
| [no Search(), no IsAbsoluteLatestVersion] nuget.exe list | |
| [no Search(), no IsAbsoluteLatestVersion] nuget.exe list -allversions | |
| GET /api/v2/Packages HTTP/1.1 | |
| GET /api/v2/Packages?$skip=100 HTTP/1.1 | |
| [no Search()] nuget.exe list -allversions -prerelease | |
| [no Search(), no IsAbsoluteLatestVersion] nuget.exe list -allversions -prerelease | |
| GET /api/v2/Packages()?$orderby=Id&$skip=0&$top=30 HTTP/1.1 |
| # It might work in 4, but I'm not testing there. Lower you'll have to tweak code | |
| #requires -Version 5.0 | |
| param( | |
| # Your Live ID for MSDN login | |
| [Parameter(Mandatory)] | |
| [PSCredential] | |
| [System.Management.Automation.CredentialAttribute()] | |
| $Credential, | |
| # Pick a browser to use. Defaults to Firefox (which doesn't seem to require an external Driver file) |
My preferred code style is 2-space K&R. This is intended to provide a justification for this style.
K&R style has the following properties:
- Provides symmetric size (in terms of screen space consumed) between the opening and closing syntax of a clode block.
- Forces no empty or meaningless lines, thereby avoiding artificial distance between related things that should be together.
- Consumes the minimum vertical space while keeping the opening and closing syntax of a block on separate lines from the content.
| <# | |
| .Synopsis | |
| Converts a PowerShell object to a Markdown table. | |
| .EXAMPLE | |
| $data | ConvertTo-Markdown | |
| .EXAMPLE | |
| ConvertTo-Markdown($data) | |
| #> | |
| Function ConvertTo-Markdown { | |
| [CmdletBinding()] |