Bo2SS

Bo2SS

#2 | New Discoveries in Home Quarantine (Efficient Cooking, Achieving Automated Multi-Warehouse Branch Management...)

Hey everyone, this is Bo2SS's new series, mainly sharing some thoughts from daily life and technology. Compared to previous technical long articles, the overall style of this series is lighter. (Friendly reminder: there is an example of multi-repository branch management script at the end, scroll down to see if you need it!)

“Those who should go home, go home, don’t come out. Those who should go home, go home, don’t come out…”

On Tuesday morning at 7:30, I was woken up by the incessant sound of loudspeakers, and my first reaction was to check the community group chat.

That's right, we received the “Quarantine Gift Package”.

image

Recent Meals#

Honestly, I never thought I would have time to cook during workdays; I usually only cook on weekends to treat myself.

image

image

image

image

image

image

image

But on the first day of quarantine, after hearing my family say in a video call that “Takeout is not hygienic,” combined with the fact that the takeout I ordered that day was indeed terrible, I decided to start cooking myself from the next day.

Let me first talk about the benefits of cooking for myself that I’ve experienced:

  • Delicious (plenty), has a sense of ritual (one source of happiness), makes my family feel like I’m doing well (which is true)…

  • More importantly, I unexpectedly discovered that during this process, I could think about problems on a higher level without getting bogged down in details.

Cooking simple home meals doesn’t require too much brainpower, so my mind still has some room for thought.

Moreover, compared to sitting in front of a computer, cooking reduces the interference of various useless information, allowing me to concentrate more on the key issues.

That said, we can easily gain inspiration while showering or using the restroom; the reasoning is similar.

image

As the saying goes, “You gain some, you lose some.” Since I’ve gained so many benefits, we must also lose something, right? Yes, we need to spend more time and energy.

But actually, making the above delicious food doesn’t take much time.

Here, I’ll compare the time consumption data of cooking for myself versus ordering takeout:

Cooking for MyselfOrdering TakeoutWinner (Shorter Time)
1. SelectionSelecting two meats and two vegetables on MeituanOrdering on MeituanBasically the same
2. Picking UpCan pick up everything for the day at onceNeed to pick up twice for two mealsCooking for myself
3. PreparationCooking rice + stir-fryingNo preparation neededTakeout
4. Cleaning UpWashing dishesAlmost no needTakeout

It seems that ordering takeout is better, but actually, the time spent on cooking rice + stir-frying can be considered “negligible”:

  • Cooking rice: With the help of Stretchly reminder tool, my usual work rhythm is to take a 20-second break every half hour and a 4-minute break every one and a half hours, so I can cook rice during the 4-minute break.

  • Stir-frying: Choosing quick dishes from Meituan’s grocery section, the cooking process can be controlled to 10-20 minutes.

    • Quick dishes come with pre-washed and pre-cut ingredients (if you’re worried, you can wash them again), along with oil and seasonings (if you’re worried, you can use your own oil and seasonings; generally, soy sauce and salt are enough), plus a step-by-step guide for stir-frying, so you just need to follow the instructions like building with Lego blocks.

    • Make sure to choose ingredients with a few days of shelf life rather than a few months, so they are generally fresh.

Now let’s look at the newly added task of washing dishes:

  • I can choose to do it after meals or during the 4-minute break, making good use of fragmented time.

  • Sometimes if there’s too much grease, I can rinse the dishes first, soak them, and then wash.

  • Additionally, I’ve found that the motion of washing dishes, with one hand in front and the other behind, is similar to the pushing (chest workout) and pulling (back workout) actions in fitness, so washing dishes can also compensate for some of the exercise I should have done (indeed, based on observation, my chest and back muscles have not shown significant signs of weakening 🐶).

image

Besides time consumption, I also mentioned that more energy is required, which is unavoidable, especially when first learning to stir-fry.

But as the saying goes, “You lose some, you gain some.” Spending time and energy can always bring other values in return.

Recent Entertainment#

Eating the dishes I made while watching the history of the Red Army is quite enjoyable.

image

Recently, I’ve been watching the film “Mao Zedong” directed by Gao Xixi, and I particularly like the spirited performance of the young Mao Zedong actor, Hou Jingjian.

image

Let me share a few scenes I really like~

1) Studying Abroad

One day, my cousin Wen Yunchang came to Mao Zedong’s house and told him he could go to the Xiangxiang County Higher Primary School to study, where he could learn a lot of new knowledge.

At that time, Mao Zedong was an apprentice at a grain shop arranged by his father, but he wasn’t interested in doing business, so he sought his father’s permission.

His father actually just wanted Mao Zedong to earn some money to support the family, as there were two younger brothers and a sister at home, and he hadn’t considered spending money to send him to school.

However, after Mao Zedong’s strong persuasion, his father reluctantly agreed.

So Mao Zedong left his hometown and wrote a seven-character poem for his father: “The child aspires to leave the countryside, swearing not to return until he becomes famous. Why must I be buried in my hometown? There are green mountains everywhere in life.”

At 17, although Mao Zedong was only in the first grade of primary school, he learned very quickly by asking questions whenever he didn’t understand.

2) Opening a Bookstore

At that time, Mao Zedong and his group opened a bookstore (Cultural Book Society) to spread new ideas.

However, the startup capital for the bookstore was limited, and the finance department suggested that in addition to selling cultural books, they could also sell some bestsellers and popular books to increase revenue.

This suggestion was rejected by Mao Zedong, who believed that the purpose of opening a bookstore was to gather like-minded people and bring together those who agreed with their ideas. Selling bestsellers and popular books would make it difficult to distinguish the readers who came in.

This point has inspired me in writing my public account; I don’t want to write eye-catching content, but rather hope to slowly share my thoughts here and connect with like-minded people.

Additionally, Mao Zedong would definitely be a “traffic celebrity” today; when this bookstore opened, he even invited the governor of Hunan Province to cut the ribbon.

3) Mao Zedong Being Marginalized

Mao Zedong’s strategy of “surrounding the cities from the countryside” and his sixteen-character guideline for guerrilla warfare (“When the enemy advances, we retreat; when the enemy camps, we disturb; when the enemy is tired, we strike; when the enemy retreats, we pursue”) repeatedly helped the Red Army win many victories.

However, the Central Committee in Shanghai was eager for achievements and believed that the Red Army had the strength to attack large cities, so they issued orders multiple times to attack large cities.

The Central Committee’s orders were hard to disobey, but Mao Zedong knew that the Red Army’s current strength was insufficient, so many times he just went through the motions.

However, Mao Zedong was labeled as a “runawayist” and a rightist and was continuously marginalized by the Central Committee.

Until the fifth counter-encirclement, the Central Committee sent Bo Gu (relatively young and inexperienced in actual combat) to serve as General Secretary, and Li De (a German, who used a Chinese name for confidentiality) as a military advisor. Their “fortress-to-fortress” hard-hitting strategy led to heavy losses for the Red Army.

After this, Mao Zedong gradually returned to his rightful position.

4) The Capture of Luding Bridge

image

During my trip to Western Sichuan after graduation, I crossed the Luding Bridge, and the sound of the water flowing beneath the Dadu River sent chills down my spine.

At that time, the enemy had removed the planks in advance to prevent the Red Army from crossing the river, leaving only the iron chains.

To cross the river, the Red Army charged under the enemy's machine guns, with one team attracting fire while stepping on the ropes, another team laying down planks, and a third team passing the planks, while the rear team crossed the river.

It is said that Chiang Kai-shek, who was in Nanjing at the time, asked his subordinates why they didn’t just blow up the bridge. His subordinates replied that they never thought the Red Army would lay planks while advancing.

Chiang Kai-shek sighed and said, “When fighting against Mao Zedong, one cannot predict their actions with conventional thinking.” However, he still did not anticipate that the Red Army would cross the snow-capped mountains, allowing them to unite.

Watching Mao Zedong in battle always reminds me of Zhuge Liang (I previously wrote an article discussing the Three Kingdoms: History | If Characters from "Romance of the Three Kingdoms" Were to Apply for Internet Jobs, Who Would You Choose?), in seemingly disparate contests, they always manage to adapt to circumstances and find a way out, which is quite thrilling.


Additionally, regarding the video resources of this drama, I prefer watching it on Xigua Video because the comments there are abundant, creating a lively atmosphere.

  • Occasionally, someone introduces the achievements of the characters appearing. For example, when I see Xue Yue from the Kuomintang, I certainly regard him as our enemy, but when the comments mention he is a famous general in the Anti-Japanese War, I can’t help but feel a sense of respect 🫡.

  • Some people also express different opinions on certain matters or provide potentially overlooked backgrounds...

On the other hand, Bilibili is relatively quiet, possibly because it was uploaded later.


Alright, the previous part discussed some insights from life, and now let’s talk about some technical thoughts.

Recent Thoughts: Multi-Repository Branch Management Automation V1.0#

Let’s call it V1.0 for now, because besides the current capability of automatically creating branches, there are certainly many other capabilities that can be extended and iterated when needed.

Final result: Automatically create branches for multiple repositories🌲.

  1. Before automation: Go to each repository separately, fill in the relevant parameters, and click the button.

  2. After automation: Go to each repository separately, fill in the relevant parameters, and click the button.


I wonder if you’ve encountered a situation where every time a product reaches a new stage, a new branch needs to be created in the code, such as for testing.

If it’s just creating a branch for one repository, it’s manageable, but our group has as many as five or six related repositories, so we need to perform this simple and tedious repetitive operation (creating branches) for each repository, which is unacceptable for me as a programmer.


So, I utilized the continuous integration tool Jenkins (for the convenience of others) and Shell scripting language to automate the above process.

Now I only need 2 steps to easily complete the above process:

1) Enter the Jenkins project, fill in 2 build parameters: current version, previous version.

image

⚠️:

  1. Our branch names are based on version names;

  2. We will create the current version’s test branch based on the previous version’s release branch.

2) Click the Build button and wait for the result.

Here, I tested it with my two GitHub repositories, and the relevant logs are as follows:

image

✌️: The logs clearly show the process and results of the operation.

⚠️: The repositories we need to operate on are configured in Configure > Source Code Management > Git > Repositories. If you need to add a new repository, just add it in the configuration without modifying the script.


The Shell script for V1.0 is as follows (with specific explanations inside):

# Main process
main() {
  #1
    set +ex  # e: do not exit on error; x: do not display executed commands
    declare -a success_list  # Record successful repositories
    declare -a failure_list  # Record failed repositories
    echo "========================⚙️Preparation Completed⚙️========================\n"
    
    #2
    echo "========================🆒Official Start🆒========================"
    remote_hosts=`git remote`
    echo "🌿The repositories to operate on are:\n${remote_hosts}\n"
    
    # ️Iterate over the managed remote repositories, added in Source Code Management > Git > Repositories
    # ⚠️You can configure repository aliases through Advanced > Name for easier log checking
    for remote_host in ${remote_hosts}; do
        CreateAndPushTestBranch ${remote_host}
    done
    
    #3
    echo "========================🌲Output Results🌲========================"
    echo "✅Successful: ${success_list[*]}"
    echo "❌Failed: ${failure_list[*]}"
    echo "\n\n"
}

# Create and push test branch
# Parameter 1: Remote repository alias
CreateAndPushTestBranch() {
    echo "========================💼Starting operation on repository: $1💼========================"
    target_host=$1  # Record repository alias
    
    echo "1. Create branch git checkout -b"
    # current_version, last_version are build parameters defined in General
    git checkout -b test/${current_version} ${target_host}/release/${last_version}
  
    echo "2. Push branch git push"
    git push ${target_host} HEAD
    if [ $? -eq 0 ]; then
        success_list+="${target_host} "
        result="Success✅"
    else
        failure_list+="${target_host} "
        result="Failed❌"
    fi

    echo "3. Clean up branch git branch -D"
    git -c advice.detachedHead=false checkout ${target_host}/release/${last_version} # -c advice.detachedHead=false temporarily suppresses detachedHead warning
    git branch -D test/${current_version}
    
    echo "\n👉Created and pushed test/${current_version} branch in ${target_host} repository: ${result}\n"
}

main; exit

Conclusion#

Keep thinking and boldly practice, hoping this article is helpful to you~

This is Bo2SS; if you have any suggestions for this series, feel free to leave a message, and see you next time~

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.