Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
ninmonkey / Decorator-LogMethod.ts
Last active October 21, 2026 19:14
Typescript-Decorator-Examples.ts
/**
* @summary decorator for logging method calls ( TSC 5.0+ 2026-06-11 )
* @link [Pixel Grid UI: JavaScript Decorators What Actually Shipped](https://www.youtube.com/watch?v=gw2hKIxSk4g)
*/
function logged(value, context ) {
return function (...args ) {
console.log( '->',
context.name + '( ' + args.join(', ') + ')' )
const result = value.call( this, ...args )
@ninmonkey
ninmonkey / Convert Offset to Processor Affinity Bitflags.ps1
Last active September 15, 2026 18:49
Convert Offset to Processor Affinity Bitflags.ps1
<#
Output:
ProcessNum BitFlag BitStr
---------- ------- ------
10 1024 000000000000010000000000
11 2048 000000000000100000000000
12 4096 000000000001000000000000
13 8192 000000000010000000000000
14 16384 000000000100000000000000
@ninmonkey
ninmonkey / DAX - Sign Operator Precedence - Exponents.md
Last active September 13, 2026 20:14
DAX - Sign Operator Precedence - Exponents.md

Dax Comparing operator precedence for exponents

Live demo: https://dax.do/k1CMcd5fRbo6ax/

Do these DAX expressions equal the same thing? Or do they differ?

(-10) ^ 2

verses

@ninmonkey
ninmonkey / ParseByDepth.ps1
Last active August 26, 2026 02:32
Parsing-CiscoTemplateFiles.ps1
#requires -Modules Pansies
#requires -PSEdition Core
remove-module PSFrameWork, psutil, string -ea ignore
<#
.SYNOPSIS
parse a cisco router config from 10 years ago. split into groups. Show depths. Show warnings if any exit contained within
.NOTES
I used colors for a screenshot
but if you use Num and DisplayNum you'd be able to have colors and still filter like
@ninmonkey
ninmonkey / Reddit Post.md
Last active August 17, 2026 23:56
Suspicious Entry AD Module notes.md

Posted reddit thread: https://www.reddit.com/r/PowerShell/comments/1von1d7/comment/p41z4et Date: 2026-08-15

The version currently up didn't appear to execute something malicious currently -- but it looks more suspicious than not.

The domain is not github, and the cert was invalid. Unlike the guy below, who said he got 404

  • hashed HOMEPATH and ComputerName
  • which version of the module you ran
  • Your powershell version
@ninmonkey
ninmonkey / Fixing PS1 files utf8 encoded files with no BOM mark and Japanese culture.md
Last active August 16, 2026 19:07
Claude and Powershell 5 - Fixing PS1 files with Japanese and no BOM mark

I found these CLAUDE.md examples that help mitigate when claude or external tools are executed ie: Cases where you can't just modify your profile

The problem is powerh

Traditional fix for current user

In the file $Profile.CurrentUserAllHosts add

@ninmonkey
ninmonkey / Css Pwsh Web Scraping Example - Using CSS Selector Queries.ps1
Last active July 28, 2026 16:16
Web Scraping Example - Using CSS Selector Queries.js
#requires -Modules PSParseHTML
<#
.link
javascript answer: https://gist.github.com/ninmonkey/b59e33cec6765a2c782edaf5c4807b17
#>
Import-Module PSParseHTML
$url = 'https://tavex.pl/zloto/zlote-sztabki/page/1?filter%5Bweight%5D%5B0%5D=1&meta%5B0%5D=tax-gold%3Azlote-sztabki&sorting=recommended'
$html ??= Invoke-WebRequest -url $Url -UseBasicParsing
@ninmonkey
ninmonkey / EditFunc-Definition.ps1
Created July 10, 2026 16:35
EditFunc - Jump to profile functions in Vs Code.ps1
function EditFunc {
<#
.SYNOPSIS
Finds where a function is defined, opens it in vs code -- and jumps to the line number it starts on
.example
gcm prompt | EditFunc
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
@ninmonkey
ninmonkey / PwshExponents.md
Last active June 5, 2026 19:22
Powershell sugar for exponents
function Pow { param( $base, $pow ) [Math]::Pow( $base, $pow ) }
filter  fPow { param( $Pow ) [Math]::Pow( $_, $pow ) }
filter  IPow { param( $Base ) [Math]::Pow( $base, $_ ) }
function Csv { $input | Join-String -sep ', ' }

3 Different interfaces

Pow 2 7    
@ninmonkey
ninmonkey / Simple-EscapeControlChar.ps1
Created October 12, 2025 20:50
Tiny Escape Control Char Pwsh7
filter EscapeCC {
($_)?.EnumerateRunes() | % {
($_.Value -le 32) ? [Text.Rune]( $_.Value + 0x2400 ) : $_
} | Join-String
}
"sdf `a sdjf hi world`t`n ${fg:#feaa99} more stuff `u{0} `r`n blah" | escapeCC
# outputs: sdf␠␇␠sdjf␠hi␠world␉␊␠␛[38;2;254;170;153m␠more␠stuff␠␀␠␍␊␠blah