1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
<#
.SYNOPSIS
Lorem ipsum dolor sit amet.
.DESCRIPTION
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
.PARAMETER InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
.parameter InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
bla .PARAMETER InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
.EXAMPLE
PS> .\foo.ps1
#>
@" multi
line
string
$x
"'
\n
"@
"@
@' multi
line
string
$x
"'
\n
'@
'@
$foo = "Test `u{2013} String`nwith `"escapes`" """
$foo = "Test `u{2013} String`nwith `"escapes`" `
dssad"
$foo = 'bla bla''bla bla $x `n'
$Global:HOME = "abc"
[bool]::Parse('false')
echo [bool]::Parse('false')
echo $env:EDITOR ${env:EDITOR} $foo ${foo} $foo-bar ${foo-bar} ${a b
c}
echo "hashtable: $(@{ key = 'value' })"
echo 122.42kb 332.d 23d 625 3232e+2 0x233 0b1101
echo 0xaj 0b1112 123a
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
--network todo-app `
-e MYSQL_HOST=mysql `
-e MYSQL_USER=root `
-e MYSQL_PASSWORD=secret `
-e MYSQL_DB=todos `
node:12-alpine `
cmd "npm install && npm run start"
function Get-NewPix
{
$start = Get-Date -Month 1 -Day 1 -Year 2010
$allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse
$allpix | Where-Object {$_.LastWriteTime -gt $Start}
}
function Get-SmallFiles {
Param($Size)
Get-ChildItem $HOME | Where-Object {
$_.Length -lt $Size -and !$_.PSIsContainer
}
}
function Get-EscapedPath
{
param(
[Parameter(
Position=0,
Mandatory=$true
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[string]$path
)
process {
if ($path.Contains(' '))
{
return '"' + $path + '"'
}
return $path
}
}
<#
Copied from Craft for testing syntax highlighting
#>
# this file sets some environment variables that are needed
# for finding programs and libraries etc.
# by Hannah von Reth <vonreth@kde.org>
# you should copy kdesettings.ini to ..\etc\kdesettings.ini
# and adapt it to your needs (see that file for more info)
# this file should contain all path settings - and provide thus an environment
# to build and run kde programs
# based on kdeenv.bat
cls
$env:CraftRoot=[System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$CRAFT_ARGUMENTS = $args
&{
[version]$minPythonVersion = 3.6
function findPython([string] $name)
{
$py = (Get-Command $name -ErrorAction SilentlyContinue)
if ($py -and ($py | Get-Member Version) -and $py.Version -ge $minPythonVersion) {
$env:CRAFT_PYTHON=$py.Source
}
}
findPython("python3")
findPython("python")
function readINI([string] $fileName)
{
$ini = @{}
switch -regex -file $fileName {
"^\[(.+)\]$" {
$section = $matches[1].Trim()
$ini[$section] = @{}
}
"^\s*([^#].+?)\s*=\s*(.*)" {
$name,$value = $matches[1..2]
$ini[$section][$name] = $value.Trim()
}
}
$ini
}
if(test-path -path $env:CraftRoot\..\etc\kdesettings.ini)
{
$settings = readINI $env:CraftRoot\..\etc\kdesettings.ini
}
else
{
Write-Error("$env:CraftRoot\..\etc\kdesettings.ini Does not exist")
break
}
if( $CRAFT_ARGUMENTS[0] -eq "--get")
{
Write-Host($settings[$CRAFT_ARGUMENTS[1]][$CRAFT_ARGUMENTS[2]])
break
}
function prependPATH([string] $path)
{
$env:PATH="$path{0}$env:PATH" -f [IO.Path]::PathSeparator
}
if( -Not $env:CRAFT_PYTHON)
{
prependPATH $settings["Paths"]["Python"]
$env:CRAFT_PYTHON=[IO.PATH]::COMBINE($settings["Paths"]["Python"], "python")
}
(& $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "CraftSetupHelper.py")) "--setup") |
foreach {
if ($_ -match "=") {
$v = $_.split("=")
set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
#Write-Host("$v[0]=$v[1]")
}
}
cd "$env:KDEROOT"
}
function Global:craft() {
return & $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "craft.py")) $args
}
if($args.Length -ne 0)
{
invoke-expression -command "$args"
}
|