This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Post-ToSlack | |
{ | |
Param( | |
[Parameter(Mandatory = $true,Position = 0,HelpMessage = 'Chat message to send')] | |
[ValidateNotNullorEmpty()] | |
[String]$Message, | |
[Parameter(Mandatory = $true,Position = 1,HelpMessage = 'Slack webhook URL')] | |
[ValidateNotNullorEmpty()] | |
[String]$uri, | |
[Parameter(Mandatory = $false,Position = 2,HelpMessage = 'Slack channel')] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Exit-TsSession { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True, | |
ValueFromPipeline=$True)] | |
[string[]]$computername | |
) | |
begin { | |
$username = $env:USERNAME | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------- | |
# Name: cookies.py | |
# Purpose: Import cookies as JSON and output in WPT script format | |
# | |
# Author: Ross Brown | |
# | |
# Created: 23/05/2014 | |
# Copyright: (c) RBrown 2014 | |
# Licence: Beerware | |
#------------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Convert-ToUnixDate ($PSdate) { | |
$epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970') | |
(New-TimeSpan -Start $epoch -End $PSdate).TotalSeconds | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-UnixDate ($UnixDate) { | |
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($UnixDate)) | |
} | |
# It returns a PowerShell DateTime object, which can be manipulated | |
# using the standard DateTime methods, eg | |
PS> $logtime = Get-UnixDate 1269313872.893866062 | |
PS> $logtime | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> 'My phone number is 01-234-5678' -replace '[\d-]','#' | |
My phone number is ########### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$myString = "99 Bottles of beer on the wall!" | |
$myValue = $myString -replace '[ !,.a-zA-Z]' | |
Write-Host $myValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> '1 is a number, so is 2. I quite like 3 and 4 too' -replace '[ ,.a-zA-Z]' | |
1234 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> '1,2,3,4,5,6,,,' -replace ',' | |
123456 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat /var/log/nginx/access.log | awk '$9 ~ "200" {print $2}' | sort | uniq -c | sort -hr |
NewerOlder