Skip to content

Instantly share code, notes, and snippets.

@mxpv
mxpv / windows_build_numbers.txt
Last active June 5, 2023 06:53
Windows build numbers
Windows Name or Service Pack Version Number
---------------------------- --------------
Windows 1.0 1.04
Windows 2.0 2.11
Windows 3.0 3
Windows NT 3.1 3.10.528
Windows for Workgroups 3.11 3.11
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 23, 2024 19:14
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
function Get-NumberRange
{
[cmdletbinding()]
Param()
DynamicParam {
$Dictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
$NewDynParam = @{
Name = "Firstnumber"
Alias = "int"
@jkdba
jkdba / ToastNotification_Windows10.ps1
Created May 9, 2016 17:30 — forked from altrive/ToastNotification_Windows10.ps1
Windows 10 toast notification sample
$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
@jkdba
jkdba / AutomaticJobCleanup.ps1
Last active June 12, 2022 23:57
PowerShell Automatically Cleanup Job on Completion Using a Registered Object StateChanged Event
#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 {
@indented-automation
indented-automation / Get-CommandParameter.ps1
Last active December 17, 2021 23:27
Gets the parameters for a command from the default parameter set
function Get-CommandParameter {
param (
[Parameter(Mandatory = $true)]
[String]$Command,
[Switch]$GetDefaultValues
)
$defaultParams = @(
[System.Management.Automation.Internal.CommonParameters].GetProperties().Name
@indented-automation
indented-automation / Get-CommandParameter.ps1
Last active October 26, 2022 21:34
PowerShell version 2 param block parser
function Get-CommandParameter {
# .SYNOPSIS
# A PowerShell version 2 compatible parameter block parser.
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 1, ValueFromPipelineByPropertyName = $true)]
[String]$Definition
)