foreach ($package in $(dotnet tool list --global | Select-Object -Skip 2)) {
Write-Host "dotnet tool update --global $($package.Split(" ", 2)[0])"
dotnet tool update --global $($package.Split(" ", 2)[0])
}
Add-Type @"
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
public static class Downloader {
public static async Task DownloadAsync(string url)
{
url = WebUtility.HtmlDecode(url);
var filename = url.Split('/').Last();
if (File.Exists(filename))
{
await Task.CompletedTask;
return;
}
using var handler = new HttpClientHandler()
{
Proxy = new WebProxy(new Uri(`"socks5://127.0.0.1:7890`")),
};
using var httpClient = new HttpClient(handler);
using (var s = await httpClient.GetStreamAsync(new Uri(url)))
{
using (var fs = new FileStream(filename, FileMode.CreateNew))
{
await s.CopyToAsync(fs);
}
}
}
public static void DownloadFile(string url)
{
Task.WaitAll(DownloadAsync(url));
}
}
"@
$files = @("https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fCRc4EsA.woff2",
"https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fABc4EsA.woff2",
"https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmWUlfBBc4.woff2")
$files | ForEach-Object {
[Downloader]::DownloadFile($_)
}
Write-Host ([System.Text.Encoding]::GetEncoding(0).CodePage)
Write-Host ([System.Text.Encoding]::GetEncoding(0).EncodingName)
Add-Type -TypeDefinition @"
using System.IO;
using System;
public class Program
{
public static void Main()
{
// Get an array with the values of ConsoleColor enumeration members.
ConsoleColor[] colors = (ConsoleColor[]) ConsoleColor.GetValues(typeof(ConsoleColor));
// Save the current background and foreground colors.
ConsoleColor currentBackground = Console.BackgroundColor;
ConsoleColor currentForeground = Console.ForegroundColor;
// Display all foreground colors except the one that matches the background.
Console.WriteLine("All the foreground colors except {0}, the background color:",
currentBackground);
foreach (var color in colors) {
if (color == currentBackground) continue;
Console.ForegroundColor = color;
Console.WriteLine(" The foreground color is {0}.", color);
}
Console.WriteLine();
// Restore the foreground color.
Console.ForegroundColor = currentForeground;
// Display each background color except the one that matches the current foreground color.
Console.WriteLine("All the background colors except {0}, the foreground color:",
currentForeground);
foreach (var color in colors) {
if (color == currentForeground) continue;
Console.BackgroundColor = color;
Console.WriteLine(" The background color is {0}.", color);
}
// Restore the original console colors.
Console.ResetColor();
Console.WriteLine("\nOriginal colors restored...");
}
}
"@
[Program]::Main()
Write-Host [System.ConsoleColor]::DarkRed
$items = git diff --name-only --cached | Where-Object -FilterScript {
($_ -Match '\.fbx$') -OR ($_ -Match '\.fbx.meta$')
}
$items | ForEach-Object {
$Pattern = '(?<suffix>\.fbx(\.meta)?)$'
if (-NOT ($_ -CMatch $Pattern)) {
Write-Host $Matches
Write-Host "suffix: $($Matches['suffix'])"
} else {
Write-Host $_
}
}
$rclone = (Get-Command -ErrorAction Ignore -Type Application -TotalCount 1 -Name "rclone").Path
Write-Host ($null -eq $clone)