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.  

Conditional query in Laravel Eloquent

Laravel Eloquent is very powerful and we can use it in many cases to get or filer data. One very common situation is to build query according to some statements and conditionals. The most common way to achieve that is to build id step by step: 

$onlyUnread = $request->only_unread ?? null;

$query = Article::query()->where('active', true);
if ($onlyUnread) {
    $query->where('unread', true);
}

$articles = $query->get();

Last time I checked some old documentation and found different method – when. It allows us to simplify that process a lot and include are conditionals and additional query steps in just one command: 

$articles = Article::query()->where('active', true)
    ->when($onlyUnread, function (Builder $query): Builder {
        return $query->where('unread', true);
    })
    ->get();

It’s much cleaner than build step by step, and because we still use Builder object, we can do exactly the same things like on higher level. Of course, it may be necessary to use some additional params – of course it is not a problem, we only must send them to function inside:

$articles = Article::query()->where('active', true)
    ->when($myCondition, function (Builder $query) use ($param1, $param2): Builder {
        return $query->where('unread', true)
            ->orWhere('param1', $param1)
            ->orWhere('param2', $param2);
    })
    ->get();

It is also possible to use when more than once – if you need set some steps with separate conditions, no problem. I do not know, why this is not present in current documentation, but when method is available in current Laravel version and can be used without additional steps.  

Goals vs systems

This is one of the usual posts on my blog and you will find some strong, vulgar words inside – it was necessary, because I’ve come a long way and want to name certain things appropriately, without any mercy. Do you have any goals? Are you goal-oriented? I was such a man for a few years, and I can’t recommend such approach. It may look like good motivation, but it’s destructive and stupid, in most of cases, it’s just coaching bullshit. Right now, I change my life from goal-oriented to systems-oriented, I will explain difference and write, why goals are bad option. 

It’s difficult to not hear about goals nowadays – a lot of people discuss about success, about scaling, about self-improvement. One of the core elements of such approach are goals: you must have goals and you must do anything to achieve them. For example, attractive shape, fit. According to many people, you should set your weight target and then train and eat to archive that goal. Or your own business: you SHOULD grow up, earn more, hire more employees, produce more, and more, rise your market, scale up every time. It looks fine seemingly, but there is a big problem – what after that?

Rat race

Last years I have archived a lot from my assumed goals. And guess what – almost every time, I felt happy for only a moment, and then I felt a void – no more goal, no more sense… Solution is simple and coach gurus can tell you: find another goal to achieve and continue your adventure! But it’s stupid. It’s like rat race, never-ending story with only few moments of happiness and rest of enormous, debilitating effort. It’s not hard to work hard, to work a lot, but make it without good sense: for example, waste time for meetings, for pep talks (I really hate them), but without real vision, without knowledge of what we want to do and what our values are. The tricky thing it to work smart, to say STOP in some moments and decide we are not interested in scale up, because… it will break our rules and we are happy now. 

With systems, values are more important. Back to fit example from the beginning: weight target is bad, because after months of many austerities you will be happy for only moment, and you will return to the previous weight quickly. It will need a lot of willpower and will “drain” you, like bad app can drain your phone battery. All changes you made were only temporary, only to achieve that goal. Then you will try again… and again… and again. With the same result. And it’s a definition of insanity: “Insanity is doing the exact… same fucking thing… over and over again expecting… shit to change… That. Is. Crazy.”. With system, you do not need austerities. You can decide I want to be healthier, and then, step by step, change your habits and nutrition – still tasty, but healthier than before. You do not have to plan finish an Iron Man, but you want to be quite active every day: because you know, that good sleep + healthy food + some activity = you will feel great most of time. Most, not only few minutes after each stupid goal! What an amazing difference!

With systems, it’s not important to push extremely hard. It doesn’t make any sense. Example from my life: I can run fast, but when I increase my pace, I also increase chance to injury. It doesn’t matter, because benefits from higher pace are small and from my perspective, irrelevant: I do not have goal to win something, I want to be healthier to have more power for my family, to enjoy life so… As you can see, it’s simple. Amazingly simple and I love simple things a lot. The hardest thing is to change a way of thinking. During years, a lot of us has been infected by toxic thinking, that only achieved goals can give you happiness. If effect, lot of us uses social medias “to be famous”, to show different people, what we achieved, to measure our progresses and compete with others (like Strava). But all of that it’s bullshit, just answer that question: what will you do after your current goal? Will you set a new one? Just think about that. 

Goals are for losers

With systems, you do not have to abandon all your goals. They can remain, they can build your systems, but you must remember, to not treat them as process determinants, milestones etc. If you will fail some goal – no problem, you can learn a lot from that lesson and it’s always solution where everyone benefits. I think it’s hard to separate these two things – I can blame myself easily after non-achieved goal, so in such cases, it’s better way to avoid them. And it’s the reason I still not full decided to use or to not use some services like Strava. They have their advantages, but “hidden defects” are particularly important in most of cases. Life is too short and too beautiful to waste time for such defects.

To be honest, I do not mean to stop, sit down, do nothing, and say: “I’m happy now without that rat race!”. No, it’s not an option, not for people like me, who like challenges. I urge to change life fundamentals, to build few systems based on our values and then use them to be happier. If you think you can be happy because of money, you are wrong: new jacket/car/home/TV/plane will be great for few days, but after that, you will lose a sense of novelty. If you think, achieved goals and “sucess” (whatever it is) will give you better life, you are wrong. Simple things can give you a lot of happiness, and you can use systems to make your life longer and simpler, to have more time for happiness instead of mindlessly, crazy forcing forward. It’s your life, don’t fuck this up.