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-Screenshot ($url) { | |
| $apiKey = 'Your-API-key' | |
| $secret = 'Your-Secret' | |
| $urlpart = '?apikey=' + $apiKey + '&url=' + $url | |
| [Void][Reflection.Assembly]::LoadWithPartialName("System.Web") | |
| $token = ([System.Web.Security.FormsAuthentication]::HashPasswordForStoringInConfigFile($urlpart + $secret, 'MD5')).tolower() # Won't work if upper case | |
| $requrl = 'http://www.url2picture.com/Picture/Png' + $urlpart + '&token=' + $token | |
| Write-Output $requrl |
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-UserAgent { | |
| # Uses PowerShell's prebuilt UA strings. See | |
| # http://goo.gl/9IGloI | |
| param ( | |
| [ValidateSet('Firefox','Chrome','InternetExplorer','Opera','Safari')] | |
| [string]$browsertype | |
| ) | |
| if (!$browsertype) { | |
| $browsers = @('Firefox','Chrome','InternetExplorer','Opera','Safari') |
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
| # Show current date/time as a UNIX timestamp | |
| date +%s | |
| # Show the timestamp for an arbitrary date/time | |
| date -d '01/12/2013 16:42:13' +%s | |
| # Convert a timestamp to a date/time | |
| date -d @1357962133 |
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 |
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
| 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
| $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> '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
| 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
| Function Convert-ToUnixDate ($PSdate) { | |
| $epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970') | |
| (New-TimeSpan -Start $epoch -End $PSdate).TotalSeconds | |
| } |
OlderNewer