Test your plans by reducing time

I couldn’t find any better phrase that describes the approach I’ve learned in the last year. It’s a simple piece of advice: Test your plans by reducing time.

It’s easy to fall into the trap of thinking that the amount of our free time is stable and we’ll also be able to spend the same number of hours on things in the future.

Sooner or later, you’ll need to put most of your effort and attention in a specific direction. Eventually, you’ll push every insignificant activity in the background, and you may struggle to find even minutes to deal with the rest of your stuff. Starting of studies, new relationship, new job, starting a family – they are only examples of events that can change your priority. If you want to stick to your routines, you need to change the approach to performing tasks.

Read more →

Avoid using global git identity

When I clone a new project, I put the proper email address (e.g., a company email) as an author email in the local config stored in the repository. It worked fine until I started working for a client whose project is spread across many repositories that I cloned when needed.

I can’t count how many times I forgot to put the correct email into the local config of the newly cloned repository before committing anything into it – just because I was in a rush. In effect, my personal email (which occupies my global configuration) has been leaking many times into commits, sentenced to last forever in the git history. I’ve probably done it more times than I even realize.

To avoid making these mistakes, don’t use a global git configuration for identity.

Read more →

How to remove hard spaces from file using awk

Some tasks seem easy when we perform them manually, but new things come to light once we want to automate them. What can go wrong if we remove hard spaces from a text file using a script?

If it’s a one-time operation, we run the editor, use the find-and-replace functionality, and that’s enough. Otherwise, we need to find a more automatic-friendly approach.

Read more →

How to decrypt PDF files on macOS

Some companies send encrypted PDF documents. If you’re a macOS user, Preview will ask you for the password each time you use quick look or open the document. Moreover, if you print that document, you’ll end up with a blank sheet of paper. At least I got it. So secure.

Read more →

Missing article image on Twitter due to GetMatch in Hugo template

Recently I received notification that somebody post information about my article on Twitter (thanks!). Twitter usually renders a link to blog posts as nice-looking cards. The card to my article shown up without a featured image.

I checked my Twitter feed, and some of my other entries also suffer from missing featured images.

Read more →

Line break in Markdown

There are a few different methods to enforce a line break in the same paragraph in Markdown syntax: HTML’s <br />, backslash and double space. Let’s consider each case.

Read more →

Restore files from encrypted iPhone backup

I do not use iCloud backup for my iPhone. Instead, I do local encrypted backup, more or less regularly. I wanted to browse and find something from one of these backup.

Did you know, that there is no native way on macOS to browse and restore something from your encrypted iPhone backup? I didn’t.

Read more →

Using local DNS in dhcpcd causes to ignore others DNS

I struggled with the strange behavior of dhcpcd on my Raspberry Pi powered by Raspbian. The RPi does many things on my local network, including ad-blocking thanks to the pihole service.

I run pihole1 as a docker container, and it does its job perfectly well. Thanks to the port binding, I could bind port 53 (DNS) directly to the host and use its address as a DNS server.

Read more →

Specify timezone for tests in Node to get deterministic results

In one of my side projects in Node, I wanted to test if the object with the date is formatted correctly as a Markdown entry. The setup of the test was the easiest part. However, comparing the outcome of the formatted Date object wasn’t so convenient because of the timezone. Because I live in the Europe/Warsaw timezone, I experience an offset relative to UTC.

Read more →

Synchronize two collections with different representations

We get used to reading about big things – high-level architectural solutions, design patterns in action, or big data processing. However, most of our problems are small and lie at the low-level in our code. One of them is: how to synchronize a collection of entities with another collection, which is its simplified representation?

Imagine you have a collection of entities. You receive an updated version of that collection, e.g., from the API endpoint. But what if data are transferred using DTOs? We should add new entities based on data in DTO, update existing entities, and remove elements that don’t appear in the edited collection.

In this article, I’ll show you a generalized solution to this particular problem.

Read more →