Log archives, mainly environment setup and issue resolving.
Zsh History File Encoding Issue with UTF-8 Characters
Issue Description
When opening .zsh_history file via vim, some UTF-8 encoded characters (e.g. Japanese, Chinese characters) are not displayed correctly, and vim shows the fileencoding as latin1 instead of utf-8.
-
For example, the following shows how Japanese/Chinese characters are displayed incorrectly in vim:
2466 : 1762759121:0;locale 2467 : 1762759501:0;echo "ä½<83><80>好" 2468 : 1762759519:0;echo "ã<81><83>³ã<82><83>³ã<81>«ã<81><83><81>ã<81>¯" -
The actual content of the
.zsh_historyfile is as follows:
Solution to Restore Recently Deleted Albums from iCloud Photos Library
Issue Description
During the Beta testing of the new iPadOS 26, I accidentally deleted all albums in my iCloud Photos Library on my iPad, which then synced the deletion to my other Apple devices. This resulted in the loss of all my photo albums, although the photos themselves remained intact in the “All Photos” section.
Solutions
1. Find the Deleted Albums in the Photos.sqlite Database
Find the Photos.sqlite database file in the Photos Library package. The path to the database file is as follows:
Solution to the Failure to Pass Cookies into yt-dlp When Using mpv
Issue Description
When using mpv to play videos from Bilibili, users may encounter issues where mpv fails to pass cookies to yt-dlp correctly, regardless of whether the cookies are already in Netscape format, leading to error messages like the following:
→ mpv --cookies-file="~/bilibili_cookies.txt" --ytdl-raw-options=format=100028+30280 https://www.bilibili.com/video/BV1HMH7z4ES4
[ytdl_hook] ERROR: [BiliBili] BV1HMH7z4ES4: Requested format is not available. Use --list-formats for a list of available formats
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.
The format 100028+30280 is a valid format on Bilibili, but only extractable when the user is logged in, which requires the correct cookies to be passed to yt-dlp, which is the default backend for mpv to handle online video playback.
Deployment Templates of AWS Services via AWS CDK (in TypeScript)
WAFv2
Considering the comparison table shown below (from https://blog.dream11engineering.com/enhancing-security-and-trust-with-aws-wafv2-8b050b1cba37)
The WCU requirements for a rule group are determined by the rules that you define inside the rule group. The maximum capacity for a rule group is 1,500 WCUs. The basic price for a web ACL includes up to 1,500 WCUs The maximum capacity for a web ACL is 5,000 WCUs.
and AWS doc shown above (from https://docs.aws.amazon.com/waf/latest/developerguide/aws-waf-capacity-units.html) use WAFv2 instead of WAF Classic(v1)
C++ Implementation of LRU & LFU Cache
LRU (Least Recently Used) Cache
Referring to LeetCode Q146 https://leetcode.com/problems/lru-cache/
Description
LRUCache(int capacity)Initialize the LRU cache with positive size capacity.int get(int key)Return the value of the key if the key exists, otherwise return -1.void put(int key, int value)Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used- The functions
getandputmust each run inO(1)average time complexity.
Data Structure Used
To satisfy the O(1) average time complexity for get and put,
Visual Studio Code C/C++ Extension Setup on M1 Mac
Prerequisites
-
Visual Studio Code extension
ms-vscode.cpptools -
Xcode Command-line Tools / Xcode IDE
- To install Xcode Command-line Tools:
xcode-select --install - To install Xcode IDE:
mas install Xcode
- To install Xcode Command-line Tools:
Test Environment
-
Visual Studio Code 1.54.3 (Universal)
- Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
- Extension: ms-vscode.cpptools v1.2.2
-
macOS 11.2.3
$ uname -v Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 -
Xcode 12.4 (12D4e)
$ clang --version Apple clang version 12.0.0 (clang-1200.0.32.29) Target: arm64-apple-darwin20.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Setup
Modify the settings.json in Visual Studio Code as shown below