Use Vuex to avoid multiple requests from different components

JavaScript is asynchronous, it’s big advantage, but in some cases, also a big problem. The most popular mistakes relate to AJAX requests. Many people trying to do something before there is a response with data, and it cannot work. Now we can use many comfortable tools, and don’t have to remember about that – one of them is async/await. But sometimes, it can be still a problem. Let’s say, we use Vue, have one page with multiple similar components. Each of them needs some data from the same API endpoint, and calls request. In that case, we can’t use async/await, because there a lot of completely separate components. How can we avoid multiple requests then? There are few solutions, one of them is to use Vuex and this post is about that. 

Continue reading “Use Vuex to avoid multiple requests from different components”

Browsers JavaScript performance test

JavaScript Test

Browser is today one of the most important aplications – very often we don’t have to use other, specific aplications, we need only browser to open not only pages, but also complex internet services and apps, email clients, remote desktops, stream, play games or use social media. Most of these services are based on JavaScript, so performance in this area is very, very important for overall browser performance. There are many browsers, but we have only limited browsers engines now. I decided to made a small test and compare popular browsers JavaScript performance. Results are not surprised me, but have some interesting conclusions.

Continue reading “Browsers JavaScript performance test”

X Marathon around Lubin

X Marathon around Lubin

Just like every year, a mararhon around Lubin was in last days of August 2019. Some people ran 100 km or less, other used bicycles and also many different distances. It was my third start on this marathon, and like every year, I decided to ride 110 km, the longest one. Weather was great – especially in the morning. All day was sunny, without rain, but also hot, there was about 32 degree Celsius (~92 degree Fahrenheit).

It wasn’t race, but great marathon: you could choose start time (from 6am to 10am, every 30 minutes) and also choose path, but must visit all eleven control points. As every year, I rode some in forrest, some on roads, and also lost way few times. Theoretically the best option is to ride across the red trail, but some sections are terrible for gravel or cx bikes. Overall, it was fantastic day!

Jizera Mountains, edition 2019

Jizera Mountains 2019

I visited Jizera Mountains again in this year. It was great time with a lot of hard cycling – not 100 km, but more that 2000 m uphill. Ufff, it was difficult, but amazing. I made a lot of personal records in many segments on Strava. Yep, it wasn’t most important, but it always something good. When next time? Maybe this year? Not sure, but want visit Jizera again! One info: tubeless saves me this time, but I disovered this after went back to home. I will wrote about that in one of next posts.

MongoDB – Natural sort

One of the most common problems with databases are sorting. Let’s see an simple example: we use MySQL/MariaDB and have table with some data. We want to sort this data. Everything is ok if we use only values in the same type in field, for example numeric (maybe some amount?), strings (titles), dates, keys etc. But what if field is custom, user-typed data and may contain many types? In that case, we have big problem, because standard sorting is not enought, it will not work. Example, value: “11”, “1”, “2”, “3”, “2a” will be sorted in order: 1, 11, 2, 2a, 3, not as we expected i.e. 1, 2, 2a, 3, 11. The solution is to use natural sorting.

Continue reading “MongoDB – Natural sort”