let today = new Beginning();

All Posts


Best-practice for authentication after creating a new Linux server

This article helps you change the following items if your cloud provider didn't do that for you. Create your own account instead of root. Disable password login and force to use SSH key to log in. Disable root account. Enable sudo without password. Before starting the process, make sure you have a valid SSH key-pair locally. Fist, connect to the server. (With root password). you@local …

bash Linux Ubuntu SSH

Setup auto-renew wildcard HTTPS certificate on Azure virtual machine

Sometimes we might need to host a website in Azure. And there are so many options, like storage account, app service. But none of those supports wildcard HTTPS and auto-renew. An ideal configuration shall be static which means that it will never crash even when no one maintains it. Auto-renew is a must-have feature for HTTPS. Luckily, I got a solution based on win-acme: https://github.com/win- …

Azure Azure DNS Windows Server HTTPS Win-ACME Certificate letsencrypt ACME

C# Rotate the square matrix

This is one of my questions from an interview. The interviewer asked me to rotate a square matrix in C#. While it is not so hard for me and I have done it in 10 minutes, I'd share my solution to all developers who may need this. namespace Test { class Program { static void Main(string[] args) { var a = new int[][] { new int[] …

C# Algorithm Matrix Math

Creating a proxy to another URL with ASP.NET Core

This post talks about writing a simple HTTP proxy logic in C# or ASP.NET Core. And allowing your project to proxy the request to any other URL. It is not about deploying a proxy server for your ASP.NET Core project. Before starting, you need to be clear about the target you are going to proxy for. It shall be an URL. Add the following code anywhere of your project. public static …

ASP.NET Core Reverse Proxy Web Proxy

Fix Azure Media Player can't play video in iOS mobile devices

Recently, when we are trying to distribute video from Azure Media Service, we noticed that our video can't be played in iOS mobile devices. But the same web page plays normally in Android devices. There are multiple reasons for iOS devices to load and play Azure Media Player. As for the player itself is not open source, it might happen some strange effects when I change these settings. But the …

Azure Media Player Azure Azure Media Service

微信的架构是如何实现分布式消息分发?

我们每天的生活都离不开微信。微信基本上已经成了在中国生活的一部分。 但是,微信有些方面的功能总是看起来令人觉得有些奇怪。例如: 微信几乎是第一款需要手机扫码才能登录PC端的 微信群和微信聊天记录在切换设备后会完全无法同步 你无法得知自己是否被一个微信好友拉黑了 你不能同时在多个移动设备上同时登录微信 从产品的角度来看,这些设定看起来彷佛是在给用户制造障碍,也成了大家普遍对微信的槽点。那么,微信的团队为什么要这么设计,而为什么又不改良它的体验呢?我想或许问题并不只是产品和需求分析这么简单,而是还需要进一步探寻架构上的本质。 在我生活在澳大利亚期间,我发现一件很有趣的事情:在澳大利亚,我使用微信给同样在澳大利亚的好友发送微信消息,他也可以几乎瞬间收到。假想微信在国内建立单点的服务器,那么这种性能一定不足以支撑澳大利亚内的通信。数据从澳洲抵达中国再从中国推送到澳洲至少需要5 …

Web WeChat Distributed Messging IM

Download any Azure Media Service video or live stream with FFmpeg.

This blog shows a tutorial about how to download any Azure media service video or live stream. Before starting, you need to have FFmpeg installed. No matter you are using Windows, Linux, or Mac OS. Download latest FFmpeg here: https://ffmpeg.org/download.html After installing it, prepare a command: ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "{0}" -c copy video.mp4 And you …

Azure Media Player bash Azure Azure Media Service Download FFmpeg

EF second layer cache to enhance your SQL database performance based on Redis

Entity-Framework Core is a lightweight, extensible, open-source, and cross-platform version of the popular Entity Framework data access technology. It really helps the developer to build applications which access database easily. But in most cases, we may cache some results which do not change frequently, to reduce access to our database. For example, the home page of a blog may not change …

ASP.NET Core C# SQL Server SQL Entity Framework Core Azure Redis Caching

在前端哈希密码是否是个不错的方案?

脑筋急转弯:为了防止运维人员能够直接去数据库里查看密码,Web应用普遍采用将密码哈希一趟后再存入数据库。需要校验时,由前端提供密码值,服务器将密码哈希后再比对,从而判断密码是否正确。这样运维人员即使接触的到数据库,也最多只能重置密码,无法登录一个特定的账号。那么,既然最终需要比对的是密码的哈希,为何不直接在前端哈希完,再直接把哈希后的结果发给服务器,来鉴定密码是否正确呢?答案其实挺简单的。当初我们加一次哈希是为了阻止运维登录。而如果哈希在前端完成,那么对于服务器而言,它其实只是做了一次明文的比较。数据库里的哈希值就相当于密码了。运维完全可以直接拿着哈希去调登录的API来获取一个账号的权限。 这个脑筋急转弯挺有趣的,乍一看仿佛还挺有道理的。但是换句话说,虽然看起来前端加哈希蠢蠢的,其实历史上有很多公司和项目都做过类似的事情。其中比较典型的就是腾讯公司的QQ了。 在十几年前的时候, …

Security Password Hash

软件定制行业为何应当发展软件订阅制?

凡是涉及到事业单位的项目,涉及到知识产权外包的,通俗来说,就是自己写完就卖出去的代码,普遍软件的质量都相当差劲,漏洞百出,功能欠缺。开发商(乙方)在验收完成后,等付款方(甲方)完成验收,安装完成后,往往拿钱走人就去拓展下一个项目。这种低质量的软件严重影响企业的扩展和用户体验,甚至能够影响整个行业的健康度和。对于我们普通人的认知,就是非互联网企业的线上服务体验往往都很遭。 表面来看可能是因为构建软件的程序员水平较弱。但是如果它形成了一个现象,那么问题一定是在规则上。在于软件本身质量而引发的责任在多次承包后足够弱化,导致真正构建软件的人根本不在乎代码的质量。这是由于现在普遍的商业采购模式导致的。而要想解决这个问题,发展软件订阅制是个非常不错的方案。 对于甲方来说,采用订阅制来采购软件,就是按时间和用量付费,而不购买整个软件源码的知识产权。换句话说,就是买软件的使用权和一种服务,这个服务就是 …

DevOps China Software Development SaaS Subscription

Get unique random numbers in C#

The source code this blog mentioned is here: https://github.com/Anduin2017/SuperRandom The traditional methods for obtaining `n` non-repeating random numbers are: The random number is generated by the linear congruence method, and each random number is generated and compared in the database. If it already exists, the number is discarded. Randomly generate a linear sequence, and then …

C# .NET Core Algorithm Random Numbers Unique random Non-repeat Random