Skip to content

Instantly share code, notes, and snippets.

<#
yoinked and just stripped the namespace and change internal to public
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/utils/FuzzyMatch.cs
https://www.geeksforgeeks.org/damerau-levenshtein-distance/
https://yassineelkhal.medium.com/the-complete-guide-to-string-similarity-algorithms-1290ad07c6b7
#>
Add-Type -TypeDefinition @'
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
-join (1..255 | % { "`e[48;5;$($_)m  {0:00#}  `e[0m" -f $_ + ($_ % 15 -eq 0 ? "`n" : " ") })
-join (1..255 | % { "`e[48;5;$($_)m  {0:00#}  `e[0m" -f $_ + ($_ % ($host.ui.RawUI.WindowSize.Width / 10) -eq 0 ? "`n" : " ") })


#Windows Powershell compatible version
-join (1..255 | % { "$([char]27)[48;5;$($_)m  {0:00#}  $([char]27)[0m" -f $_;if ($_ % ($host.ui.RawUI.WindowSize.Width / 10) -eq 0) { "`n" } else { " " } })
@ninmonkey
ninmonkey / Template for readme.md using screenshots.md
Last active October 12, 2023 21:20
Template for readme.md using screenshots

template-with-images.md

This example organizes all the non-pbix files in subdirectories.
Imagine main is a local folder, ex: inside the root folder: `c:\git\PowerQuery

The absolute path to my screenshot is:

c:\git\PowerQuery\img\title.screenshot.png
@ninmonkey
ninmonkey / How to move Docker-Desktop-Data to another drive.md
Last active October 10, 2023 13:31
How to move Docker-Desktop-Data to another drive

About

Docker desktop throws 20GB on c:\ . This is how you can move that to another drive like D:\wsl.2023\

EverythingSearch query

ext:vhdx
@ninmonkey
ninmonkey / Power Query Fancy Docs with Html.md
Last active August 29, 2023 22:40
Some html formatting is used by Power Query's doc strings

Here's a random example to demonstrate html

Tips : Multiline strings

It can be messy writing a bunch of newlines in a multiline string. It's easier to use a list of strings that combine.

For Html newlines

= Text.Combine({ "Line1", "", "Line3" }, "<br>")
@Jaykul
Jaykul / Invoke-Native.psm1
Last active March 6, 2026 19:47
Calling native executables that write non-error to stderr (with prefixes like "Warning:" and "Error:") ...
class EncodingAttribute : System.Management.Automation.ArgumentTransformationAttribute {
[object] Transform([System.Management.Automation.EngineIntrinsics]$engineIntrinsics, [object] $inputData) {
if ( $inputData -is [string] ) {
return [Text.Encoding]::GetEncoding($inputData)
} else {
return $inputData
}
}
}
@Jaykul
Jaykul / About Copilot CLI.md
Created April 30, 2023 22:55
Copilot CLI in PowerShell

We are, for now, just using the official github copilot CLI, but they didn't really have hooks for PowerShell, so I wrote a few functions to implement it.

It works great, as you can see:

a simple prompt for how to find the top 10 files

the modified query, executed

@ninmonkey
ninmonkey / Powershell Settings - vscode.md
Last active March 23, 2023 03:47
VS Code Settings for Powershell 2023.03

Default settings in VS Code are dynamic. They are generated based on your extensions's metadata. That means they are up to date. I have some tips for discovering new settings in Vs Code through Default settings (ninmonkeys.com)

Another extension that helps is Better Align

The main settings:

{   "powershell.codeFormatting.autoCorrectAliases": true,
    "powershell.codeFormatting.useConstantStrings": true,
    "powershell.codeFormatting.useCorrectCasing": true,
 "powershell.codeFormatting.alignPropertyValuePairs": true,