Anduin

let today = new Beginning();

All Posts in 2021


Auto backup for Minecraft on Linux

Recently, I was addicted to Minecraft. And I hosted a server. In order to backup the server automatically, I have tried many solutions. Git solution Git solution requires a lot of CPU when compressing the objects. And may impact the game performance since Java itself requires a lot of CPU. So I finally gave up Git.   Copy solution Copy the world folder to anther place is super simple. Before try  …

bash Linux Minecraft Backup

Validate an object in any C# projects

Sometimes, we need to check if the input is valid. Usually, we may do this: if (string.IsNullOrWhiteSpace(InputArgument.TargetMachine) || string.IsNullOrWhiteSpace(InputArgument.PatchId)) { throw new ArgumentException($"Invalid input argument! Patch ID: '{InputArgument.PatchId}', Target Machine: '{InputArgument.TargetMachine}'!");  …

ASP.NET Core C# .NET Validation

在一秒钟内打开苏康码

之前每次进公司,为了打开苏康码,都得翻半天支付宝和微信的小程序,非常痛苦。 尤其是手机卡住了,网不稳了,小程序框架本身就加载半天,弄得我经常尴尬的卡在门外,迟到,难受。 不过,我怎么看怎么感觉,这个苏康码好像就是个网页呀,如果能抠出来URL,自己用浏览器打开,岂不是相当方便快捷? 还可以省去天天翻各种小程序了。   获取苏康码 在下面地址获取苏康码: https://scm.szgaj.cn/wjw/health_skm.html (这并不需要你有任何App例如微信、支付宝,可以在PC上操作)   (防钓鱼:         这个URL的意思,看起来是 https://苏城码.苏州公安局.中国/微警务/健康_苏康码.html。经过检查备案信息,确实属于苏州公安局。再加上有HTTPS,应该不是钓鱼链接,可以放心输入个人信息)     加速这个过程 在你通过浏览器获取到苏康码后,可以复制  …

Web China Health Code

C# Play with GZip.

A extension class for string to add GZip features. Copy the following code to your project first. using System; using System.IO; using System.IO.Compression; using System.Text; public static class GZipExtensions { private static byte[] Zip(string str) { var bytes = Encoding.UTF8.GetBytes(str); using (var msi = new MemoryStream(  …

C# .NET Compress GZip Base64

Directly talk to any enterprise Microsoft Teams user

Recently, we found that you can directly talk with any Microsoft Teams (Work or School) user. Before starting Before starting, you need to have Microsoft Teams (Work or School) installed and sign in with your work or school account. To buy it, reference Microsoft 365: Compare Microsoft 365 Enterprise plans   Find a person The approach is pretty simple. First, you need to grab his email address.  …

Microsoft Teams Microsoft 365

Use Windows as a stateless OS on your devices

Why stateless device, stateless OS? OS might be buggy Now Windows 11 is very buggy. Stuck everyday. Unresponsive everyday. Store stop working every day. Since those tiny problems emerge endlessly on Windows 11. Often inexplicable systems will fall into weird failures. Solving these problems is very difficult, and it may require us to understand how Windows works. However,  …

PowerShell Windows Windows 11 Automation Configuration Device Reimage


Install Windows store app with WinGet

Now winget supports to install a Microsoft store app. First, you need to get the store app Id. Go to the Microsoft official website: https://www.microsoft.com/en-US/ And search the store app here. For example:   Click it. And now you have the address. So, for example, the 'to do app' has ID: 9nblggh5r558 You can use command to open store: ms-windows-store://pdp/?ProductId=9  …

PowerShell Windows Winget Microsoft Store UWP Store

Install Windows 11 side-by-side without a USB drive

This tutorial only for existing Windows users which needs to install the second Windows along-side it without USB disk or CD. How When you have the Windows installer, you can directly unzip the install.wim to a new partition. This process does not need to restart or enter the PE environment, so no USB storage disk nor CD is required.   After the decompression is complete, directly boot the new  …

Windows 10 PowerShell Windows Windows 11 Install DISM Bcdedit Boot BCD

Retry with exponetial back-off on C#

Just built a simple retry engine in C#. /// /// Retry engine. /// public class RetryEngine { private static Random rnd = new Random(); private readonly ILogger logger; /// /// Creates new retry engine. /// /// Logger public RetryEngine(  …

C# .NET Retry

找到玄学问题的根源的方法 - 夹逼调试法

背景 最近经常会有人找我问一些非常有趣,但是又非常玄学的问题。这类玄学问题我指的是正常情况下明明能工作,现在却不知为何无法工作的情况。 这些问题往往和非常多的难以预料的因素(例如环境)有关。例如:为什么我无法将一个文件签入到git? 解决大部分玄学问题,往往需要我主动在他的电脑上进行大量操作、环境分析,才能知道到底是哪里对程序产生了影响。或往往需要我反复沟通数十条消息才能真正判断问题所在。而且这类问题,由于正常情况下是能工作的,所以非常难以通过Google和Stack Overflow解决。 后来我想,与其每次都花费大量时间帮别人解决问题,不如抽象出一套能够解决上述问题的通用方法,来让大部分人能够自行解决这些问题。 夹逼调试法由此诞生。 夹逼调试法 夹逼调试法,指的是通过两个方向共同限制作用,使得问题根源的可能范围集中在最小化的条件变化中。 夹逼调试法适用于解决: 平时或  …


The simplest way to retry in PowerShell

$attempt = 0 do { try { Do-SomeThing-That-May-Crash-Here $success = $true } catch { if ($attempt -eq 5) { throw } Write-Host "Task failed. Attempt $attempt. Will retry in next $(5 * $attempt) seconds. Error: $($Error[0])" -ForegroundColor Yellow Start-Sleep -Seconds $(5 * $attempt) } $attempt++ } until($  …

PowerShell Retry

时评:国家对于子女教育方面的政策还需要多方面配套

之前看到中央办公厅 国务院办公室印发了减轻学生作业和校外培训负担的意见。(中共中央办公厅 国务院办公厅印发《关于进一步减轻义务教育阶段学生作业负担和校外培训负担的意见》_中央有关文件_中国政府网 (www.gov.cn)) 从意见中看得出,其主要目的之一,仍然是为了降低现在家长的育儿压力。而目前的现状仍然更倾向于是:家长没有那么多精力来管教孩子的业余生活,而课外生活往往又内卷于做题和研究解题技巧这些意义不大的事情上。通过标准教育流程的学生,往往精于解题技巧,却对社会本身的运行原理理解并不深入,生存能力也并不高,反而在业余时间找不到舒适又能够被所有人许可的娱乐方式。 而在6月8日,人民时评一篇报道:以制度效能守护健康上网(人民时评)--理论-中国共产党新闻网 (people.com.cn),其主要方向仍然围绕在避免未成年人的过度网络游戏、消费行为上。要求增加更多对未成年人在网络游戏上的制度建 …

China Politics Education


Build a common cache service for your C# app.

Recently, I found that almost every time I creates a new .NET app, I gonna need cache service. While Microsoft officially provides the IMemoryCache, I found that it is pretty complicated for you to use it. For it requires a lot of code. So I wrapped it to a more common one. Before starting, make sure the project references Microsoft.Extensions.Caching.Memory and Microsoft.Extensions.Logging.  …

ASP.NET Core C# .NET Core Performance .NET Cache MemoryCache


Tips about rules setup for Outlook enterprise users

How to set rules for an employee in a large company that uses outlook? As I work at Microsoft, I receive thousands of emails every day. Usually including: Advertisement and news. Daily updates. Topics about the project I'm working on. My crew working discussion Robots notification (like GitHub notification) Incident alerts. Oncall requests from other teams. Updates from my organization. Questions  …


软件工程领域中的逆全球化趋势

在过去的二十年间,我们目睹了中美关系的长足发展带来了在技术领域非常多元的交流。其中典型的代表,就是微软和苹果在中国的市场发展。李永乐老师的视频中曾经指出:两个国家在贸易的过程中,一定是对国家双方都有利益的。 在这样的思想的指导下,我们始终认为构建的应用,也应该是越来越“全球化”的。所谓全球化,指的也正是在应用能够全球布局,全球服务。而面向这种全球布局的应用,我们完全可以在已有的基础设施、服务和运维经验的基础上,来大幅度的降低我们的维护成本。因为我们始终只需要一份专业的运维团队来维持全球的数据和服务。 我们曾经在思考一个问题的时候,也随着技术的背景发展,我们思考“分布式”的方式也逐渐改变。其中,最典型的代表就是在思考CAP定理时,我们更多的考虑的是实现分区容忍性和可用性,而弱化最终一致性。这类使用场景,在例如Email、微信等通信App的构建上时非常典型。也就是说,我们可以考虑中美两个大型数 …

Multi-tenant China Software Development AirGap

Build a package that can be used in browser and node with TypeScript

Sometimes I may need to share some of my logic\algorithm with other developers. In this case I might need to build a library. That library might be used in the customer's browser, or might be referenced by other front-end projects, may be based on Angular or React. So how can we build a package with TypeScript that benefits from strong type while can be installed\reference\used by others? After  …

Web npm TypeScript node webpack JavaScript Front-end

Use Azure Key Vault to store connection strings for App Service.

Sometimes, we need to provide key-values as environment variables for Azure app service, like database connection strings. In some cases, we might need someone to collaborate managing the app service. However, with app service environment variables access, he will also be able to connect to the database manually and do custom database operations, like drop database. That is not what we expected.  …

Azure App Service Azure Security Key vault

Programmatically connect to the remote server via SSH and execute remote command.

Recently I was trying to build a server management tool. That I need to connect to my server (Ubuntu) programmatically. I usually access my server via SSH, as a normal human. So I wanna do it with the same approach. First, create a new .NET Core project with: dotnet new console After creating the new project, install the latest SSH.NET library. Reference: NuGet Gallery | SSH.NET 2020.0.1 And  …

C# .NET Core bash Linux SSH

Use JetBrains code quality analyzer to prevent checking-in bad C# code

When we are using Azure DevOps to review PR, it's simple and easy to use. Usually, we only run tests and build tasks, like this: In my previous blog, I mentioned how to run test and generate code coverage for CI pipelines: Display code coverage information for .NET Core project using Azure DevOps. - Anduin Xue (aiursoft.com) -------------- JetBrains ReSharper and Rider are impressive C# grammar  …

C# Azure DevOps JetBrains Resharper Code Quality Pipelines