The best investment you can make

Right now we live in somewhat difficult times: there is still a pandemic, some restrictions, rising prices and inflation. A lot of challenges, but of course also a lot of opportunities. It is normal that many people think about how to invest, to save their money, families, work etc. Some of them buy and rent houses or offices, some buy gold or silver, some invest in stock exchanges, some trying their chances on Forex (and according to research, 95% of them are bankrupt after just two months), some also trying cryptocurrencies, NFT and similar things based on new technologies. 

Each of them has a risk level: higher or level, but there is risk. Of course, we can say that investing in government bonds is a safe method, but with current inflation levels, it cannot even prevent loss. What if there is always a good method to invest? What if that method does not require a big capital, a lot of money, but in most cases provides a huge rate of return? Yep, there is such a method, and it’s very simple.

It is investing in yourself

Just that, and so much. It’s super simple, but I think some people do not or do not want to understand that. I know some people who have quite nice work and positions, and they try investing in very risky things. It is ok, it is their money and I can not decide here. But… simple observation: they often need a lot of time to track some stock changes. Sometimes they win, sometimes lose, I think it is similar to playing the lottery. I win the lottery every day. How? I do not play, so I can save that money for something different. Coming back to mentioned people – imagine they will spend just 10% of time they require to observe stock to learn new things. Just 10%, no more! I am 100% sure that after a year, their base salary will be higher. What if they decide to spend 50% of their time? No, it is not only a dream from movies, some stupidity bizarre from pep talks. It is just a simple rule. 

Remember, if you learn something new, it will be your skill till your death. No one can take it from you. That new skill may increase your chances in the labor market: because of new abilities, you will have higher chances during applying for a higher position with better salary. Even if you will not be successful, that new skill may help you in the future, or in your personal life. Nobody knows what we will do in the next ten years, so… Treat that always like the best investment you can make. In most cases, it will not require any additional money – if you can read this blog post, you have internet access and phone, tablet or computer. With such a connection, you have access to the biggest knowledge database in the human world. And what is also interesting, a lot of people share their knowledge, without any fees. So, just read, learn, then try new things to “learn truly”. 

This rule works not only for money, but also for a lot of different things. We can do what we like to do, or we liked to do in the past: sometimes I want to play old games that I loved 10-15 years ago. It is fine, but just in the first 5 minutes. After them, I feel it is nonsense, because “I already did it”. I do not regret these hours I played in the past – maybe that time was required, I also liked that, and it was fine. But right now… it is not exciting anymore. I want to gain new knowledge, new skills, new abilities, or even… something new just for relaxation. Watching the same movie two or more times is nothing interesting for me, but watching something new, especially science fiction, why not? Reading the same book a few times… it depends. If we talk about belles-lettres, no way. If it is something that I can use to improve myself, yeah, I definitely often go back to intriguing books. 

Perhaps I do not take a lot of risk, potentially someone will tell, that I am just a coward, but I do not care about that. I do not believe when someone tells me: “just invest in that, the rate of return is amazing 200%!!!”. Sorry, no way. I think even slower, but continuous growth and progress is much better. I remember I was shocked when the pandemic started. I panicked and bought a lot of EUR and USD because the Polish Zloty was so weak. It was my fault, and a good lesson: when I decided to expand my knowledge about investing, financial instruments. Bought a lot of books, built a diversified portfolio and right now I am much calmer: I do not know what will happen, but it should be fine in many situations. I do not have to track a lot of sessions, results it is not my goal. I know that I need to be up-to-date, but not with everything, it should not be too time demanding.

And it’s just one example, probably very common. 
Think about that – how much effort and money can you save though investing in yourself?

From sport to self confidence

If you know me personally you probably will not agree when someone will tell you, I was shy, very shy. Yep, it’s true. Few years ago I was a young man, introverted and shy. To be clear: I was and I am still an introvert: it is a part of our nature, we can align some things, but personality type is not the same as character. During our life, our decisions, we can change our character, but not personality. I still do not like crowds, a lot of noise, loud parties, but there is one big difference between me now and me a few years ago: I believe in myself, I trust myself. Because of that, other people see me differently and can not believe I was shy. 

Again, if you know me, you know I like sports and I do a few workouts every week. Have pretty interesting habit for almost two months: I run a half-marathon every weekend. It used to be different a few years ago. I really… hated sports. It is true, really. Hard to say, what was the reason for that, but maybe bad experiences from school time? I remember the most popular activity was football and I was never interested in football… or basketball, or volleyball. First, I was not good at any manual things that require precision. Second, I did not feel good in teams in school: with a lot of people playing for themselves, not for the team – they could always complain about others, but they did not motivate others. Because of that and a few other aspects, I was shy and I did not like sports. In effect, at 23 (and even earlier), I was obese, I was really big man.

Then, things started to change. There was not a very successful episode in my life that I am laughing at now: first fascination, I got an elbow and was depressed for about half a year. It was a hard time, but then I changed my mind: decided I would never get down on my knees again, and also started weight training. First by just push-ups, crunches and squats, then using an exercise bench in my home. It was nice, very nice and I felt better and better every week. When spring came, I started cycling my old bike – just a few kilometres, to get to know my local area. I changed that old bike quickly to a new one, a trekking bike and cycled farther and farther. It was the beginning of my adventure with bikes.

Last year I made my “final fantasy”: cycled from my home to Baltic Sea in just one day, it was about 400 km. Did it with my friend, another local cyclist. Of course right now I have a different bike, different knowledge, physical level, but it is a clue: it was a process, step by step I builded different person, a different me. During that, I gained a lot of confidence. There was a period when I wanted to start each race: two MTB races in one month, next month road race and mix using cross bike, next be a part of a triathlon team (of course on bike). Did I want to prove something to myself? Maybe, I am not sure right now. Right now it is different: I do not race, do not have plans for that, just want to have a lot of fun… and make the transition from cycling to running, because after the first, completely unplanned marathon distance, I feel I found the next milestone in my life. 

Of course during these few years, I did a lot of things not related to any sports: getting a sweetheart, working in a startup, learning new things, trying new things, all of them are great challenges but I think sport was the basic, the fundamental of all changes. It allowed me to think better about myself, to trust myself. Right now I do not have to prove anything in races: I know I can, so it is just my choice. In most cases, I will not be interested, in some cases, I will do it on my terms: right now I want to do an ultra run, but not on an official competition, just for fun. And it is amazing, it works in different areas of life: you do not have to, you just want. It can also be funny, then in the gym (I do not look strong), someone starts a conversation, we talk about sports, I mention cycling and there is a question for me: “did you ever cycled 100 km?”. I can only smile and answer: yeah… it was fine, but it was only the beginning. 

Right now sport is part of my life and I know, it will be as long as it will be possible. It is a habit, it is passion, sometimes it is a positive addiction. I believe, without sport I would not be where I am – and I am very content and happy now. Can not recommend strict sports, competitions, a lot of austerities, keep pushing forward anyway – no, all these things are not important. Important is consistency and something like discipline. Even walking can help us a lot: it is a great time to refresh our minds, meditate, and rethink important questions. If our activities become passion, it is fine, we will change our life. 

Reduce WSL and Docker disks size

I really like WSL/WSL2 in Windows – it provides a lot of features with minimal performance impact (WSL2) and I can still use Windows app. In combination with Docker, it can handle a lot of things and it’s much better for me than for example MacOS. One problem I discovered last time is space consumed by WSL, and also Docker volumes. In both cases, Windows uses Virtual Hard Disk (VHD) format, vhdx files to store all data.

The problem is Windows can extend virtual disks on demand, without asking about that, but doesn’t reclaim free space if we make bigger changes inside WSL filesystem or Docker volumes. I had few IDE versions and different instances, each about 1,5 – 2 GB, and it consumed a lot of space. After deletion them from WSL filesystem, I didn’t get any real free space on my computer disk. We have to manually compact virtual hard disks to do that. How to do this? It’s quite simple. First, we have to enable Hyper-V if it’s not enabled. Just run terminal or PowerShell with admin privileges and execute this command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

System restart may be required after that.

Second step is to compact disks. First, close Docker Desktop if it’s running and also shut down WSL by command:

wsl --shutdown

Right now we can compact disks, command is also very simple:

Optimize-VHD -Path "path_to_disk.vhdx" -Mode Full  

The question is, where can we find these disks?

You can find disks created by Docker in:

SYSTEM_DRIVE\Users\your_username\Local\Docker\wsl // and then directories inside

Second thing is related to your WSL distro – all should be in the same main directory, but with different subdirectory. I use Ubuntu, from Canonical and in that case, data is located on:

SYSTEM_DRIVE\Users\your_username\Local\Packages\CanonicalGroupLimited(...)\LocalState\ext4.vhdx

Of course you can use search or tools like Everything to locale any *.vhdx file easily.

After execute command, file should become smaller and you will have more free space.

The most important question in life

Last time I think about long-term goals in my life and what I really want to do, to achieve. These thoughts caused I decided to write a post about some of them. You will find sport-based examples in this post, but these are just analogies, and you can translate it into other views. The most important question is:

What do you want from your life, and how do you want to achieve that?

Even this year, I was a “bike-mech” geek. I really liked to read about cycling technical, new groupsets, different and proposed solutions, watch reviews and discuss with people about that. I have been in such point for few years, and it was fine for me. During that time, I also tested some things to form an opinion: I had about nine different bikes (not in the same time of course), tried tubeless three or four times, changed bike shoes, experimented with HR straps and bike computers… Whow, it was a ton of gadgets and bike parts. Of course, it was fine then, but right now when I think about that… it was a bit crazy. To be honest, right now I feel tired and do not want to join that “rat race” anymore. Because of COVID, some markets gone mad – and bicycle market is one of them. Prices are high, there are not enough parts, and it looks like situation will not be better in 2022, or even in 2023.

So, what choice do I have? What choice do other cyclists have? Can we only buy new things for higher prices? No, we can quit that race and stop doing that, we can look for something different, something simpler and more effective at the same time. In reality, I found something like that, and it is running. Much simpler, much more suitable for countries like Poland, when only max four months in the year are surprisingly good for cycling, without tons of gadgets and available to do in many unusual places: if I will go for business trip, holidays, to close family. No problem, I will only take shoes and clothes and I will be ready for that. With bike, logistic is bigger problem and it causes you must be “more stable”.

I live with my wife in the apartment. It is not big, but it is also not small – we have separate bedroom and two additional rooms, so for two people, it is enough place. Living in such apartment has disadvantages: your neighbors may be too noisy sometimes, you have limited space for all your things, you cannot decide about some matters like for example additional, independent power source. From my perspective, also cleaning bike is sometimes problematic and in effect, I avoid riding in bad conditions. But it also has advantages. I do not care about snow during winter: there are people hired for that. I do not care about grass around the building (and I really hate mowing), about heating, electrical or water systems or communal waste. I know that because I’ve lived in house for over 25 years. In apartment, a lot of things is included in rent I pay every month and it is extremely comfortable, I can spend the same time for more interesting things.

Last time I thought about my own house. A lot of people decide to loan a credit and build their one house to avoid some apartments disadvantages. I think some of them – not all of course – forgot about all new work they will have with house. All additional costs, all time spend for mowing, painting, gardening etc. Yes, of course you can hire people to do that, but in such case, you will have to earn additional money to do that so… you will spend more time in job, or in creating additional funding sources. I read article about people how won big lotteries. After a year, about 90-95% of them were… complete bankruptcy. Why? Because they were not prepared for such money, they do not invest that money, just spend for things which generated costs: new house with pool? Nice! But you will have to pay for cleaning that pool. Nice, fast car? Why not, but every inspection, every part will be more expensive. And these things will not earn additional money for you, they will only generate costs.

I think a lot of people want many things without real reasons. Just because other people have these things, because these things are fancy. In Poland, still some people think that iPhone is luxurious, a kind of social status symbol. It is bullshit. It is just phone, mass gadget. In the USA, iPhone has something about 50% of market. Are all US citizens rich? No. When are you rich? It is hard to say, because every time you can find people with more money, more things, more companies etc. It does not make sense to compete with different people. The only sense is to compete with yourself – if you really want to improve something in your life.

If you do not know, what you want and just look for other people, you waste a lot of energy, will power, money and time for something that does not bring you joy. I like competition, I like challenges, but sometimes I see, that comparing yourself with others does not make any sense at all. We can find exceptionally good example in sport, in any sport-social apps like Strava. It is fine to show your results, to share pictures from interesting events, to involve other people or be involved by them. But if we decide to train to be better than others on our feed… It is another bummer. It will be never-ending story because we can always find better people. And guess what – professional athletes do not use such apps! Why? Because social aspect is not important for them. They need raw training data, for trainers, to prepare better training and recovery plans, to prepare for the real competition.

The fun thing is that we do not need most of things we “want”. We spend time to earn money, then buy them and… after 2-3 weeks the feeling of novelty disappears. So, we want next new thing… vicious circle, which offers us only additional work, additional worries, time we spend for something we will not remember on our deathbed. So simple, but I realized that just recently and right now I wonder a long time before I buy something new. Life passes, and we are still in the race. We can win it, but for what price? Did you ever think about that? If no, it is suitable time to do that.

Do not get me wrong. I do not think about abandon personal development and endeavor – I am a type of fighter, warrior and I always have interesting goals – even if I think, that systems-based approach is much better. That post is not something like “it doesn’t make sense”. It is about “maybe something doesn’t make sense”. Thinking and changing your mind is never bad. Aimlessly going one road never makes sense

MongoDB aggregation – why stages order really matters

MongoDB aggregation framework is very powerful tool. It can do much more than many relation databases features, but if we do not know or do not understand some simple rules, effects can be… a bit strange. Especially if we want to use it in PHP and build aggregation step by step, as array of commands. Great example is to use sorting or limiting, one small mistake and it will return false documents. Why? Because we can forget about commands order. 

When we use standard Eloquent, it’s not a problem to first set some conditions, then add sorting and then additional conditions, everything will be fine, because it will use simple find on Mongo: 

$query = MyModel::query()->where('foo', 'bar');
$query->limit(10);
$query->orderBy('name', 'desc');
$query->where('param1', 'val1');
$results = $query->get();

 
In that example, everything will be ok, because query builder will do all required things. But what if we will try to do the same thing using aggregation framework? We can do that in raw Mongo, but use another PHP and Laravel example, it will the same except small syntax changes: 

$aggregate = [];
$aggregate = [
	'$match' => [
		'foo' => 'bar'
	]
];
$aggregate = [
	'$limit' => 10
];
$aggregate = [
	'$sort' => ['name' => -1]
];
$aggregate = [
	'$match' => [
		'param1' => 'val1'
	]
];
        
$results = MyModel::raw(function (Builder $builder) use ($aggregate)) {
	return $builder->$aggregate;
};

In that case, results will be completely different. Why? Because when we use aggregation, command order matters. It will first filter documents and receive only these with field “foo” with “bar” value, then it will limit them to just 10, then sort and in the end, use additional filter by “param1” field. As you can see, limiter inside will cause, that a lot of documents will be skipped and not included in query. Its why command order is important – it allows us to make very complex queries, modify data, join collections in different way (using $lookup) but we should now, what we want to achieve.  

Ok, so, how should be prepared aggregation to work like simple query from first example? We need to change order. Also, we can simplify that by merge two $match stages into one: 

$aggregate = [];
$aggregate = [
	'$match' => [
		'foo' => 'bar',
		'param1' => 'val1'
	]
];
$aggregate = [
	'$sort' => ['name' => -1]
];
$aggregate = [
	'$limit' => 10
];
        
$results = MyModel::raw(function (Builder $builder) use ($aggregate)) {
	return $builder->$aggregate;
};

In that case, aggregation will first filter documents, then sort them and finally use limiter – no risk, that some documents meet our requirements will be skipped.