使用Travis CI自动部署Github/Coding Pages博客

This blog has switched to Github Action for automated deployment.

Using Hexo to generate a static blog and then deploying it to Github/Coding Pages is currently how my blog is hosted. It’s quite enjoyable to use, but there are several issues:

  1. The environment configuration for Hexo is too cumbersome; it’s almost impossible to update the blog when changing to a new computer.
  2. Each time I modify an article, I have to regenerate everything.
  3. Additionally, the number of command executions for submitting the blog source files is too high (mainly the first step).

I wasted a lot of time submitting articles, so I optimized the process to almost achieve fully automated submissions.

Read more »

Boost源码分析笔记

Recently, I’ve been reading the Boost code and writing some analyses on the usage and implementation of useful modules in the Boost libraries, with updates to come periodically.

Read more »

配置SublimeText为Boost开发环境

Recently, I would like to study the Boost library. Most tutorials available online are based on using IDEs (such as VS/Code::Blocks), but I find it frustrating to have to open a bloated IDE just to write some test code. Today, I fiddled around and managed to compile/link code that uses the Boost library in SublimeText. I also organized the process/tools I worked with, so if others have similar needs and happen to see this article, they can save some time.

2016.11.01 Update
I used the latest version of MinGW64-GCC6.2 (x86_64-6.2.0-posix-seh-rt_v5-rev1) to compile LLVM/Clang 3.9, and then I used the compiled Clang to compile Boost1.62. The error messages that occurred when linking the Boost library in Clang are gone now.
Note: When compiling Boost with Clang, it is best to ensure that the current version of clang is compiled from the version of gcc in the current system; otherwise, when linking the static libraries produced by clang, strange issues might arise.

You can download my compiled versions here: MinGW62-GCC6.2(x86_64-6.2.0-posix-seh-rt_v5-rev1), LLVM/Clang3.9 compiled with GCC6.2 (above MinGW version), and Boost(MinGW64-GCC6.2/LLVM3.9/VC14-ALL). You can choose the version of the linked library (debug/release/static, etc.) as needed.
You can download the full compilation toolchain here.

Read more »

使用Docker部署shadowsocks服务

Arukas is a Japanese Docker service provider that is currently in the testing phase and can be used for free. We can easily use Docker to do some interesting (useful) things, such as deploying our own blog or shadowsocks server.

Read more »

在UE中使用Git进行版本控制

The Source Control provided in Unreal Editor allows you to implement basic functions such as version submission/version comparison/reverting changes through Git for blueprint projects, which is far less powerful than Git Bash, but the Diff between BluePrints is still very useful.

Read more »

Git快速上手指南

no hostkey alg

When connecting to the SSH Server, if this prompt appears, it is due to the SSH version being used; the remote SSHD version is too high while the local SSH version is too low.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
OpenSSH_5.1p1, OpenSSL 0.9.8i 15 Sep 2008
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.64.222.108 [10.64.222.108] port 2222.
debug1: Connection established.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file G:/UnrealProjects/Client/Build/NotForLicensees/SSHKeys/10.64.222.108/buildmachine/RemoteToolChainPrivate.key type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.0
debug1: match: OpenSSH_9.0 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: kex_parse_kexinit: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-sha1
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug2: mac_setup: found hmac-sha1
debug1: kex: client->server aes128-ctr hmac-sha1 none
no hostkey alg

UE updated the client’s SSH version in the 4.27 engine: Replace Windows ssh and rsync from DeltaCopy with new version from cw…

If the engine version is earlier than 4.27, upgrading to MacOS13+ will encounter this problem during remote builds. ## detected dubious ownership in repository at

1
2
3
4
5
6
7
8
9
$ git remote set-url origin https://git.woa.com/xxxx/UnrealEngine.git
fatal: detected dubious ownership in repository at 'D:/agent/workspace/MasterPackage/SOURCE/Engine'
'D:/agent/workspace/MasterPackage/SOURCE/Engine' is owned by:
'S-1-5-21-1333135361-625243220-14044502-1020188'
but the current user is:
'S-1-5-21-1333135361-625243220-14044502-1052754'
To add an exception for this directory, call:

git config --global --add safe.directory D:/agent/workspace/MasterPackage/SOURCE/Engine

If you switch to a new account, you will encounter the error message above for repositories pulled using the previous account.

The solution is to add all paths to the safe directory:

1
git config --global --add safe.directory "*"

Note: This command must be executed in the new account.

Warning: the ECDSA host key

When you encounter the warning while submitting to GitHub: Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '192.30.255.112', it means your SSH client has authenticated another host matching the target IP address.

To resolve this issue, please follow these steps:

1. Remove the old key from the known_hosts file:
Open the ~/.ssh/known_hosts file with a text editor (Windows users should find the file at %UserProfile%\.ssh\known_hosts) and locate the corresponding entry (referring to the IP address and hostname), then delete the corresponding line.

For example, find the following entry in the known_hosts file:

1
github.com,192.30.255.112 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hX ...

Delete that line.

2. Confirm GitHub’s SSH host fingerprint:
Confirm the currently valid transport layer security (TLS) public key fingerprint and SSH public key fingerprint from the GitHub official documentation.

3. Reconnect via SSH and add the new host key:
Execute the following command in the terminal or command prompt:

1
ssh -T -oStrictHostKeyChecking=accept-new git@github.com

This will automatically add the new github.com host key.

If prompted with “Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.”, it means the SSH authentication is successful and the issue has been resolved.

Now, you should be able to submit code to GitHub normally, and the warning message should no longer appear.

pull/push prompts for password every time

You can execute the following command:

1
git config --global credential.helper store

Get the latest commit information of the current repository

To get the latest commit ID of the current repository, you can use the following command:

1
2
$ git rev-parse HEAD
5c342b5145720c8cd4642e50774990db1c4294c3

If you want to see branch and commit information, you can use the command below:

1
2
$ git log -1 --pretty=oneline
5c342b5145720c8cd4642e50774990db1c4294c3 (HEAD -> master, origin/master, origin/HEAD) AUTO: Commit 58ca381 - (by UGit)

The -1 argument lists only the most recent commit.

If you add --decorate, you can see the branch information (this also depends on the git version; newer versions display branch information by default):

1
2
$ git log -1 --pretty=oneline --decorate
2d7b647a0f7330e3470ebe05fe039d9107624479 (HEAD -> dev, origin/dev) copy file

SSH login with key failed

If you receive the following error when connecting via SSH:

1
lipengzha@192.168.31.55: Permission denied (publickey,password,keyboard-interactive).

You can modify the server-side SSH configuration (/etc/ssh/sshd_config):

1
2
RSAAuthentication yes
PubkeyAuthentication yes

Then restart the SSHD service.

Check the last modifier of a specific line of code

To view the last commit person for code at lines n~m of a file:

1
git blame filename -L n,m

It will output:

1
2
e74836f557b (lipengzha 2024-01-10 09:43:02 +0800 541)                                   TArray<FString> FoundShaderLibs = UFlibShaderCodeLibraryHelper::FindCookedShaderLibByPlatform(PlatformName,SavePath,false);

1
git blame -L 541,541 --incremental --minimal Plugins\\HotPatcher\\HotPatcher\\Source\\HotPatcherCore\\Private\\CreatePatch\\PatcherProxy.cpp

Output:

1
2
3
4
5
6
7
8
9
10
11
12
e74836f557bc5ddf01de3f5f8d3b797107d9a767 541 541 1
author lipengzha
author-mail <lipengzha@gmail.com>
author-time 1704850982
author-tz +0800
committer lipengzha
committer-mail <lipengzha@gmail.com>
committer-time 1704850982
committer-tz +0800
summary [Build] Build Requirements Summary
previous 00ea9b4597dad3fe867b8af8747d12d10be105e2 Plugins/HotPatcher/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp
filename Plugins/HotPatcher/HotPatcher/Source/HotPatcherCore/Private/CreatePatch/PatcherProxy.cpp

Clear all history records

To clear all history records in a Git repository, keeping only the latest commit, you can follow these steps:

  1. Create a new branch:
    First, ensure you are in a clean working directory (no uncommitted changes), then create a new branch.

    1
    git checkout --orphan latest_branch

    This command creates a new branch without any history.

  2. Add all files:
    Add all files to the new branch.

    1
    git add -A
  3. Commit changes:
    Commit all files.

    1
    git commit -am "Initial commit with latest state"
  4. Delete the old branch:
    Switch back to the main branch and delete the old branch.

    1
    git branch -D main
  5. Rename the new branch to main:
    Rename the new branch to the main branch.

    1
    git branch -m main
  6. Force push to the remote repository:
    Finally, force push the changes to the remote repository. Note: This will overwrite all history in the remote repository.

    1
    git push -f origin main

This will clear all history records, keeping only the latest commit. This operation is irreversible; all historical records will be permanently deleted, so please ensure you really do not need these historical records before executing this operation.

Differences in line endings between Win and Linux

Windows uses carriage return and line feed (CRLF, \r\n), while Linux uses line feed (LF, \n). If you create or modify files on Windows and then view them on Linux, Git may recognize changes due to the differences in line endings.

The solution is to configure how Git handles line endings. Use the following commands to set Git to automatically convert line endings:

1
2
git config --global core.autocrlf true  # Windows
git config --global core.autocrlf input # Linux
  • Use a .gitattributes file to specify how line endings should be treated for specific files, for example:
1
* text=auto

Note: After I set this, I found that changes in files could not be displayed in real-time in the working directory. You can delete this configuration in C:\User\[USER_NAME]\.gitconfig.

Batch convert line endings

I wrote a Python script to implement this: git_eol_normalize.py

1
python3 git_eol_normalize.py --repo_Dir REPO_ROOT_DIR --eol LF

You can modify the list of text formats in g_text_exts as needed.

UPDATE

CheatSheet

Reference Articles

Explanation of Git Remote Operations
Creating and Merging Branches
Reversing Branch Deletion in Git
Reverting Changes with git checkout Command
Using git diff to Compare Two Branches

为C++的switch添加case的字符串匹配

The switch in the C++ standard cannot implement string case matching, but we often have this need, so let’s implement it.

Read more »

总结我的几个编码习惯

At the beginning when writing code, I always rolled up my sleeves and got to work as soon as I encountered a problem, essentially writing code while debugging and simultaneously designing the solution flow. However, this approach is simply too slow, often leading to writing and deleting code, effectively resulting in a poorly designed code structure requiring refactoring, which wastes a lot of time.

Read more »

读《C++语言的设计与演化》及一些疑问的解答

C++ Language Design and Evolution is a book written by C++ author Bjarne Stroustrup, discussing the thought process and trade-offs from the conception and design to the actual implementation of C++. It is arguably the only book on the market written from the perspective of a language designer on language design.

There are many issues where we should not only know How, but also understand Why, as this allows for a deeper comprehension of the subject. Fortunately, “C++ Language Design and Evolution” is precisely that kind of book. Recently, I realized many aspects of C++ that I only knew How but did not understand Why (too much was sacrificed for compatibility with C), and this article serves as a reading note and a record of Why, which I will gradually organize.

Read more »