Missing Code Review Advice

We all know that code reviews are important and have a lot of value. There is plenty of “best practices” articles telling you how you should do a code review, when, at which pace, on which Moon cycle, which SMARTass criterias to prepare, etc.

I believe they miss one piece of advice.

There are two types of changes you as a code reviewer can propose to do: the ones that involve some huge effort, and the ones that do not. The examples of the former are architectural changes, missing functionality, wrong interpretation of requirements, etc. Among the latter are code style issues, typos, redundant comments, missing type hints, obvious small bugs, etc.

Sometimes You Are No One without your Phone

We become more and more dependent on all sorts of technology and gadgets in our lives. Exactly for this reason, I try to minimize the amount of digital things I interact with daily.

All I have is my laptop and, of course, my smartphone. And it is my smartphone that made me recently feel completely helpless.

One day I decided to try a scooter sharing app.

I took a scooter and had a 10-5 min drive to a subway station, where I wanted to switch and go home. The ride was really great. But when I arrived I had to end my rent. Via the application.

For several minutes I was getting a Bluetooth connectivity error and could not stop the rent. And then my phone’s battery just died. One second I had ~20% of a battery, and another - the screen is black.

Building a Slack Command with Go

This post is a step by step tutorial on how to build a simple Slack command with Go.

Bedtime Ideas

Bedtime ideas

Ah, bedtime. It’s time to close Reddit and have some rest. But not for your brain. Have you ever wondered why you’re so damn.. ehh.. creative before sleep? Why does your brain start to produce this stream of crazy ideas? I have, so I made a small research on the topic.

It turns out, that it has nothing to do with the time of day (well, a bit), but rather with your energy cycles. Let’s break it down.

Gracefully Terminate a Program in Go

This post is about gracefully terminating a program without breaking currently running process.

Tie-breaking Rounding

So I was reading an article about differences between Python 2 and Python 3, and there was a statement:

Python 3 adopted the now standard way of rounding decimals when it results in a tie (.5) at the last significant digits. Now, in Python 3, decimals are rounded to the nearest even number.

At this point, I was like “WTF?!”. At school I was taught a simple rule: if x is exactly half-way between two integers - round to the largest absolute value, i.e. 13.5 becomes 14, and -13.5 becomes -14. No magic with even/odd numbers. It wasn’t even discussed, that there are might be different ways of rounding.

But, as it often happens with school program, they didn’t tell us all the truth.

There are actually six more or less normal ways and two not so normal, thus leaving us with eight (eight, Carl!) rules of rounding.

One Way to Deal with Anxiety

Whenever it comes to some sort of a test or exam, I start to have this feeling of worry and anxiety. It doesn’t matter how well I’m prepared - I still have it. And, of course, it affects my performance not in the best way.

But there is one way, that helps me overcome this feeling. The key point, though it might sound strange, lies in our insignificance. When the stress begins before some important occasion, I do an exercise.

First, I concentrate on myself, like: this is me, I’m standing here and feeling anxiety. At this point I can describe myself a bit, e.g. the clothes I’m wearing, etc. It usually helps to relax by changing the topic in your head.

A Few Notes on PHP Exceptions

There are several practices, that I found myself using over and over again while working with PHP exceptions. Here they are.

Atomic Change of an Index in MySQL

Imagine you have a composite index on four columns, and you need to remove one column from the index. The obvious solution would be to re-create the index:

DROP INDEX idx ON test_table;
CREATE INDEX idx ON test_table (column1, column2, column3);

But after the DROP statement there is no index at all, which is, of course, bad for performance. Especially on a production system. The other way would be to re-create the index in one ALTER TABLE statement:

ALTER TABLE test_table
ADD KEY idx (column1, column2, column3);

Split File in Chunks without Breaking the Sequence with GAWK

Today I came up with a task for myself, mostly for fun, but it also has a useful application. I have a dump of some MySQL table in csv, it’s ~500K records. The data will be loaded into Neo4j, though I want to speed up the load and be able to parallelize the process. Of course, I can make it in any programming language, but I decided to practice with Linux shell commands and to use gawk.

The example structure of the file is like this: