How to open a PDF file at a specific page with a link
To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL.
For example, this HTML tag opens page 4 of a PDF file named myfile.pdf:
<A HREF="http://www.example.com/myfile.pdf#page=4">
Note: If you use UNC server locations (\\servername\folder) in a link, then set the link to open to a set destination using the procedure in the following section. If you use URLS containing local hard drive addresses (c:\folder\), then you cannot link to page numbers or set destinations. With Adobe Acrobat 7.0 products, a link to a page number only works if you use HTTP or HTTPS locations. UNC server locations will only work if you use the set destinations method outlined in the following section of this document.
Powershell: Scanning a network for alive hosts
This is a way to scan a network for ip's and return if hosts are alive or dead.
$i =1
$Ip = "10.0.0."
$ipsamling = @()
Write-Host "IP Address"
Write-Host "----------------------------------------"
do { $Ip4th = $Ip + $i
$Pingy = get-WmiObject Win32_PingStatus -f "Address='$Ip4th'"
if($Pingy.StatusCode -eq 0) {
"{0,0} {1,5} {2,5}" -f
$Pingy.Address, $Pingy.StatusCode," ON NETWORK"
$ipsamling += $Pingy.Address
}
else
{"{0,0} {1,5} {2,5}" -f $Pingy.Address, $Pingy.StatusCode, " xxxxxxxxx"
}
$i++
}
until ($i -eq 20)echo "Kontakt til:"
echo $ipsamling
Regex Basics
Here is some basic regex (Regularexpressions)
\d = digit
\d{1,2} = one or 2 digits
\d{3,} = 3 or more digits
\d+ = 1 or more digits
\d* = 0 or more digits
\D = NON digits
\w = word / letters / numbers
\w{3,6} = 3 to 6 letters or numbers
\W = NON words or numbers
\s = matches any white space character, such as tabs, spaces, and so forth.
\S = Any non space chars. space, tabs and so forth.
\\ = \
\. = .
\? = ?
\+ = +
\* = *
\b = word boundary. if i want a word this specifies the boundary. Example \b[Dd]an\b this would find "Dan" even at the start of a line or at "Dan." and only captures "Dan".
^ = marks the start of a line.
$ = ENDS the line (the same as ^, just for the end insted)
example:
"57\\Server2\Share" -match "\\\\\w+\\\w+" (True)
"57\\Server2\Share" -match "^\\\\\w+\\\w+" (False)
first is marked true while the second realises the 57 should not be there.
Its possible to make groups with the following example:
[a-z] = everything between a and z. This still counts as one character, so "a" would be true, and "ab" would be false.
[abc] = "a" true, "b" true, "c" true, "ab" false and so on.
| = Or. for example "(?:[a-z]+|\d{1,3})/.([a-z]+|\d{1,3})" would capture "0.3" and "a.5"
() = capture group
(?:regex) = the ?: excludes the capture group from the final result.
\d{1,3}? = here ? means NOT GREEDY so it would only take "1" in "123"
/i = makes the regex match case insensitive
/s = enables "single-line mode". In this mode, the dot matches newlines.
/m = enables "multi-line mode". In this mode, the caret and dollar match before and after newlines in the subject string.
/x = enables "free-spacing mode". In this mode, whitespace between regex tokens is ignored, and an unescaped # starts a comment.
Feel free to ask questions below.
Powershell: A simple RSS Reader
I experimented a bit with reading diffrent data types, and i came up with a simple rss reader
- Take a look.
#Definer hvorfra det skal hentes
$feed="http://newz.dk/rss"
# hent rss feed
$wco = New-Object System.Net.WebClient
$rss = [xml]$wco.DownloadString($feed)
# Viser det hentede
$rss.rss.channel.item | Select-Object title,pubDate,description | Sort-Object pubDate | Select-Object title,pubDate
Or as a function:
function readRss([string]$feed){
$wco = New-Object System.Net.WebClient
$rss = [xml]$wco.DownloadString($feed)
return $rss.rss.channel.item | Select-Object title,pubDate,description | Sort-Object pubDate | Select-Object title,pubDate
}readRss "http://www.newz.dk/rss"
Powershell: Create a function
A function in powershell is used as in every other object oriented programming language, by defining what it does and then call it. lets see how to create one:
function Test-Function ($1)
{
$1 += " test"
return $1
}$test = Test-function "google"
$test.ToString()
The function name here is: "Test-Function" and takes one argument that's called "$1" for this test. Within the loop you will refer to it as "$1" all the way. The value returned to the caller is returned via "return".
To call the function write "Test-function("argument")". replace argument with anything of your choice.
Note it is NOT required for a function to have any arguments!
Another example is a function i used to read a file at match it to a regular expression.
function SearchFile([string]$regex, $fileloc){
$file = Get-Content $fileloc
$array = @()
foreach ($i in $file)
{
$matches = ""
$i -match $regex | Out-Null
if (!$matches){} else {$array += $matches[0]}
}
return $array
}SearchFile "\d{1,2}.\d{1,2}.\d{1,4}" "c:\10.0.0.144.txt"