Skip to content

Instantly share code, notes, and snippets.

View JohnL4's full-sized avatar

John Lusk JohnL4

View GitHub Profile
@JohnL4
JohnL4 / Set-JavaHome.ps1
Last active February 2, 2018 16:43
Set string environment variable (e.g., $env:JAVA_HOME) to most-recently-created subdirectory
# So, we're not dependent on filename sort order ("9" > "10").
if (Test-Path "c:/usr/local/Java") {
$env:JAVA_HOME = $(ls c:/usr/local/Java | sort CreationTime -desc | select -first 1 FullName).FullName
}
else {
Write-Warning "No Java"
}
# TODO: could probably use a list of directories to search (e.g., @("c:/usr/local/Java", "c:/Program Files/Java")).
@JohnL4
JohnL4 / ArrayLiteral.java
Created February 21, 2018 04:11
Array literals in Java
someMethod( 12, new String[] {"aaa","bbb","ccc"}, FontType.Bold);
@JohnL4
JohnL4 / sed.cmd
Last active September 14, 2018 14:53
Invoking Cygwin sed via cmd.exe from kdiff3
c:\bin\sed -E /([0-9a-f][0-9a-f],)+\/d
@JohnL4
JohnL4 / sed.ps1
Last active September 14, 2018 14:53
sed-like PowerShell command to null out hex codes in registry dumps before diffing
cat .\hklm-after-scm-client-but-before-reboot.reg `
| % {$_ -replace '([0-9a-f][0-9a-f](,|$))+','hex-codes'} `
> ..\RegistryHijinks.edited\hklm-after-scm-client-but-before-reboot.reg
@JohnL4
JohnL4 / xml-comments.cs
Created September 21, 2018 17:45
XML comment-based documentation for C# -- lists
/// <list type="bullet">
/// <item><description>
/// blah blah blah
/// </description></item>
/// </list>
// See https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/list
@JohnL4
JohnL4 / org-mode-live.txt
Last active October 8, 2018 18:46
Live updates of org-mode files
In emacs lisp (emacs 25.2.1; org-mode 9.1.2):
(add-hook 'org-mode-hook
(lambda ()
(add-hook 'after-save-hook 'org-html-export-to-html nil t)
))
In org-mode file (having downloaded live.js from https://livejs.com):
#+HTML_HEAD: <script src="/live.js"></script>
@JohnL4
JohnL4 / Xform-Nlog.ps1
Last active October 10, 2018 18:53
Using PowerShell and Apache XSLT to transform XML (semantic) logs into plain text
<#
.SYNOPSIS
Transform Sunrise Nlog output (e.g., UIShell.log) to more-readable text
.DESCRIPTION
The UIShell.log file will be found in (for example) c:/ProgramData/Allscripts Sunrise/Helios/8.4/Gateway/Log
#>
param(
[Parameter( Mandatory = $true)]
[string]
@JohnL4
JohnL4 / Get-Services.ps1
Created October 22, 2018 17:34
List Windows services matching a string
get-service | ? {$_.Name -match 'allscripts|sunrise|helios' -or $_.DisplayName -match 'allscripts|sunrise|helios'}
<# Could maybe create a string variable w/the regexp so we don't have to type it twice. #>
ls $src | ? {$_.LastWriteTime -ge (Get-Date).AddMinutes( -5)} | cp -dest $dest -for -pass
@JohnL4
JohnL4 / footnote-standout-highlight.org
Created November 7, 2018 00:21
Garish highlighting for footnotes in org-mode html
#+HTML_HEAD: <style>a.footref { background-color: cyan; font-weight: bold; padding: 0.3em; }</style>