Skip to content

Instantly share code, notes, and snippets.

@jborean93
jborean93 / Split-ExeArgument.ps1
Last active June 4, 2024 01:24
Splits the input string using the Win32 argument splitter
# Copyright: (c) 2024, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module Ctypes
Function Split-ExeArgument {
[OutputType([string])]
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
@ninmonkey
ninmonkey / Power Query Gh-Copilot example.md
Last active May 26, 2024 18:31
Example of Copilot Generating code using my library in Power Query.md

snippet of my lib

The rest of the code is here: Write.Html.pq

// aliases
Write.Format  = String.Write.Format,
Write.Element = Write.Html.Element,
Write.Key     = Write.Html.KeyValue,
Tag           = Write.Html.Element,
@ninmonkey
ninmonkey / Select-Some-Or-One.ps1
Last active May 26, 2024 02:16
PowerShell Selecting First, Last, One, Some, script.ps1
using namespace System.Collections.Generic
Import-module Pansies
function Dotfiles.Select-Some {
<#
.SYNOPSIS
select 1 item, 5, or a specific count.
.NOTES
- [ ] future: rewrite using steppable pipeline for an earlier exit
.EXAMPLE
@trackd
trackd / Get-AnsiEscape.ps1
Last active May 5, 2024 11:12
something
Update-TypeData -TypeName '_RegexAnsi' -MemberType ScriptMethod -MemberName ToString -Force -Value {
return ($this.Value ? $this.value : $this.Text)
}
Update-TypeData -TypeName 'System.Management.Automation.Internal.StringDecorated' -MemberType ScriptMethod -MemberName ToString -Force -Value {
return $this.IsDecorated
}
function Get-AnsiEscape {
<#
.DESCRIPTION
Get-AnsiEscape can be used to strip, escape, or regex VT codes from a string.
function ConvertTo-TableFormat {
<#
.SYNOPSIS
Rebuild an object based on the Format Data for the object.
.DESCRIPTION
Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject.
#>
[CmdletBinding()]
param (
<#
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