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
| public class DynamicJsonConverter : JsonConverter<dynamic> | |
| { | |
| public override dynamic Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | |
| { | |
| if (reader.TokenType == JsonTokenType.True) | |
| { | |
| return true; | |
| } |
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
| public class DateOnlyConverter : JsonConverter<DateOnly> | |
| { | |
| private readonly string serializationFormat; | |
| public DateOnlyConverter() : this(null) { } | |
| public DateOnlyConverter(string? serializationFormat) | |
| { | |
| this.serializationFormat = serializationFormat ?? "yyyy-MM-dd"; | |
| } |
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
| using Serilog; | |
| using Serilog.Events; | |
| var builder = WebApplication.CreateBuilder(args); | |
| Log.Logger = new LoggerConfiguration() | |
| .ReadFrom.Configuration(builder.Configuration) | |
| .CreateLogger(); | |
| try |
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
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| if ($host.Name -eq 'ConsoleHost') | |
| { | |
| Import-Module PSReadLine | |
| } | |
| Set-PSReadLineOption -PredictionSource History | |
| Set-PSReadLineOption -PredictionViewStyle ListView |
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
| # 移除兩個不實用的 Cmdlet Aliases | |
| If (Test-Path Alias:curl) {Remove-Item Alias:curl} | |
| If (Test-Path Alias:wget) {Remove-Item Alias:wget} | |
| # 快速開啟 c:\windows\system32\drivers\etc\hosts 檔案 | |
| function hosts { notepad c:\windows\system32\drivers\etc\hosts } | |
| # 快速產生一組亂數密碼 (預設會產生 10 個字元的密碼) | |
| function New-Password { | |
| <# |
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
| # winget parameter completion | |
| Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock { | |
| param($wordToComplete, $commandAst, $cursorPosition) | |
| [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new() | |
| $Local:word = $wordToComplete.Replace('"', '""') | |
| $Local:ast = $commandAst.ToString().Replace('"', '""') | |
| winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object { | |
| [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
| } | |
| } |
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
| { | |
| "final_space": true, | |
| "console_title": true, | |
| "console_title_style": "folder", | |
| "blocks": [ | |
| { | |
| "type": "prompt", | |
| "alignment": "left", | |
| "horizontal_offset": 0, | |
| "vertical_offset": 0, |
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
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| if ($host.Name -eq 'ConsoleHost') | |
| { | |
| Import-Module PSReadLine | |
| } | |
| Set-PSReadLineOption -PredictionSource History | |
| Set-PSReadLineOption -PredictionViewStyle ListView |
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
| // ==UserScript== | |
| // @name 中、英文網頁切換的瀏覽器書籤小工具 | |
| // @namespace https://blog.miniasp.com/ | |
| // @version 0.1 | |
| // @description 按下 Alt+s 就會自動將目前網頁切換至中文或英文版 | |
| // @license MIT | |
| // @homepage https://blog.miniasp.com/ | |
| // @homepageURL https://blog.miniasp.com/ | |
| // @website https://www.facebook.com/will.fans | |
| // @source https://github.com/miniasp/en-zh-bookmarklet |
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 New-RandomPassword { | |
| param( | |
| [Parameter()] | |
| [int]$MinimumPasswordLength = 8, | |
| [Parameter()] | |
| [int]$MaximumPasswordLength = 12, | |
| [Parameter()] | |
| [switch]$ConvertToSecureString | |
| ) | |
| $length = Get-Random -Minimum $MinimumPasswordLength -Maximum $MaximumPasswordLength |