Skip to content

Instantly share code, notes, and snippets.

View JohnL4's full-sized avatar

John Lusk JohnL4

View GitHub Profile
@JohnL4
JohnL4 / tide-config.el
Last active September 26, 2017 11:41
emacs tide (typescript-mode) configuration
(add-hook 'typescript-mode-hook
(lambda ()
(tide-setup)
(flycheck-mode +1)
(eldoc-mode +1)
(company-mode)
(setq fill-column 120)
(local-set-key "\C-j" 'newline)
(local-set-key "\r" 'newline-and-indent) ;Auto-indent.
(local-set-key "\M-o" 'one-line-section-break)
@JohnL4
JohnL4 / Make-Zips.ps1
Last active February 7, 2020 16:31
PowerShell cmd to zip up a directory while excluding multiple subdirectories
ls -rec | ? {-not ($_.FullName -match '\\(NUnitConsole|TestRun)\\')} | write-zip -output "$(datefn).zip"
#### If you want to get fancier...
# (1) Make a list of files touched in the last hour.
$fs = ls c:\work\sxa\18.4cu2\Projects\VisitRecord\VRDotNet\Portal\SXA.VR.Portal\bin `
| ? {$_.LastWriteTime -ge (Get-Date).AddMinutes(-60)}
# (2) Add to it. The '+=' operator actually makes a new Array by copying the old Array + the entry(ies).
@JohnL4
JohnL4 / Start-Process-MsiExec.ps1
Last active December 2, 2016 21:55
Running msiexec as Administrator and getting the argument quoting right.
$VerbosePreference="Continue"
ls .\AllscriptsGateway, .\HCServer, .\EntMgr | ? {$_.Name -match '\.msi$'} | % {sudo msiexec ('/f "' + $_.FullName + '"'),'/passive'}
# VERBOSE: Start-Process «msiexec» -ArgumentList «/f "C:\SCM-Setup\Installers\AllscriptsGateway\Allscripts Gateway 16.3 (488).msi"»,«/passive»
# VERBOSE: Start-Process «msiexec» -ArgumentList «/f "C:\SCM-Setup\Installers\HCServer\Helios Connect 16.3.msi"»,«/passive»
# VERBOSE: Start-Process «msiexec» -ArgumentList «/f "C:\SCM-Setup\Installers\EntMgr\Enterprise Manager for Sunrise Enterprise 16.3 (488).msi"»,«/passive»
# Look at me, all fancy with my Unicode guillemet characters!
<#
@JohnL4
JohnL4 / TraceSourcePlay.cs
Last active December 9, 2016 21:46
Playing around with .NET TraceSource, a nicer "primitive" way of debug/trace logging than just using {Debug,Trace}.WriteLine(). More "primitive" (and lighter weight) than Enterprise Library logging.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace TraceSourcePlay
{
@JohnL4
JohnL4 / Get-WindowsServicesAndTasksWithHardcodedPasswords.ps1
Last active August 23, 2022 18:05
PowerShell command to find logon account of Windows services; also cmd line to dump attributes of scheduled tasks to CSV file
<#
This might help in finding that pesky windows service that's always locking you out when you change your password and reboot.
#>
# ft is Format-Table; -auto is auto column width; -wrap is wrap text if necessary
Get-WmiObject win32_service | sort startname,startmode,state,displayname | select StartMode,State,StartName,DisplayName | ft -auto -wrap
# Or you can select only certain services.
# '?' is 'where' alias; -match uses regular expressions; -not is (obviously) a 'not' operator.
Get-WmiObject win32_service | ? {-not ($_.state -match 'running')} | sort startname,displayname | select StartMode,State,StartName,DisplayName | ft -auto -wrap
@JohnL4
JohnL4 / whatis.ps1
Created April 24, 2017 17:43
What is that Windows process?
ps officeclicktorun | sel Description,path | ft -au -wr
@JohnL4
JohnL4 / new-random-number.ps1
Created June 9, 2017 17:37
PowerShell snippet to quickly gin up a new random number.
(new-object Random).Next()
# Or...
$n = 9999999999
[Math]::Floor((new-object Random).NextDouble() * $n) + 1
@JohnL4
JohnL4 / Copy-RecentFiles.ps1
Last active July 27, 2017 19:38
Copy files you just built to the application directory for testing.
$build = "7.3.5941.0";
$dest = "c:\Program Files (x86)\Allscripts Sunrise\Clinical Manager Client\$build";
$src = "c:\work\sxa\main\Projects/bin";
ls $src | ? {$_.LastWriteTime -ge (Get-Date).AddMinutes( -5)} | cp -dest $dest -for -pass
@JohnL4
JohnL4 / Show-Path.ps1
Created July 7, 2017 15:35
Dump out your PATH in a more usable format
$env:PATH -split ";" | less
# 'less' is from PSCX (recommended).
@JohnL4
JohnL4 / which.ps1
Created July 13, 2017 20:08
Where is this command coming from?
gcm runonce
gcm runonce | select Definition
# 'gcm' is, by default, aliased to Get-Command