Finisky Garden

NLP, Software Engineering, Product Design

0%

When working with Azure Virtual Machines (VMs), monitoring performance metrics is essential for ensuring optimal operation. A common scenario involves tracking the CPU Credits Remaining for a B-series burstable VM instance.

Typically, we use az vm monitor metrics tail to get the CPU Credits Remaining metric:

Transaction systems are at the heart of modern commerce and financial activities, spanning a wide range of scenarios from e-commerce order processing to real-time settlements in financial institutions. Such systems demand high concurrency handling, real-time data storage, and efficient retrieval capabilities, all while balancing data consistency and performance. As transaction data continues to grow in scale and complexity, traditional transaction system architectures often struggle to meet these challenges due to rigid table structures and limited horizontal scalability.

MongoDB, as a distributed document-oriented database, provides a modern solution for building complex and efficient transaction systems. With its flexible schema design, high throughput capabilities, and built-in transaction support, MongoDB addresses diverse business needs effectively.

Received a certificate renewal notification from Tencent Cloud, but when applying for a new certificate, I found out that Tencent Cloud no longer offers free one-year certificates:

Starting from April 25, 2024, the validity period of new free certificates issued by Tencent Cloud will be adjusted to 90 days.

Since I’ve always updated certificates manually, doing it every three months feels quite tedious. So, I decided to explore Certbot from Let’s Encrypt. My only concern was how to prove ownership of a subdomain. After trying it out, I realized this wasn’t an issue at all, as Certbot only issues certificates and doesn’t pose any threat to the website itself.

Here are the configuration steps for Certbot. In fact, it’s very simple and only requires running a few commands.

Nowadays, many popular apps incorporate social network features, such as Twitter, WhatsApp, and Facebook. These platforms need to scale to accommodate billions of users (graph nodes), which is no small feat. Building and maintaining a scalable social network infrastructure requires careful planning and strategic data modeling. In fact, specialized social networking applications like Facebook have dedicated teams focusing solely on optimizing their performance to the highest level. However, for smaller apps or startup projects looking to add social networking capabilities, creating a full team to handle such architecture is often impractical and unnecessary.

So, is it possible to build a high-performance, scalable social network using the right data modeling and storage solutions? The answer is yes. Early versions of Facebook used MySQL as the underlying storage to construct their social network, but today we have more advanced and efficient storage options available: MongoDB.

After upgrading packages in a conda env, talib cannot accept dataframe as input, the error message looks like TypeError: Argument 'xxx' has incorrect type (expected numpy.ndarray, got DataFrame):

1
2
3
4
5
6
Traceback (most recent call last):
  File "/data/1.py", line 7, in <module>
    df['SMA_5'] = ta.SMA(df['Close'], timeperiod=5)
  File "/data/miniconda3/envs/a/lib/python3.10/site-packages/talib/__init__.py", line 64, in wrapper
    result = func(*_args, **_kwds)
TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got DataFrame)

Most of the web search results are misleading, like changing the df into np array. Since the code works before updating packages, the problem should be package incompatibility issue.

Today, I encountered a strange issue in Windows 11 where the D drive was visible in the Disk Management tool but not in File Explorer. I searched online for many solutions, such as updating drivers in Device Manager, disabling and re-enabling the device, using diskpart to delete and recreate the partition, changing the volume label, changing the drive letter, etc., but none worked.

Problem Description

  • A new D drive, visible in diskmgmt.msc Disk Management, everything seemed normal. It could even be accessed in File Explorer (though the drive wasn’t displayed in the left sidebar).
  • The D drive could be used normally, such as via the command line.
  • Changing the drive letter to “E” or another letter made it visible in File Explorer, but switching it back to “D” caused it to disappear again.

Use az cli to query multiple fields of VM information. Here we need to use JMESPath language to implement it.

Typically, we will use az vm show to get the detailed VM information:

1
2
3
4
$ az vm show -g Linux -n alpha -d -o table
Name    ResourceGroup    PowerState    PublicIps     Fqdns    Location    Zones
------  ---------------  ------------  ------------  -------  ----------  -------
alpha   Linux            VM running    11.1.111.111           eastasia    1

In WinSCP, I found that when uploading file to the server, the file doesn’t have a temporary filename extension “.filepart”.

Enable temporary filename for all files in “Preferences -> Transfer -> Endurance” still does not work.

After upgrading Ubuntu 20.04 LTS to Ubuntu 22.04LTS, the server always freezes after ~10 minutes. All services are down, cannot ssh, connect to serial console but cannot input. However, this issue never happen before release upgrade.

Cannot believe that Word has such a bug: when tracking changes, wildcard replacement cannot correctly work.

I want to batch replace English parentheses with Chinese parentheses, so I use wildcard replacement:

1
2
3
Find What: \((*)\)
Options: Use Wildcards
Replace With: (\1)

For example, for “(abc)”, the expected result is “(abc)”, however, the result is “abc()”.

1
2
3
4
$ pip install torch==1.12.0
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement torch==1.12.0 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2)
ERROR: No matching distribution found for torch==1.12.0

The root cause is that python version is too low (3.6). We need to upgrade python to a new version.

Recently I upgrade NexT theme to v8.14.1. The related post plugin hexo-related-popular-posts had been replaced by hexo-related-posts, which generates related posts by tf-idf algorithm. However, the compute cost is a little bit heavy if you have many posts. A good trade-off is enable this feature only for production environment. The plugin hexo-related-posts already takes this into account and use enable_env_name to disable its execution. Unfortunately, the document has typo so I takes some time to fix it.

So how to set environment variable in Hexo?

Short Answer$ hexo <command> --<env_key> env_value

The following secitons will illustrate how to enable related post on production.

How to make your local repository always sync with GitHub repository? The answer is webhook.

When the repo received a push event, GitHub will send a POST request to the webhook URL with details of any subscribed events. What we need to do is to implement a webhook (on local side) which performs git pull to keep sync with remote.

When I install elasticdump, the following error appears:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
$ npm install elasticdump
...
npm WARN @1.0.0 No description
npm WARN @1.0.0 No repository field.
npm ERR! Linux 5.4.0-1091-azure
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "elasticdump"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /home/finisky/node_modules/.staging/@types/node-1f2b596d/package.json
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall open

npm ERR! ENOTDIR: not a directory, open '/home/finisky/node_modules/.staging/@types/node-1f2b596d/package.json'

git reset --hard not working: everytime you reset, the file is flipped between file.txt and File.txt, really weird…

It’s not a joke, just clone this repo on Windows and you can reproduce it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
D:\$ git clone https://github.com/finisky/git-case-demo.git
Cloning into 'git-case-demo'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 11 (delta 0), reused 8 (delta 0), pack-reused 0
Unpacking objects: 100% (11/11), 1.85 KiB | 126.00 KiB/s, done.
warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:

  'File.txt'
  'file.txt'

After clone the repo, you will find that the main branch is not clean. git reset --hard not working:

GitHub Pages cannot perform HTTP 301 redirects as you cannot modify the server config. However, 301 redirects is really crucial for SEO. In order to keep the site ranking, you need to 301 redirects the old GitHub Pages to your new site, and manually notify Google Search Console :

Do you lose credit for links when you redirect to new URLs?
No, 301 or 302 redirects do not cause a loss in PageRank

So how to migrate GitHub Pages to a new site without losing site ranking?

I bind a custom domain finisky.eu.org to the github pages finisky.github.io and then remove it. However, when I visit finisky.github.io, it always redirects to finisky.eu.org which is unavailable. I suspect the issue is caused by cache.

As the post number increases, Hexo generate posts slower and slower. Recently, it usually generates posts for several minutes and report the following error:

[ERROR][hexo-renderer-pandoc] pandoc exited with code null. at Object._prettifyError (/home/finisky/node_modules/nunjucks/src/lib.js:36:11)

I spent several hours to figure out the issue. Finally, I found the root cause is … VM memory is too small … :-(