Skip to content

Instantly share code, notes, and snippets.

View JohnL4's full-sized avatar

John Lusk JohnL4

View GitHub Profile
@JohnL4
JohnL4 / Get-IISAppPoolIdentities.ps1
Last active April 21, 2020 15:37
Fetch IIS Application Pool identities and Virtual Directories (and passwords!) to check that passwords used are correct and won't lock you out of the system due to high failure count
Import-Module WebAdministration;Get-ChildItem -Path IIS:\AppPools\ |
Select-Object name, state, managedRuntimeVersion, managedPipelineMode, @{e={$_.processModel.username};l="username"},
@{e={$_.processModel.password};l="password"}, @{e={$_.processModel.identityType};l="identityType"} |
format-table -AutoSize
# Also, to get virtual directories and auth credentials:
# (Need to select a new object to alias Path to AppPath, since VirtualDirectory also has a Path property)
#
get-iissite | sel -expand Applications | sel @{e={$_.Path};l="AppPath"} -expand VirtualDirectories |
sel AppPath, LogonMethod, UserName, Password | ft -auto -wrap
@JohnL4
JohnL4 / JpqlExecutor.java
Created April 9, 2020 01:29 — forked from kencoba/JpqlExecutor.java
REPL for JPQL
package client;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
@JohnL4
JohnL4 / python-re-capture.txt
Last active July 13, 2020 16:49
Capture regexp subexpressions with python. Better than Perl.
>>> import re
>>> m = re.match( r"-*(a+)-*(b+)-*(c+)", "---aaa---bbb--ccc---")
>>> m[1]
'aaa'
>>> m[3]
'ccc'
>>> m.group(2,3)
('bbb', 'ccc')
See python fileinput for looping over lines of a series of files on stdin.
@JohnL4
JohnL4 / Copy-UnlessAlreadyExists.ps1
Last active December 20, 2019 20:42
Copy files that don't already exist in a destination directory
ls | ? {(-not (Test-Path (Join-Path c:\tmp\DirB $_.Name)))} | cp -dest c:\tmp\DirB -pass
# Not recursive.
# Test-Path can also do date-checking.
@JohnL4
JohnL4 / ildasm.cmd
Last active November 25, 2019 17:31
Disassemble an assembly (.dll or .exe) in Visual Studio Developer Command Prompt
ildasm /source /linenum /all /out=SXA.ED.Server.Web.exe.txt SXA.ED.Server.Web.exe
@JohnL4
JohnL4 / perl-re-capture.sh
Last active January 24, 2020 02:25
Grab a substring out of a string with Perl. But: Perl is the road to hell. Don't do it, mon.
cat edWebLog.txt | perl -e 'while (<>) { /caching service background update finished on thread \(id 21\) in ([0-9]+) ms/ && print "$1\n";}'
# Simpler:
echo abc | perl -n -e '/a(.)c/ && print "$1\n";'
# So, the first line becomes:
cat edWebLog.txt | perl -n -e '/caching service background update finished .* in ([0-9]+) ms/ && print "$1\n";'
@JohnL4
JohnL4 / find-grep.ps1
Last active December 14, 2023 15:00
Find/grep for files that contain MULTIPLE strings (Boolean AND)
ls -rec | ? {$_ -is [IO.FileInfo]} `
| ? {(cat $_ | sls '\bALTER\s+TABLE\b' -list).Count -gt 0} `
| ? {(cat $_ | sls '\bADD\s+CONSTRAINT\b').Count -gt 0}
#### Older, more complicated cmd line follows:
ls -rec | ? {-not (HasNulls $_)} | ? {$_ | sls 'vital.?sign' -list} | sls 'critical' -list | ogv
# OR... (to post-process to filter OUT some spurious matches)
System&
Queries
queries submitted -> Queries Out
No Queries
Queries Out
Queries Remain?
queries remain? -> Queries Out
no queries remain? -> No Queries
@JohnL4
JohnL4 / SketchSystems.spec
Last active February 15, 2019 20:52
System&
System&
Queries
queries submitted -> Queries Out
response received -> Queries Remain?
No Queries*
Queries Out
@JohnL4
JohnL4 / .ghci
Last active February 7, 2019 23:54
.ghci for Windows 10 PowerShell when ANSI escapes don't work
-- -*- coding: utf-8; comment-start: "-- "; comment-column: 40 -*-
-- NOTE: Can't follow :set commands with comments on same line. Also, none of this works in PowerShell, hence the use
-- of System.Console.ANSI. :(
-- See https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
-- :set prompt "\ESC[7m%s\ESC[0m\nλ> " -- Reverse video, two lines
-- Reverse video
-- :set prompt "\ESC[7mλ %s>\ESC[0m "