Anduin

let today = new Beginning();

All Posts


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 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

FFmpeg 用法概览

用法概览 ffmpeg有两种用法,一种是复制流,一种是编码流。 复制流 如果采用复制流,其参数简单,工作效率会极高,而且处理器占用率极低,往往能够每秒复制几千帧,是视频播放速度的几百倍。这种方法非常推荐。 但是,复制流无法修改视频的码率、分辨率,也无法改变视频格式。 如果需要直播,建议先将视频编码为可以直播的视频,再使用复制流的方法推流。 其中, 一般RTMP直播服务器接受的视频格式有:h.264编码的所有视频,一般为mp4格式或flv格式。一般RTMP直播服务器接受的音频格式有:aac编码的所有视频,一般为aac格式或mp4格式。 警告:其中Lavc57.89编码器编码的所有mp3格式音频无法推流。 编码流 如果采用编码流,其参数复杂,工作效率极低,处理器占用率极高,一般能够达到和视频播放速度相当或显著低于视频播放速度。这种方法仅适合于非直播场景。 但是,编码流,可以修改流的码率、分辨率 …

bash FFmpeg