Skip to content

Instantly share code, notes, and snippets.

@rossnz
rossnz / gist:8174043
Last active January 1, 2016 16:59
Generating a UNIX timestamp
# 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
@rossnz
rossnz / Get-UserAgent.ps1
Last active September 10, 2024 02:23
Generate a valid UserAgent using PowerShell's pre-built UserAgent strings. Run without parameters to get a random UA, or pass in a generic browser type to get a specific value.
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')
@rossnz
rossnz / gist:5107076
Last active December 14, 2015 15:19
Create screenshot from URL using url2picture.com
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