Hogwarts

zxy's personal website

0%

在我一生的黄金时代。我有好多奢望。我想爱,想吃,还想在一瞬间变成天上半明半暗的云。后来我才知道,生活就是个缓慢受锤的过程,人一天天老下去,奢望也一天天消失,最后变得像挨了锤的牛一样。可是我过二十一岁生日时没有预见到这一点。我觉得自己会永远生猛下去,什么也锤不了我。

–《黄金时代》

Yesterday, I found an excellent terminal for teenagers called “fish”, however, it does not support several features of bash. Therefore, I decide to setup iterm2 + zsh for my convenience.

The original terminal on the mac is difficult to use.

  • No auto complete
  • No fancy theme support
  • No syntax highlighting

But the iterm2 + zsh can solve all the above problems.

This is my original terminal.
original terminal

And after replacing the terminal of macos with iterm2, and installing zsh according to the following blog.

https://sspai.com/post/63241

I change the theme and also the background color. Current item2 looks like this.

current terminal

The plugins that I selected:

1
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

With the help of autosuggestions, when you type in some characters in the terminal, zsh will automatically fill in the command.
You can simply press “=>” to ensure the current command. Different types will be highlighted with various color.

auto fill

Although I install iterm2 + zsh about one year ago, how stupid I am that I did not find out the proper way to use it!

Now, after experiencing it for a quite short period of time, I found out that every operation on the terminal is so smooth!

Ohhhhh!

Recently, I am preparing the docker image which is necessary for one course project. The OS version is Linux CentOS. The docker image should contain all necessary libraries that the project needs.

Step1. Install Python3.7

The following links tell users how to install python3 on linux

https://blog.csdn.net/qq_35304570/article/details/80302872

https://www.cnblogs.com/kimyeee/p/7250560.html

I use python 3.7.8 here

1
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
Encountered error
1
zipimport.ZipImportError: can’t decompress data

This error is caused by lack of necessary dependencies. It is important to install all dependencies in the first step.

https://blog.csdn.net/u014749862/article/details/54430022

https://www.cnblogs.com/jimc/p/10218062.html

Step2. Prepare docker images

https://msd.misuland.com/pd/3065794831805579512

Encountered error

When stating the docker using

1
2
3
sudo systemctl start docker

A dependency job for docker.service failed. See 'journalctl -xe' for details.

a brain f**king error popped out

I hav tried several methods that I can found, spend about 40 min, still in vain.

Reinstall my docker

Then I decide to reinstall it according to this link to see whether it works or not.

https://www.cnblogs.com/myzony/p/9071210.html

And then, emm…, another error occurred.

1
2
3
4
  File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax

This was caused by the python version. /usr/bin/yum is written in python2 snytax, whereas I have upgrade my python to python3 and setup the soft link “python => python3”. Fortunately, the following link solves my problem. And during the process of reinstalling docker, I use this trick to solve several similar errors.

https://stackoverflow.com/questions/11213520/yum-crashed-with-keyboard-interrupt-error

It still didn’t solve my problem after I completely uninstall and install docker for several times. I got the same error when I start the docker. So I decide to investigate on this more carefully, first thing is to check the exact error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@izwz9h66f1dwk5qi56kfs0z ~]# systemctl status docker.service -l
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com

Feb 28 12:36:09 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine.
Feb 28 12:36:09 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'.
Feb 28 13:26:58 izwz9h66f1dwk5qi56kfs0z systemd[1]: [/usr/lib/systemd/system/docker.service:37] Unknown lvalue 'TasksMax' in section 'Service'
Feb 28 13:26:58 izwz9h66f1dwk5qi56kfs0z systemd[1]: [/usr/lib/systemd/system/docker.service:37] Unknown lvalue 'TasksMax' in section 'Service'
Feb 28 13:28:12 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine.
Feb 28 13:28:12 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'.
Feb 28 13:28:54 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine.
Feb 28 13:28:54 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'.
Feb 28 13:30:44 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine.
Feb 28 13:30:44 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'.

I start the docker again, and use “journalctl -xe” to see detailed error information.

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
44
45
46
47
48
49
50
51
[root@izwz9h66f1dwk5qi56kfs0z ~]# systemctl start docker
A dependency job for docker.service failed. See 'journalctl -xe' for details.
[root@izwz9h66f1dwk5qi56kfs0z ~]# journalctl -xe
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service: main process exited, code=exited, status=203/EXEC
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Failed to start containerd container runtime.
-- Subject: Unit containerd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit containerd.service has failed.
--
-- The result is failed.
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is dependency.
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'.
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Unit containerd.service entered failed state.
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service failed.
Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z polkitd[398]: Unregistered Authentication Agent for unix-process:8386:350732 (system bus name :1.505, object
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service holdoff time over, scheduling restart.
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Starting containerd container runtime...
-- Subject: Unit containerd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit containerd.service has begun starting up.
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[8413]: Failed at step EXEC spawning /usr/bin/containerd: No such file or directory
-- Subject: Process /usr/bin/containerd could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/bin/containerd could not be executed and failed.
--
-- The error number returned by this process is 2.
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service: main process exited, code=exited, status=203/EXEC
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Failed to start containerd container runtime.
-- Subject: Unit containerd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit containerd.service has failed.
--
-- The result is failed.
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Unit containerd.service entered failed state.
Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service failed.

The main error is the following:

  • containerd.service: main process exited, code=exited, status=203/EXEC

  • Failed at step EXEC spawning /usr/bin/containerd: No such file or directory

My understanding is that when the system want to boot docker, it failed to start containerd container at runtime. The above error is the reason. Then the system try to “Starting containerd container runtime…” again, this time the following errors occurred. According to what I have found, it seems that this is not a bug. This problem is due to the incorrect environment or path settings of the user.

Anyway, after trying for 5 hours, I give up fixing this bug. This is quite annoying to work all day on this problem with no progress. I reset all the server and start everything from scratch. If time allowed, in the future I will try to solve this problem. But now I have tons of things to do…

Therefore, the first step should be Step0. Install Docker and then continue step1,2

Now, after the stupid “all start from scratch”. I successfully start my docker. And I am also aware of the lack of knowledge of linux. Previously I add one new user named zxy in centos. However, I need to switch back and forth between root and zxy, which brings me lots of trouble since the authority of different usr differs. Every time when I want to modify some system related files, I have to use sudo and input my password. So this time, I will only focus on root user since there will be nobody except me using this server.

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
[root@izwz9h66f1dwk5qi56kfs0z ~]# systemctl start docker
[root@izwz9h66f1dwk5qi56kfs0z ~]# docker version
Client: Docker Engine - Community
Version: 20.10.4
API version: 1.41
Go version: go1.13.15
Git commit: d3cb89e
Built: Thu Feb 25 07:06:20 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.4
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 363e9a8
Built: Thu Feb 25 07:04:45 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@izwz9h66f1dwk5qi56kfs0z ~]#

Build the docker file using the following commands.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# base image
FROM python:3.7

# add the ./recommender into container folder /recommender
# later we can go into the container to see this
ADD ./recommender /recommender
ADD ./requirements.txt /tmp/requirements.txt

# install dependencies
RUN pip install -r /tmp/requirements.txt

# set the working directory to be /recommender
WORKDIR /recommender

# expose the port
EXPOSE 4001

# when starting the container
# use python3 to execute the py shell script of the specified path
CMD ["python3", "/recommender/main.py"]
CMD echo "---end---"
CMD /bin/bash

This may stuck in pip install, so we can simply ignore the dependency installation. We can first create a simple image, create a container using that image, enter it and install (mirror accelerated), then build a new image based on this container.

Up till now, the python environment and docker image construction is done.

Some other problems

https://blog.csdn.net/eleanoryss/article/details/70207767

https://www.cnblogs.com/hongzg1982/articles/2101792.html

Update Hexo and Next Theme

I haven’t updated the blog for quite a long time. Yesterday, I decide to write down something to record my ideas and thoughts. Everything went smoothly when I wrote and generated static website on the local server. However, when I was deploying the blog to github repository, something wired happened. I searched on the internet and did not find the desired solution immediately. I guessed this must relates to my outdated hexo+next version. Therefore, I spent several hours yesterday evening to update my hexo version (tougher than I thought). And today, I discover several wonderful blogs about how to update hexo along with “next theme”, it works! All bugs are gone, currently all dependencies and modules are up-to-date. In case I will update my blog system in the future, just record those links that help me a lot (save me tons of time doing things in vain, anyway, I am a pure frontend freshman).

Here are the links:
https://laytonsun.com/learning/2020-04/upgrade-hexo-and-next.html

https://www.cylong.com/blog/2020/08/10/update-hexo-next/

https://www.jianshu.com/p/802182c01b59

Just as the title goes, sth to say to myself

Start

It has been a long time since my last post.How time flies, now I am a third year student, struggling for the undetermined future.Just an hour ago, I looked the blogs of two classmates, who are for sure excellent in our college.They have clear goals, their favorite fields of CS, either research or frontend design. I used to consider myself as a “thoughtful” person majored in computer science.However, after three years college study, something has escaped from my life without my attention.

Frankly speaking, I was touched and cannot help thinking about my own life,
what I have done? what should I do? what will I do?

Continue

With excitement and passion, when I first created this blog system in 2019, I was quite confident about the future. I started to learn every new things that could encounter in courses. Machine learning, jupyter notebook, tensorflow, pytorch, latex, regular expression …

Although recalling what I have learnt by myself, they are just “nothing” (yes, maybe just nothing) for a programmer, the process is of great satisfaction to me. Nothing seems difficult once I decided to learn.

However

Later on, I realized the gap between me and those excellent students, which cannot be filled simply by things called “diligence”. What I have known is far less than what I still need to mater.

During the past three years, I have devoted myself to study and research. However, not as expected in most “dogmatic” story, I didn’t get outstanding scores.

Due to myself or the course design of our school, up till now, I still feel that I am not a “true programmer”.
I am eager for experience, no matter “coding experience, learning experience, working experience, project experience”. I think I am lack of enough practice and I am indeed a lazy guy, which makes me painful.

The epidemic exposes my weakness and mess up my plans. Year two is quite a hard academic year for me. Witnessing people around working hard, I seems to be trapped in a pitfall, keep static and cannot step forward. I did try my best to develop self-discipline and spare no effort to learning. Whereas, due to my personal reason, I found nothing truly interesting for me.
Coding, machine learning, algorithms, what I am happy about is not these stuffs (though they are good to me and at least I do non hate them).

Sometimes, I reckon myself as a boring person, who have no big dreams, no true interests, no one to share my ideas. I keep a regular life routine unchanged for almost two years. Get up, go to lectures, eat lunch, go to lectures, study in the library until late, take a shower, sleep. Go to the gym every other day to keep myself healthy. I just write down these things for myself. Even from my perspective, this kind of life is boring. I cannot truly love sth consistently, even though they can attract my attention for a moment. Maybe that’s the reason…

Therefore, no wonder I am perplexed about my future.
Setting up clear goals is always hard for me, though I am not saying to give up.

And

Anyway, this college is not an ideal place for me, for I am kinda timid. It belongs to those who are brave and clear about their goals. Not to blame CS major or our school, I have to say CS major is still an optimal choice in contemporary society and I do not regret choosing this. Our school is good, with good facilities, some good professors, some good students, anyway, maybe not that suitable for person of my type.

End

When writing this blog, I still have three homeworks, research project, group project to finish. And I am working hard to prepare CV and pursue an intern.

Despite the heavy burden, I still want to write down sth, which is important for the “real me”.

Emotions should have one place to go, this blog could be a wonderful place. Though complaining about so much things, I think I still have the courage and perseverance to continue working hard.

Never give up yourself. Keep going is the best choice for me.

Markdown Cheat Sheet

Thanks for visiting The Markdown Guide!

This Markdown cheat sheet provides a quick overview of all the Markdown syntax elements. It can’t cover every edge case, so if you need more information about any of these elements, refer to the reference guides for basic syntax and extended syntax.

Basic Syntax

These are the elements outlined in John Gruber’s original design document. All Markdown applications support these elements.

Heading

H1

H2

H3

Bold

bold text

Italic

italicized text

Blockquote

blockquote

Ordered List

  1. First item
  2. Second item
  3. Third item

Unordered List

  • First item
  • Second item
  • Third item

Code

code

Horizontal Rule


title

Image

alt text

Extended Syntax

These elements extend the basic syntax by adding additional features. Not all Markdown applications support these elements.

Table

Syntax Description
Header Title
Paragraph Text

Fenced Code Block

1
2
3
4
5
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}

Footnote

Here’s a sentence with a footnote. [^1]

[^1]: This is the footnote.

Heading ID

My Great Heading {#custom-id}

Definition List

term
definition

Strikethrough

The world is flat.

Task List

  • Write the press release
  • Update the website
  • Contact the media

Websites collection of C++ tricks that are easy to forget or seems confusing at the first sight:

Function Pointer (return type (*func ptr name)(input type))

https://www.geeksforgeeks.org/function-pointer-in-c/

Virtual Functions and Mechanism, Runtime Polymorphism

https://www.geeksforgeeks.org/virtual-functions-and-runtime-polymorphism-in-c-set-1-introduction/

https://www.geeksforgeeks.org/polymorphism-in-c/

Function Object/ Functor

https://www.geeksforgeeks.org/functors-in-cpp/

Type Inference (auto, decltype)

https://www.geeksforgeeks.org/type-inference-in-c-auto-and-decltype/

Lambda Expression

https://www.geeksforgeeks.org/lambda-expression-in-c/

Happy New Year to Myself and Everyone

Year 2020 is quite unusual, it starts with loads of messy stuffs and annoying things. However, I still want to persuade myself that everything will be fine. I firmly believe that this coming new year can still be wonderful. I wish that I can make more friends and achieve goals. Hope that everything will be nice!!! (smile~)