Anduin

let today = new Beginning();

All Posts



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

C# run tasks in a threads pool with fixed size

Imagine I have 100 tasks to run. But my machine has only 16 core. So I expect that every core will run one task in parallel. And once a core is idle, assign a new task to it. That will be very easy for C# with Task. But before starting, we gonna create a thread-safe queue for saving our tasks. public class SafeQueue<T> { private readonly Queue<T> queue = new Queue& …

C# Async Task Multi-Threading

Display code coverage information for .NET Core project using Azure DevOps.

Target. Display code coverage information on your own .NET Core project. First, create a build pipeline in your Azure DevOps. If you are using the classic designer, you need to add new .NET Core command line step. Make sure you publish the test result. As for the Arguments input, insert: --configuration $(buildConfiguration) --collect "Code coverage" Or if you are using YAML: Add …

.NET Core Azure DevOps .NET Test MSTest Integration Test Code coverage GitHub