Read in Q2 2023

I decided to share some info about books I read – I will publish such a post every quarter and list all books with some summary info. It will include not only books, but also audiobooks, but always with clear info, what medium I used.

Exercised: Why Something We Never Evolved to Do Is Healthy and Rewarding

By Daniel Lieberman

I listened to it as audiobook but probably will read also an ebook – Daniel Lieberman shows us, that we as humans were not prepared to exercise… But we need to do them because we changed the world, and our bodies can handle a lot of effort. There are a lot of debunking myths and good advices. Thanks for Artem for recommending me this book!

The Making of a Manager: What to Do When Everyone Looks to You

By Julie Zhuo

Julie was a manager in Facebook and now is co-founder at Sundial. She described her experiences and tips on how to be a better manager: how to build effective teams, hire people, help them in growth and how to handle feedback. Tons of guides

The Chaos Machine: The Inside Story of How Social Media Rewired Our Minds and Our World

By Max Fisher

I think people who read this blog know that social media can negatively impact society. I knew that before, but reading this book is like reading a good thriller: more and more twists, confusion and chaos. But… It’s our reality. I did not know about some issues on Reddit or YouTube, I did not social media are even guilty of genocide

We Have Been Harmonized: Life in China’s Surveillance State

By Kai Strittmatter

I’ve listened this audiobook about changes in China, about how their government is using modern technologies or social apps to build controlled society. For me it was shocking because I see similar steps also in EU

Sztuka Życia Według Stoików

By Piotr Stankiewicz

Polish book from created by the philosopher and stoic about stoicism. Complex, with a lot of quotes and interpretations. I think it’s better even than many Ryan Holiday books, but unfortunately is not available in English and in effect, it is not as popular

Mengele. Anioł śmierci z Auschwitz

By Max Czornyj

Polish book about Josef Mengele, German SS officer known as “Angel of Death” – he was a doctor in Auschwitz concentration camp and made inhuman experiments. Descriptions are shocking and it is not a book for people with of weak nerve

Recovering files on Google Cloud Storage

Google Cloud is a complex and very powerful platform. One of its components is Cloud Storage – based on buckets, a place where we can store files. It supports a lot of options like files versioning, saving metadata, generating signed URLs for downloading/pushing files etc. One of the most problematic options is data recovery: if you check Google Console, you will not see any option to do that. Does it mean we cannot recover deleted files? Fortunately, it is possible, but a bit tricky. Trick post is to explain how to do that.

Of course, this will only be possible if a certain condition is met: our bucket must have enabled versioning. Without that, Google will not provide the ability to recover deleted files, so remember to enable this option if bucket is not used only for temporary data – in all other scenarios, it should use this option.

Versioning means we can have multiple versions of one file and switch between them at any time – it applies also to deleted files. Each file uploaded to Google Storage has generation number which is used to determine the active (current) version. If we delete the file with enabled versioning, there will not be an active version, but the file will be still available on bucket. The tricky part there: if you will try to find it, you will not have any results – on both bucket view on cloud interface and also on standard gsutil command. At the beginning, we need to find our deleted files

Checking deleted files

This operation is simple, we can do that by using command:

gsutil ls -a gs://{BUCKET_NAME}

Looks like normal ls, but -a argument will include also deleted files. Of course, command can list also only all files from specific directory:

gsutil ls -a gs://{BUCKET_NAME}/{DIRECTORY_PATH}

Conclusion: you can list all active files, or all files (active + inactive), but there is no possibility to list only inactive files. It generates some implications if we need to do something bigger, but right now, just try to recover single file.

Recovery procedure

Right now, when we have timestamps, we can “recover” files. It is quite simple because instead of using any specific command, we should use only cp – so command required to copy items. In this scenario, we need to pass not only path, but also timestamp of version we want to recover. For example:

gsutil cp gs://{BUCKET_NAME}/{PATH_TO_OBJECT}#{TIMESTAMP} gs://{BUCKET_NAME}/{PATH_TO_OBJECT}

And some real scenario:

gustil cp gs://my-bucket/myfile.jpg#1689145344557329 gs://my-bucket/myfile.jpg

Mass Recovery

As I mentioned, mass recovery is trickier because we do not have the ability to list only inactive files. In result, we must have all objects paths or scan directory and check files metadata. If they will have DeleteMarker set to True, it means, they have been deleted and potentially we want to recover them using commands above

There is an example bash script to recover all files saved in objects.txt (paths to deleted objects or all objects on our bucket) in particular bucket in parallel – 50 files in parallel to speed up this operation. It is only an example, so if you need a more specific solution, you need to adjust it.

#!/bin/bash

bucket_name="YOUR_BUCKET_NAME"

process_object() {
  object_version="$1"
  echo "Currently checking file: $object_version"

  metadata=$(gsutil stat "$object_version")

  if [[ $metadata == *"DeleteMarker: True"* ]]; then
    live_object=${object_version%%#*}
    echo "Need to recover: $object_version"
    gsutil cp "$object_version" "$live_object"
  fi
}

export -f process_object

# Run 50 processes in parallel
cat objects.txt | parallel -j 50 process_object

echo "Processing complete."

Summary

As you can see, because of some limitation, recovering deleted files in Google Storage buckets can be a bit problematic – it all depends on your needs. The good thing is you need to know only few commands and can then adjust rest to meet all your requirements. It makes these buckets flexible and maybe not the best in some scenarios, still a good option.

WSL – Reclaiming Storage Space

I’ve been a big fan of WSL ever since it came out – that to this solution, I can work daily with Windows, in my opinion the best and the most flexible OS, and still have all Linux advantages and a bit isolated work environment. Of course, WSL is not perfect and have some issues. One of them is taking up disk space. During our work, the size of the WSL file will become larger and larger. It will happen even if we will decide to jump into Linux distribution and remove a lot of unnecessary files. Fortunately, there is a quick solution – we can use diskpart includes in Windows to reclaim some space.

I’ve already written about one of possible solutions in the beginning of 2022 – that method is still valid, but a bit more complicated, because we need to enable Hyper-V components, restart computer, then reclaim space and… disable these components again, because in other case, our computer may not sleep correctly. Yes, it’s like a domino effect and everything is linked. Fortunately, it’s not only one method. The second one is much simpler and provides the same results. Let’s free some space.

Preparations

Before we will reclaim space, it is very good option to remove as much data as possible from WSL distribution – unused and unnecessary files, temp data, docker leftovers etc. There I propose some solutions you can use:

Remove packages leftovers (Debian & Ubuntu)

This command will remove leftovers, unused dependencies etc.

You can use similar command also for different distros based on your package manager

sudo apt-get autoremove && sudo apt-get autoclean

Clean temp directory:

It will remove temporary files. This command may display warning about some files – it’s fine

sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*

Remove docker leftovers

Useful only if you use docker inside WSL – this command will remove all unused containers, images, volumes and networks. Depends on your work, may free up a lot of space

docker system prune

Remove other files

Rest depends on your usage – you should know best what files you are storing and where. If you create some web apps, you can remove some generated assets and caches from directories. It is worth to also check user directory and remove all unused data

Using diskpart

Ok, right now we are prepared to reclaim space used by WSL. Subsystem must be disabled, so run this command from Windows terminal level first:

wsl --shutdown

It will shut down all WSL distros. Now we can jump into diskpart, type in terminal:

diskpart

There will be privilege elevation prompt (UAC) – confirm that. Windows will automatically start build in diskpart command in separate Windows. It’s not as powerful as a standard terminal, but for our needs, it does not matter a lot.

First thing we need to do is to select the virtual disk file used by WSL:

select vdisk file="{PATH_TO_YOUR_WSL_VHDX_FILE}"

How can you find the proper file? It depends on distribution. In default, Windows stores all these files in the user AppData directory. For example, in Ubuntu scenario it is:

SYSTEM_DRIVE\Users\{YOUR_USERNAME}\Local\Packages\CanonicalGroupLimited(...)\LocalState\ext4.vhdx

You can use Windows search or alternative search engines (like Everywhere) to locate all “vhdx” files.

Then, we need to attach this virtual disk. We will use read only option because we do not want to modify any data, just reclaim space used by this image.

attach vdisk readonly

Finally, we can start compacting process:

compact vdisk

It will take some time and the system will inform us about progress.

After completion, we should detach virtual disk

detach vdisk

You need to repeat these steps for all vhdx files you want to compact.

And it’s all!

Your virtual disk file size should be smaller after this process. It may not reflect all changes you made inside WSL – for example, I had a WSL image with a size of ~120 GB. I’ve removed about 30 GB inside WSL and then compact, but after process, WSL image is still ~100 GB instead of 90 GB as you would expect. It’s completely fine, compacting cannot cover everything. If your base image was very small and compacting can not help anymore, the only option you have is to reset WSL: remove current distro and configure it again.

Summary

As you can see, diskpart option is maybe a bit more complex in terms of number of commands required to run, but of course it does not need any additional components. You do not need to restart the computer, so operation is smooth, and you can free up WSL space at any time.

I hope it will help you reclaim your space. If you have any feedback, please contact me

New Page: My Books

I’ve just added a new subpage called “My Books“.

So far it has only one position, but it is available for free.

In the future, I plan to extend that. I have many ideas for books, only one limitation is time, but nothing is impossible

Book Review: Chop Wood Carry Water

I recently read the book “Chop Wood Carry Water” by Joshua Medcalf and would like to share my impressions of it because I think it will… it already started to change my mindset and life. It is very difficult to describe in a few sentences what this book is, so I decided to describe a little from my observations — also to consolidate knowledge for myself. It is a story about a man who wanted to become an archer, who went a long way full of important life lessons — all of which changed him a lot. This book is divided into many small chapters: all are connected, but each is also a bit separate story with another lesson, moral. Reading this book is wonderfully comfortable, because chapters are small enough to find even a few minutes every day to immerse yourself in reading and then in reflection.

Process instead of goals

Chop Wood Carry Water focuses on process, and it is mentioned many times. Instead of trying to achieve goals, one by one, instead of aiming for excitement, it recommends thinking about important items as a process. Some examples: I can set a goal like “I will make this course to be better”. It is nothing wrong, but what if we change our mindset and think more like “I would like to be an expert in XYZ, so I will develop and excel in this area”? It is a completely different approach. During this process, during this road, we can have a lot of milestones (so, something like goals), but even if we will not achieve them because of many reasons like changing plans, other opportunities etc. we will still be on track. This matters a lot. If you are a goal-oriented person, any kind of stumble, mistake, failure, can shake your self-confidence and it will not be anything pleasant.

“Any road followed precisely to its end leads precisely nowhere. Climb the mountain just a little bit to test that it’s a mountain. From the top of the mountain, you cannot see the mountain”
– Frank Herbert

I have already written about goals vs systems approach many months ago in different post and after lecture think it is valid even more: we can still have some goals, but if they are our point of reference in relation to ourselves, we will never be happy. Also, we will always be insatiable and saying “enough” will not be possible. It is because we will be in constant pursuit of our next and next goals. Of course, for some people it is something like a “life fuel”, but inside, it generates even more problems.

Talent vs training

There is also very interesting chapter about talent vs practice and explanation, why talent can be just a bad thing. Simple analogy: do you know, most people who win fortunes on lotteries are bankrupt after a year and are even worse off than they were before winning? Yep, it is true, and the reason is simple: these people were not prepared for such money. In most cases, they decided to just make some dreams come true, buy a sports car, a big home with a garden and swimming pool, a lot of gadgets. All these items are not only expensive during purchase, but also in the long term, because they do generate high costs. If you do not have knowledge of how to handle a big amount of money, you can fail with it.

“It is not what happens to you, but how you react to it that matters.”
– Epictetus

Practice is completely different: it may be slow, but it is a process during which you will learn a lot, you will fail many times, but you will not lose everything. You will be also better prepared for future and next steps. Maybe other, more brutal example: please think about many famous stars, who gained popularity suddenly and then turned to drugs, alcohol and often died even at a young age. Relying on talent is not the path we want to take it is dangerous and can blow the ego. With practice, we can be really experts, after time, but true.

You matter. Always

Another item, next significant change I think you always matter — your value is constant, not determined by what are you doing or not. If you fail with something, fine, you will get up and keep walking. Also comparing yourself to others is always a very bad idea. People have different minds, different missions and goals, so what is the purpose of that? Remember to always compare yourself to yourself, to the previous state, and the past. It was an interesting lesson for me while writing my first book about weight loss and transformation of my body because of these aspects. It was retrospective of what I was doing in the past, where I am right now and… yeah, it was great in term of self-confidence.

Probably I could have done a lot of things better, but I know this right now, I did not that before. Also, try to minimize usage of social media like Facebook or Instagram. They do not have sense and are the “best place” to compare with others. You will see always only the tip of the iceberg, the best part, but you won’t see many details: a lot of hard work (when someone posted info about achieving something), potential loans (when someone posted info about expensive gadgets) or people’s true opinion on many topics, because social media always build information bubbles.

Build your environment

One of the most important observations for me was about other people, especially the people we surround ourselves with, the people we hang out with. It matters a lot, because it builds our environment — we can call it bubble, but it depends on us, what bubble we will use. If we will join people who complain, eat unhealthy food, or always “relax” by only watching movies after boring work… we will start to be similar to them. Group has a power, and we should join proper groups: for example, if you know, you can learn from someone, join that person. Do you want to eat healthy? Build proper environment, convince family to also do the same.

Do not care about people who do not want to be like you. Why? There is a great analogy in this book: it’s like a bucket full of crabs — if one wants to leave, the rest will pull it down. So, do not be like a crab, ignore others and do what you should do. Sounds like you’re being an asshole? Sorry, you have only one life and you can spend it with the wrong, or proper people, it is your choice.

Rules and emotions

I was also very intrigued by the issue of emotions and their influence. For example, it is very, very simple to “motivate” (but for short term) using movies like Rambo or Braveheart. I know this and can confirm, it is very easy, generates a lot of “power” emotions, but in long-term perspective, it may be problematic. According to the book, we should remember also about this second, more difficult side i.e. working on calming and slowing down to have clearer thoughts. We can do that by, for example, listening to classical music, meditating, and spending some time reflecting on our steps and plans.

“The impediment to action advances action.
What stands in the way becomes the way.”
– Marcus Aurelius

Why should we not rely on big, powerful emotions? Because emotions can always change. With rules, things are different. Rules are fixed and we just follow them. With a good plan for our own path, we can always adjust our steps to rules, even if emotions are very high and try to move us in different directions. It is not easy, sometimes it will be very difficult, and we will need time to take a breath, but every time we will train this, our willpower will be better and better, we will make better decisions. Key for that is to have a life mission. Not a goal, as I mentioned earlier, but missions — like Mother Teresa or Gandhi. They did not need strong emotions, they had a mission and consistently, day after day they implemented it.

In my last post about stoic self-review, I wrote I plan to start doing evening summaries — this book also encouraged me to do that, because there is one chapter dedicated to remembering all the good things we meet or do during the day. It may look like something simple, obvious, but it has “magic power”: even if you think, day is “bad”, you can sit down, write few items and… you will see the same day in the completely different, better view.

Perspective matters while reading

Chop Wood Carry Water may look like something motivational or coaching, but I think it depends on people situation and perspective. For example, there is a chapter related to pushing forward despite everything. Sometimes we can ignore the big costs and move forward, even though what we want to achieve has lost its sense long ago. Even if we achieve the goal, we will leave behind the ruins, tears, suffering. This chapter was very important to me. I have a family, wife, daughter and definitely needed some reflection related to question: how much time do I spend on work, and how much for them?

“To be calm is the highest achievement of the self.”
– Zen Proverb

I can achieve a lot as a specialist, at the same time become a total asshole when it comes to the family, as Steve Jobs was, for example. Do I want to be remembered as someone who contributed a lot, changed a lot, but from the purely pragmatic side, or do I want to be remembered first and foremost by my loved ones? It is very difficult and always depends on perspective — I had totally different mine one, two and three years ago. Changes in my life changed also my perspective a lot and for example. My risk appetite has decreased because I know I need to take care of more than just myself. It is not withdrawal, resignation — it’s maturity and responsibility

Summary: I recommend this book

Overall, I think this book also refers to a lot of Stoic advice — I have been interested in this philosophy for several months and see a lot of commonalities: different perspective, process approach, a continuous path to improvement, abandoning comparisons to others and keep calm.

This is definitely not a book for everyone, I think. Many people will disagree with these points, with morals and they will prefer to go the simpler way, use shortcuts or even not take any challenge in life. OK, it is their choice, and it is nothing bad about that. We have free will and can decide. For me, this book is incredible learning and inspiration and thanks to it, I have already started to change some parts of my life. I know, it will be often difficult, there will be a lot of hard times, but I have my mission and want to follow this path.