Skip to content

Instantly share code, notes, and snippets.

View JohnL4's full-sized avatar

John Lusk JohnL4

View GitHub Profile
@JohnL4
JohnL4 / git-color.ps1
Created November 28, 2018 17:20
git color settings for PowerShell
<#
Default git color settings ("red", "green") for powershell are too dim to read easily. Rather than finagle the window colors (which
probably interferes with other Windows tools (PSCX, PowerTab) that assume certain color settings), we change the colors in git.
#>
git config --global color.status.added "bold green"
git config --global color.status.untracked "bold red"
git config --global color.status.nobranch "bold red red" # Bright red on dim red
# Could also just use the following if you don't want to mess around with color at all:
@JohnL4
JohnL4 / howto-org-mode.org
Created November 12, 2018 22:06
org-mode templates, css, etc.

Notes on org-mode text markup

Overview

@JohnL4
JohnL4 / set-prompt.ps1
Last active November 12, 2018 22:13
Quick-n-dirty reverse-video bash and PowerShell prompts
# Update the following two variables to modify the window title more-or-less permanently. Otherwise, your attempt to
# update the window title will be immediately wiped out by this prompt function.
# Update these variables from other functions like this: Set-Variable -Name PROMPT_TITLE_PREFIX -Value $title -Scope Global
$PROMPT_TITLE_PREFIX = ""
$PROMPT_TITLE_SUFFIX = ""
<#
.SYNOPSIS
Returns true iff current PowerShell session is running with elevated privileges (i.e., "As Administrator").
.NOTES
@JohnL4
JohnL4 / mirror-directory.ps1
Last active November 11, 2020 15:38
Mirror a directory of a static web site from one Windows machine to another, using a PowerShell Session instead of CIFS/SMB
# Get a handle to the directory. (This won't be a string, but a filesystem object, so you can do it however you need to.)
# ('gi' is Get-Item)
$dirToPush = gi work\Sunrise\DischargeDisposition\Defect\4960223-2nd-tab-bool-set-activity-not-completed
# Get the full path WITHOUT the drive specifier (i.e., rip off the "C:" part)
$dirToPushNoq = $dirToPush.FullName | split-path -noq
# Start a new PowerShell session (default idle timeout for these things is 2 hours, apparently)
# ('nsn' is New-PSSession)
$vm = nsn NedDevSrvJ6L
@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>
ls $src | ? {$_.LastWriteTime -ge (Get-Date).AddMinutes( -5)} | cp -dest $dest -for -pass
@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. #>
@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 / 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 / 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