Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
ninmonkey / Calc Relative Dates in Pwsh.ps1
Created May 31, 2024 02:52
Calc Relative Dates in Pwsh, using file modified dates
function CalcRelativeDays {
param(
[datetime]$BaseDate,
[datetime]$InputDate,
# default returns totalDays, this returns the raw [TimeSpan]
[switch]$PassThru
)
if($PassThru){
return ($InputDate - $BaseDate)
}
@ninmonkey
ninmonkey / Auto Attributes Type Def Test - System.Json.Text.ps1
Created May 29, 2024 20:01
(wip sketch) Test: Auto add Attributes to Type Def for - System.Json.Text
#Requires -Version 7
using namespace System.Collections.Generic
using namespace System.Text
using namespace System.Text.Json
using namespace System.Text.Json.Serialization
$assembly = Add-type -AssemblyName System.Text.Json -PassThru -ea 'stop'
function AutoJson {
<#
@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
@ninmonkey
ninmonkey / settings.json
Created May 23, 2024 23:36
VsCode Settings - Default using Pwsh profile settings.json
{
// settings related to pwsh terminal
"powershell.enableProfileLoading": true,
"terminal.integrated.defaultProfile.windows": "Pwsh🐒", // "Pwsh🐒",
// The terminal profile to use for automation-related terminal usage like tasks and debug. This setting will currently be ignored if `terminal.integrated.automationShell.windows` (now deprecated) is set.
"terminal.integrated.automationProfile.windows": {
"args": [
"-NoLogo"
],
@ninmonkey
ninmonkey / BeyondAllReason-Intro-Widget.lua
Last active May 21, 2024 21:33
BeyondAllReason-Intro-Widget.lua
function widget:GetInfo()
-- start at: <https://springrts.com/wiki/Lua:Main>
-- <https://springrts.com/wiki/Gamedev:Main>
return {
name = "hiworld",
desc = "getting started",
author = "ninmonkey",
date = "May 10, 2024",
license = "GNU GPL, v2 or later",
@ninmonkey
ninmonkey / BYAR-1.lua
Last active May 10, 2024 22:42
Git Speed Test Case - VsCode Algo hits 5second throttle for tiny files
-- Widget Custom data and order, order = 0 disabled widget
return {
allowUserWidgets = true,
data = {
AdvPlayersList = {
absoluteResbarValues = false,
alwaysHideSpecs = true,
customScale = 0.84999996,
enemyListShow = true,
expandDown = false,
#Requires -Version 7.0
Import-Module 'pansies'
function Hr { "`n----`n" }
<#
See related runes:
https://www.compart.com/en/unicode/block/U+2580
#>
$up = "`u{2580}" <# upper: https://www.compart.com/en/unicode/U+2580 #>
$down = "`u{2584}" <# lower: <https://www.compart.com/en/unicode/U+2584> #>
@ninmonkey
ninmonkey / Compare ImportExcel Formula Cells.ps1
Last active May 3, 2024 06:12
Compare ImportExcel Formula Cells
Import-Module ImportExcel -PassThru
Push-Location $PSScriptRoot
# Close-ExcelWindow
$PSDefaultParameterValues['Export-Excel:Verbose'] = $true
$users = @(
[pscustomobject]@{
Name = 'Jen'
Region = 'Blue'
Len = '=LEN( [@[Name]] )'
# Here's what not to do. I'm testing line continuation grammar
$daxStudioOutput = @(
'foo has | pipe', 'path \\?\c:\foo', 'other' -join "`t"
'PBIDesktopTrace', 'XEvent' -join "`t"
'tabularEditor', '96f8cba3-0ecc-4179-b720-e27ba7cef5a' -join "`t"
) | Join-String -sep "`n"
$renderArray = @{
OutputPrefix = "[`n"
OutputSuffix = "`n]"
FormatString = "`n`t{0},"