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 to the bottom 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.

Sure enough, I received the “Quarantine Gift Package”.

image

Recent Meals#

Honestly, I never thought I would have time to cook during weekdays; 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.

First, let me share the benefits of cooking for myself that I’ve realized:

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

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

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

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

That being said, we can also 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 dishes doesn’t take much time.

Here, I’ll compare the time consumption data between cooking myself and ordering takeout:

Cooking MyselfOrdering TakeoutWinner (Shorter Time)
1. SelectionSelecting two meat and two vegetables on MeituanOrdering food on MeituanBasically even
2. Picking UpCan pick up everything for the day at onceNeed to pick up twice for two mealsCooking myself
3. PreparationCooking rice + stir-fryingNo preparation neededOrdering takeout
4. CleanupWashing dishesAlmost no needOrdering takeout

It seems that ordering takeout is better, but actually, the time for 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 shopping, the preparation process can be controlled to 10-20 minutes.

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

    • Be sure to choose ingredients with a few days of shelf life rather than a few months, as these are generally fresh.

Now let’s look at the new 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 found that the motion of washing dishes, with one hand in front and one behind, is similar to the pushing (chest workout) and pulling (back workout) movements in fitness, so washing dishes can also make up for some of the exercise I should have done (indeed, based on observation, my chest and back muscles show no significant signs of weakening 🐶).

image

Besides time consumption, I also mentioned that it requires more energy, which is unavoidable, especially when first learning to cook.

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

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 talk about a few scenes I really like~

1) Studying Abroad

One day, my cousin Wen Yunchang came to Mao Zedong’s house and told him that 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 store 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 quatrain poem: “A child aspires to leave his hometown, swearing not to return until he succeeds. Why must one be buried in the land of one’s birth? Life has no shortage of green mountains.”

At 17, although Mao Zedong was 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 selling some cultural books as well as some bestsellers and popular books to increase income.

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 identified with their ideas. If they sold bestsellers and popular books, it would be difficult to distinguish the readers who came in.

This point inspires 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 big cities, so they issued orders to attack big cities multiple times.

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 also labeled as a “runawayism” rightist and was continuously marginalized by the Central Committee.

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

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

4) The Capture of Luding Bridge

image

During my trip to Western Sichuan after graduation, I crossed Luding Bridge, and just hearing 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 on the ropes, another team laying down the planks, and another team passing the planks while the others crossed the river.

It is said that when Chiang Kai-shek in Nanjing asked his subordinates why they didn’t just blow up the bridge, his subordinate 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 later 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 unequal contests, they always manage to adapt and survive, which is quite thrilling.


Additionally, regarding the video resources for this drama, I prefer watching it on Xigua Video because the comments are super lively, creating a great atmosphere.

  • Occasionally, someone introduces the achievements of the character appearing on screen. For example, when I saw the Kuomintang's Xue Yue, I certainly regarded him as our enemy, but when the comments mentioned he was a famous general in the War of Resistance, I couldn’t help but feel a sense of respect 🫡.

  • Others also express different opinions on certain events or possibly overlooked backgrounds...

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


Alright, the earlier part discussed some insights from life, 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 definitely many more capabilities that can be extended as 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 situations where every time a product reaches a new stage, you need to create new branches 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 as a programmer, I cannot allow to happen.


So, I used 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 display 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 "🌿Repositories to operate on:\n${remote_hosts}\n"
    
    # ️Iterate over 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; I hope 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.