Friday, May 31, 2024

Powershell Function to List Ports in Use by a Java Prog

Replace"YourCurrentProject" default with your most frequent query.

Add the following to your $profile (PS> code $profile).

function lsAppPorts($prog = "YourCurrentProject") {
    foreach($a in jps -l | C:\Progra~2\GnuWin32\bin\awk "/$prog/{ print `$1; }") {
        netstat -ano | findstr $a
    }
}

Note: Requires Gnu Awk for Windows

Thursday, May 2, 2024

Generate Tough Passwords From the Commandline

Note: Requires openssl
Usage: $> genpasswd [int size, default: 8]
alias genpasswd='_(){ if (($#<1)); then PASSWDSIZE=8; else PASSWDSIZE=${1};fi; openssl rand -base64 32|sed -r "s/^(.{${PASSWDSIZE}})(.*)/\1/g"; }; _'