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-FileEncoding { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$Path | |
) | |
[byte[]]$byte = get-content -Encoding byte -ReadCount 4 -TotalCount 4 -Path $Path | |
$encoding = 'utf8'; | |
if ( $byte[0] -eq 0xef -and $byte[1] -eq 0xbb -and $byte[2] -eq 0xbf ) | |
{ $encoding = 'utf8-with-bom'; } | |
elseif (($byte[0] -eq 0xfe -and $byte[1] -eq 0xff) <#big endian#>) |
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
[DefaultProperty("ViewPropertyBindings")] | |
[ContentProperty("ViewPropertyBindings")] | |
internal class InjectedView : FrameworkElement | |
{ | |
private readonly IKernel kernel; | |
private FrameworkElement visual; | |
private ObservableCollection<ViewPropertyBinding> viewPropertyBindings; |
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
#requires -version 5 | |
Set-StrictMode -Version Latest | |
function Get-WindowsCredentialManagerPSCredential { | |
[CmdletBinding()] | |
param( | |
[Parameter(Position = 0, Mandatory = $true)] | |
[Alias("Name")] | |
[ValidateNotNullOrEmpty()] | |
[string]$Url |
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
$lic = New-Item -ItemType Directory -Name "lic" -Force -ErrorAction "Stop"; | |
$projects = @( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } ); | |
$deps = $projects | %{ $_ | Add-Member -MemberType "NoteProperty" -Value "$($_.Id)@$($_.Version)" -Name "Key"; $_ } | Sort -Property "Key" -Unique; | |
$deps | %{ $pkg = $_; if($null -eq $pkg.LicenseUrl) { Set-Content -Path ($lic.FullName + "\no_license_" + $pkg.Id + ".txt") -Value "NO-LICENCE" } } | |
$loaded = $deps | %{ $pkg = $_; if($null -ne $pkg.LicenseUrl) { Try { $extMatch = [regex]::Match($pkg.LicenseUrl, '^.*?(\.html?|\.txt)$'); if($extMatch.Success){$ext = $extMatch.Groups[1].Value;} else {$ext = ".html"} $cnt = (New-Object System.Net.WebClient).DownloadString($pkg.LicenseUrl); Write-Host "$($pkg.LicenseUrl) downloaded for $($pkg.Id)."; @{ PKg = $pkg; Content = $cnt; } | Write-Output } Catch [system.exception] { Write-Host "Could not download license for $($pkg.Id) -> '$($pkg.LicenseUrl)'" } } } | |
$loaded | %{ $pkg = $_["Pkg"]; |
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
@( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } ) | %{ $_ | Add-Member -MemberType "NoteProperty" -Value "$($_.Id)@$($_.Version)" -Name "Key"; $_ } | Sort -Property "Key" -Unique | %{ Uninstall-Package -Id $_.Id -ProjectName $_.ProjectName -Force -RemoveDependencies -ErrorAction Ignore } |
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
$packagesPath = (Join-Path -Path $WorkingDirectory -ChildPath "packages"); | |
if (Test-Path -Path $packagesPath) { | |
Write-Verbose -Message "Fixing packages folder structure..."; | |
$restoredVersionedPackagePaths = @(Get-ChildItem -Path $packagesPath -Directory | | |
Select-Object -ExpandProperty "FullName" | | |
ForEach-Object { | |
$path = $_; | |
$versionedMatch = [regex]::Match($path, ".*?\\(?<path>packages\\(?<id>.*?)\.(?<version>\d+(?:\.\d+)+))"); | |
if (!$versionedMatch.Success) { | |
return; |
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
######################################## | |
## Initial data collection inside the host | |
######################################## | |
$OutputEncoding = [System.Text.Encoding]::Default; | |
[Console]::OutputEncoding = $OutputEncoding; | |
$InformationPreference = "Continue"; | |
if ($([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch "(?i)-(?:nologo|noniteractive|noecho)" -and | |
($([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch "(?i)-command" -or | |
($([System.Environment]::GetCommandLineArgs() -join " ") -imatch "(?i)-command" -and $([System.Environment]::GetCommandLineArgs() -join " ") -inotmatch ('(?i)\' + $([io.path]::DirectorySeparatorChar) + '(?i)\\(?:.*?(?<!shellIntegration|hr))\.ps1')))) { |
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
Get-Process | Group-Object -Property ProcessName | ForEach-Object { | |
$_ | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $env:ComputerName -Force; | |
$_ | Add-Member -MemberType NoteProperty -Name "MemoryUsageKB" -Value (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB); | |
$_ | Add-Member -MemberType NoteProperty -Name "MemoryPercentageOnTotal" -Value ((100/(Get-CimInstance -ClassName "CIM_OperatingSystem" -Namespace "root/CIMv2").TotalVisibleMemorySize) * (($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)); | |
$_; | |
} | Sort-Object -Descending -Property "MemoryUsageKB" | | |
Select-Object -First 5 | | |
Format-Table -Property "ComputerName","Name", @{n='Mem (KB)';e={'{0:N0}' -f $_.MemoryUsageKB};a='right'}, @{n='% on total';e={'{0:N2}%' -f $_.MemoryPercentageOnTotal};a='right'} |
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
[user] | |
name = Martin Hudasch | |
email = [email protected] | |
[push] | |
default = simple | |
[alias] | |
list-aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#" | |
aliases = list-aliases | |
la = list-aliases | |
st = status |
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
{ | |
"editor.insertSpaces": true, | |
"editor.useTabStops": false, | |
"editor.detectIndentation": false, | |
"editor.renderWhitespace": "all", | |
"editor.tabSize": 2, | |
"editor.roundedSelection": true, | |
"editor.trimAutoWhitespace": true, | |
"editor.renderIndentGuides": true, | |
"editor.formatOnSave": true, |