Skip to content

Instantly share code, notes, and snippets.

@Jaykul
Jaykul / gcixel.ps1
Created September 1, 2024 04:55
ImageMagick and Sixels -- this is not fast, but it works even across ssh
<#
.SYNOPSIS
gcixels is like gci, but with sixels...
.DESCRIPTION
Shows thumbnails of images with titles, directly in terminal.
However, it's done with ImageMagick montage, so it's awfully slow.
Just sharing it for your inspiration.
.NOTES
Requires ImageMagick and a Sixel terminal (like Windows Terminal 1.22+ or WezTerm)
#>
#Requires -PSEdition Desktop
[CmdletBinding()]
param (
[ValidateSet('AllUsers', 'CurrentUser')]
[string]
$Scope = 'CurrentUser'
)
$ErrorActionPreference = 'Stop'
@jborean93
jborean93 / Split-ExeArgument.ps1
Last active August 19, 2024 19:40
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 July 3, 2024 18:57
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 / ConvertTo-MarkdownTable.ps1
Last active June 25, 2024 22:20
ft as markdowntable
function ConvertTo-MarkdownTable {
<#
.DESCRIPTION
Convert an object to a markdown table.
.PARAMETER InputObject
The object to convert to a markdown table.
.PARAMETER Property
The properties to display in the table.
@JustinGrote
JustinGrote / ConvertTo-Markdown.ps1
Created January 27, 2024 00:25
Convert PowerShell Objects to Markdown Display by screen-scraping Format-Table
using namespace System.Collections.Generic
using namespace Microsoft.PowerShell.Commands.Internal.Format
#Inspired by: https://gist.github.com/aaroncalderon/09a2833831c0f3a3bb57fe2224963942
<#
.Synopsis
Converts PowerShell Objects or Format-Table output to Markdown
#>
Function ConvertTo-Markdown {
[CmdletBinding()]
@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 Set-DemoPrompt {
<#
.SYNOPSIS
Creates a simple prompt with WT highlighting using a temporary module.
minor trickery with setting an alias for prompt so we can easily restore old prompt on module removal.
.NOTES
it adds terminal prompt markings for WT Preview.
see links below for more info
.LINK
https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration#powershell-pwshexe/
@trackd
trackd / protocolhandler-clipboard.ps1
Created December 28, 2023 01:50
prototype something something
function Add-ClipboardProtocolHandler {
# clipboard://
$custom = Get-Command "$env:temp\customclip.exe" -CommandType Application -ErrorAction 'Stop'
$uri = 'clipboard'
if (!(Test-Path "HKCU:\Software\Classes\$uri")) {
New-Item "HKCU:\Software\Classes\$uri"
}
Set-ItemProperty "HKCU:\Software\Classes\$uri" '(Default)' "URL:$uri Protocol"
Set-ItemProperty "HKCU:\Software\Classes\$uri" 'URL Protocol' ''
if (!(Test-Path "HKCU:\Software\Classes\$uri\shell")) {