Skip to content

Instantly share code, notes, and snippets.

jkdba / MSSQL_RepetitiveReplace_fn.sql
Last active Jan 28, 2022
Simple function to recursively replace a pattern in a string.
View MSSQL_RepetitiveReplace_fn.sql
CREATE FUNCTION dbo.RepetitiveReplace_fn
@P_Pattern VARCHAR(MAX),
@P_ReplaceString VARCHAR(MAX),
@P_ReplaceLength INT = 1
jkdba / Microsoft.PowerShell_profile.ps1
Last active Aug 25, 2016
Updated PowerShell Console Window Title to Last Command and Current Path
View Microsoft.PowerShell_profile.ps1
## Use PowerShell Engine Event (OnIdle) to Update the PowerShell
## Console Window's Title to have the current path and last command executed.
## For this to work Nicely add it to your PowerShell Profile.
## Subscribe to PowerShell.OnIdle Event
## Out to null to hide Register-EngineEvent output
$null = Register-EngineEvent PowerShell.OnIdle -Action {
## Get Last Command ran from history
$LastCommand = Get-History | Sort-Object -Property Id -Descending | Select-Object -First 1 -exp CommandLine
## Updated the console window's title to have the path and command.
jkdba / Invoke-URLInDefaultBrowser.ps1
Created Jun 13, 2016
PowerShell cmdlet to open a URL in the user's default browser.
View Invoke-URLInDefaultBrowser.ps1
function Invoke-URLInDefaultBrowser
Cmdlet to open a URL in the User's default browser.
Cmdlet to open a URL in the User's default browser.
Specify the URL to be Opened.
jkdba / AutomaticJobCleanup.ps1
Last active Jun 12, 2022
PowerShell Automatically Cleanup Job on Completion Using a Registered Object StateChanged Event
View AutomaticJobCleanup.ps1
#Build Job Name to be unique
$JobName = "ExampleJob"
$JobNameCount = (get-job | Where-Object Name -like $JobName*).Count
$JobName = "$($JobName)_$($JobNameCount)"
#Define and Start job
$Job = Start-Job -Name $JobName -ScriptBlock { Start-Sleep 60 }
#Create Event to clean up job after complete
Register-ObjectEvent -InputObject $Job -EventName "StateChanged" -Action {
jkdba / ToastNotification_Windows10.ps1
Created May 9, 2016 — forked from altrive/ToastNotification_Windows10.ps1
Windows 10 toast notification sample
View ToastNotification_Windows10.ps1
$ErrorActionPreference = "Stop"
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipuration
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null