This file contains 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
Use-NuGetPackage Octokit -Verbose | |
#Get Issues from GitHub repositories | |
$client = New-Object Octokit.GitHubClient("PowerShellClient") | |
$task = $client.Issue.GetForRepository("altrive", "PSCodeAnalyzer") | |
#Show results | |
$task.Result | Out-GridView |
This file contains 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
#Usage: Show-BallonTip "Title" "Message" | |
function Show-BalloonTip | |
{ | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, Position = 0)] | |
[string] $Title, | |
[Parameter(Mandatory, Position = 1)] |
This file contains 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
[Linq.Enumerable]::Any((Get-Service), [Func[object, bool]]{ param ($p) $p.Status -eq "Running" }) | |
[Linq.Enumerable]::Where((Get-Service), [Func[object, bool]]{ param ($p) $p.Status -eq "Running" }) |
This file contains 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 Main | |
{ | |
$ErrorActionPreference = "Stop" | |
Invoke-WithProgress -Activity "Test" -Action { | |
foreach ($i in 1..100) | |
{ | |
$progress.UpdateProgress($i) | |
sleep -Milliseconds 10 | |
} |
This file contains 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
Use-NuGetPackage Mono.CSharp -Verbose | |
#Setup Mono C# evaluater | |
$settings = New-Object Mono.CSharp.CompilerSettings | |
$printer = New-Object Mono.CSharp.ConsoleReportPrinter | |
$context = New-Object Mono.CSharp.CompilerContext($settings, $printer); | |
$evaluator = New-Object Mono.CSharp.Evaluator($context); | |
$evaluator.Run("using System; using System.Linq") > $null | |
#Define Func<int,int> return n^2 |
This file contains 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 Main | |
{ | |
#1.No attribute | |
$a = 5; | |
Write-Host ($a) #5 | |
#2.With Add Value attribute | |
[AddValue(5)] | |
$b = 5; | |
Write-Host $b #5+5 =10 |
This file contains 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 Main | |
{ | |
$ErrorActionPreference = "Stop" | |
Add-Type -AssemblyName System.Net.Http | |
Write-Host ("Before: {0} MB" -f ([GC]::GetTotalMemory($true) / 1MB)) | |
foreach ($i in 1..1000) | |
{ | |
Get-ContentFromUrl -url "http://localhost" > $null | |
} |
This file contains 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
param ( | |
$RequestUrl = "http://127.0.0.1" | |
) | |
function Main | |
{ | |
$ErrorActionPreference = "Stop" | |
Add-Type -AssemblyName System.Net.Http | |
#Reuse connection |
This file contains 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
Use-NuGetPackage ManagedEsent -Verbose #Require PSNuGet<https://github.com/altrive/PSNuGet> | |
$dictionary = New-Object 'Microsoft.Isam.Esent.Collections.Generic.PersistentDictionary[string,string]'("TempData") | |
try | |
{ | |
$key = Read-Host -Prompt "Enter key" | |
if ($dictionary.ContainsKey($key)) | |
{ | |
Write-Host "Key($key) is already exists" | |
} |
This file contains 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
$stream = $null | |
try | |
{ | |
$stream = [IO.File]::Open($packagePath, [IO.FileMode]::Create) | |
#$builder.Save($stream); | |
} | |
finally | |
{ | |
if ($stream -ne $null) | |
{ |
OlderNewer