LH Log
Calling beforeEach in Mocha Tests is the Root of All Evil
Whenever we write a production code we follow certain procedures or techniques. One of the techniques is: do not mutate data unless necessary. Hence – in TypeScript – we try to use as many const statements as possible and as few let statements as possible. The main reason for doing it is clarity: if you know the variable foo is defined as a constant, you can count on it. Whenever you debug something, you know the variable has its initial value and the value is not going to change. [Continue reading…]
Tipping in Czech Restaurants: A Guide
What are the rules for tipping in Czech restaurants? It’s not as strict as in the US or UK. Rounding price up is usually considered good enough. How Much to Tip Tips are never mandatory in the Czech Republic and they are never included in the bill. Maybe in some fancy tourist restaurants, I have never been to. In a common Czech restaurant, the tip is never included and never mandatory. [Continue reading…]
Top 3 Hikes in Czech Silesia
Silesia is a historical region of Central Europe, mostly in Poland. Nevertheless, part of Silesia is located in the Czech Republic, and in this article, I’ll tell you my top three hikes in the Czech part of Silesia. I live in the city called Opava which is the capital of Czech Silesia and this a view from my apartment! Well, it’s much nicer in the real life. You should visit me! [Continue reading…]
Logs are Windows to the Past you Desperately Need
Imagine yourself – a software developer – going after a bug some customer reported. Do you remember saying “God, I hate these descriptive logs! I wish we logged less stuff!” You don’t remember saying it? Me neither. Because I ❤ logs. (This article is part of What I Have Learned As a Software Developer series.) What do I mean by logging? Usually something like adding a line of code such as this one: [Continue reading…]
Meetings are Useful
Do you like meetings? If you are a software developer, the most likely answer is: “No, I’d rather spend hours fixing other people printers than attend a meeting!” (This article is part of What I Have Learned As a Software Developer series.) A meeting is a crucial part of a programmer’s job. Yet, we tend not to like it. We like to create programs. We like to refactor for-loops to map function to make it functional and we like to refactor map function to for-loops to make it run faster. [Continue reading…]
What I Have Learned As a Software Developer
I’ve been a software developer for a few years now. I was studying computer science at the university for six years and now I’ve been working as a full-time software developer for another six years. I think it’s time to summarize what I’ve learned so far and how studying at university differs from real life. My Experience I work mainly on back end side of things in NodeJS and Typescript. I have experience with developing web applications using Angular and AngularJS and for a few years, I was responsible for developing “something like Google Analytics” which included the usage of some big data technologies such as Hadoop or Kafka to process thousands or even ten thousand events per second. [Continue reading…]
Making Conditions Based on the Branch Being Deployed in Netlify
I love Netlify’s branch deploy feature. It allows you to automatically deploy a code located in a git branch on a different domain than your master/main branch. Whenever I write a new article I write it in a branch and then I can preview the article on the web on the branch domain. I wanted to forbid indexing of such branch deploys by robots like Google so the content doesn’t end up in the Google index. [Continue reading…]
Are there more odd or even numbers?
How can we tell if there are more odd or even numbers? What about the natural numbers? Are there more natural numbers, even numbers, or rational numbers? It’s not easy to tell because there are an infinite amount of natural or rational numbers. Yet, we can somehow compare their sizes. Let’s start with simple finite and small sets. Imagine two sets of numbers: blue numbers and red numbers. 1 2 3 4 5 6 7 8 9 Can we tell which set contains more numbers? [Continue reading…]
How Did We Become the Most Covid-Infected Country in the World 🇨🇿
The Czech Republic currently has the most newly confirmed cases of Covid and most Covid-related deaths in the World. How did a small country in Central Europe gain this achievement? In case you don’t know the Czech Republic: we have about ten million inhabitants, we are very good at brewing beer and even better at drinking beer. The black dot in the middle of Europe is us: (source) The First Wave We excelled in the first Covid wave. [Continue reading…]
How to Counter Zerg Units in Direct strike
A guide to StraCraft mode Direct Strike. If you struggle to counter specific Zerg unit in Direct Strike this can help you. How to Counter Zerglings Zergling is a biological light unit. Zergling is the strongest early-game unit, no unit counters a herd of Zerglings. Not even Banelings if you position Zerglings correctly. As Terran build Hellbats and upgrade Infernal Pre-Igniter (blue flame). As Zerg build a few Banelings and a few Roaches and eventually upgrade to T2 and build Lurkers and Infestors to Fungal the enemy’s Lings. [Continue reading…]
How to Counter Terran Units in Direct strike
A guide to StarCraft mode Direct Strike. If you struggle to counter specific Terran unit in Direct Strike this can help you. How to Counter Marines Marine us a biological light unit. It deals an incredible amount of damage in a short time but it’s pretty fragile. The key is to kill them fast. As Terran build more marines and mix it with Reapers for the grenade (KD8 Charge). Don’t start with Marauders, they won’t help you in Marine vs. [Continue reading…]
How to Counter Protoss Units in Direct strike
A guide to StarCraft mode Direct Strike. If you struggle to counter specific Protoss unit in Direct Strike this can help you. How to Counter Zealots In general, build anything that has bonus damage against light units. As Terran go to T2 and build a ton of Hellbats and upgrade blue flame (Infernal Pre-Igniter) which improves damage against light units. Do not build all the hellbats in a single line, use some circle-based formation. [Continue reading…]
How to use instanceof in switch statement in TypeScript
How to use the switch statement when checking whether some object is an instance of some class. If you don’t like long reading, skip to solutions: constructor based and DSL based. Imagine code like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Shape {} class Point extends Shape {} class Rectangle extends Shape {} class Circle extends Shape {} const shape = new Circle(); if (shape instanceof Point) { console. [Continue reading…]
Estimating Number of Unique Elements
Have you ever needed to count the number of distinct elements in a really large collection? I’ll walk you through some of the options you have. The Naive Solution Counting number of unique elements is a common problem in the computer science. Consider counting number of unique users that use Facebook each day. Or each month. This could be pretty big number. Billions of users! And counting it properly is possible, yet often not desirable because of performance issues. [Continue reading…]
SC2 Direct Strike Zerg Build
What units to build when playing as a Zerg in SC2: Direct Strike in 3V3 mode. You can also read my guide to Direct Strike for beginners. Against Another Zerg ZvZ is a fun matchup. I prefer to skip the first wave, go to T2, and then scan the opponent’s base. Then I decide to either: Go for Roach/Hydra composition. Roach/Hydra is an excellent composition because Roaches are good at tanking damage and Hydralisks are good at dealing damage. [Continue reading…]
Unit Testing Code That Uses a Database
Almost every application that we develop uses a database. It either stores data to a database or reads data from a database. Often both. Unit testing such code can be a tricky thing and we’ve tried multiple approaches to this problem. Eventually, we found a good compromise. For the sake of simplicity assume we have a function that communicates to a database: 1 2 3 4 5 6 7 8 async function readPerson(personId, database) { const items = await database. [Continue reading…]
SC2 Direct Strike: Ultimate Guide
Welcome to Direct Strike’s beginner’s guide. If you are new to the game or if you want to read some tips on how to play better this is a perfect resource for you. Direct Strike Overview We’re going to talk about the standard 3v3 (or 2v2 or 1v1) format. The goal of this game is to build your units at the staging area and let them fight against your opponent’s units. [Continue reading…]
Every change to a public interface is a breaking change
Suppose we have a Typescript library called shapes exporting an interface called Point. What change can we make to this interface so we can release a new version of shapes as a minor change, not breaking anyone’s code? This is not an easy question as it sounds like. I’ve witnessed many people releasing a new version of a library as a minor change without realizing that this change is going to break someone else’s code. [Continue reading…]
Lukáš Havrlant
Hi, I’m Lukáš Havrlant and I live in the Czech Republic in a small city Opava. I’ve been working as a NodeJS/Typescript developer for many years. Currently employed by Ströer labs. I like green tea 🍵. I don’t like coffee ☕. I like to play StarCraft II. And I wrote one of the most visited websites about math in the Czech language matematika.cz! [Continue reading…]