Original link: https://xiaket.github.io/2023/pensieve-2307.html
listened to read
The books I’ve read this month are relatively mediocre. One is about Japanese style , which is probably a collection of a group of travel notes. It has no main line or theme, so it’s okay to flip through it casually. The second one is Chen Qiufan’s life algorithm , which is really not recommended. There is no big problem with the story itself, but the narrative technique reminds me of the model essays I read in high school before. They are big and empty, without the beauty of words, nor the pleasure of reading. The whole reading experience is roughly what this is and What is this again.
Added Emi Fujita’s HEADPHONE CONCERT 2022 to Apple Music, Leng た い 雨 is really nice.
Genshin
This month is mainly to brush up the exploration speed, and completed the exploration speed of Liyue/Abyssal Palace/Layer Abyss. The adventure level is almost 56. In addition, all the characters and NPCs in the seven holy summons have completed the serious wins and losses. It is expected that Xumi’s exploration speed and the full plot of the invitation mission can be fully completed before the start of 4.0. 3.8 did not draw cards (the small guarantee made a few more cards, and got a Yaoyao).
This time I would like to focus on the deck of Seven Saints Summoning. It uses Grass God + Thunder God + Yae God Son. This lineup Thor and God Son can both hang Thunder in the background, and Grass God quickly cuts and then stands on the field for output. This lineup is bad. The difference is that the single-player ability is slightly weaker, and there is no ability to spread. Because the grass god’s skill design is to penetrate the group and the background, if it is a single-player (such as the 30 health phaseless mine), this advantage cannot be used Just using this lineup, I cleared all the characters’ serious battles. The only obstacle is the serious battle of NPC Azalai. I tried this lineup a few times but failed, and then I replaced it with a debt handler/ The Shenzi/Sugar lineup has just passed.
cat with openssl
I recently completed a small hack in my work, I feel very happy, record it. There are only two binary files in a container image, one is the go binary built by myself, and the other is openssl. I want to save it when the container is running The /etc/hosts file is printed out. But there are no commands in this container. Later, after reading the openssl help for a long time, I solved it with the following method:
docker exec -t 34d14a31ebce openssl enc -base64 -in /etc/hosts
Citizenship written test
The direct reason for preparing to become an Australian citizen is the turbulent sea and the potential risk of war in the Taiwan Strait. I handed in the documents last month, and this month I received an email saying that I will have an interview. There is a large section of the documents that I need to bring, and I only briefly mentioned the written test. Next. My understanding is that this is to check the original documents in person. So I made an appointment, took annual leave, and went to the immigration office to find out that this is a written examination room. First, I confirmed with the staff that there is still a chance to make up the exam. Then I went to the examination room with confidence. There were 20 multiple choice questions, and the questions were very simple. I think even people who have never lived in Australia can pass this test. And I passed the test smoothly.
enum
Canva’s python codebase uses the enum module a lot for type checking purposes, and I have a slightly different take on that.
First of all, for Python code, I don’t think type checking can help us to much extent. Many times type checking just reduces the use of assertion, but for readability, assertion and type annotation are better or worse. Different people have different opinions. Moreover, for most business codes, the real check should be far stricter than the type check. It is debatable to divide the check of the input value into two parts: type check and assertion/validation. I think, Rather than investing development resources in type checking, it is better to invest in unit testing, which can better ensure the quality and readability of the code. It is unnecessary to use enum for type checking. Business code should be checked honestly at this time The value of the input, rather than satisfying an enum.
The cause of our glitch this time due to the enum is something like the following code:
class CapacityProvider(enum.Enum): COMPUTE_CORE = "compute-core" HIGH_FREQUENCY_CPU = "high-frequency-cpu" ... # Only available in the ml-canva ECS cluster ML_HIGH_MEMORY = "high-memory" ML_COMPUTE_CORE = "compute-core"
The uniqueness of enum is not checked here. It is taken for granted that when comparing the instances of CapacityProvider later, COMPUTE_CORE
and ML_COMPUTE_CORE
are compared, but in fact enum compares the corresponding values. If you insist on using enum, it is reasonable to avoid duplication in design value, and use the decorator @enum.verify(enum.UNIQUE)
to avoid introducing duplicate values when subsequent code changes:
@enum.verify(enum.UNIQUE) class CapacityProvider(enum.Enum): COMPUTE_CORE = "compute-core" HIGH_FREQUENCY_CPU = "high-frequency-cpu" ... # Only available in the ml-canva ECS cluster ML_HIGH_MEMORY = "high-memory" ML_COMPUTE_CORE = "compute-core"
At this point, Python will throw ValueError
. Of course, I think a more reasonable value is to process this CapacityProvider class into a dictionary:
VALID_CAPACITY_PROVIDERS = { "COMPUTE_CORE": "compute-core", "HIGH_FREQUENCY_CPU": "high-frequency-cpu", "ML_COMPUTE_CORE": "compute-core", "ML_HIGH_MEMORY": "high-memory", }
This way the maintenance cost is also low, and it is not prone to the errors discussed above.
This article is transferred from: https://xiaket.github.io/2023/pensieve-2307.html
This site is only for collection, and the copyright belongs to the original author.