Posts

From engineer to manager

In 2015, I co-founded a company with my friend. Until then I had been working as an individual contributor. Though I had been a technical lead to many projects, I hadn’t managed teams. Over the past 7+ years I have learned a great deal on project and people management. My experience has taught me the most than the books and articles I have read. In this series, I would like to summarize what has worked for me with the hope that it would be helpful for someone following similar trajectory. If you have any feedback, please leave in comments. Project and people management As a manager, you are managing two things: projects and people. They both require different sets of skills.  For the most part, managing projects can be learnt from reading books. But managing people is a different skill and it cannot be learnt from books alone. It requires a lot of interacting with people. It requires listening and understanding people’s needs so that you can help them succeed. Usually these needs a

Service health checks - the right way to build them

Service health checks are ubiquitous. If you have built any software that relies upon any upstream service, I am sure you would have used some form of health check. Your software could be a stand alone program or it could be a proxy. You may also have built and exposed a service that is used as an upstream service by another software. The worst way to perform health check is to pull a resource (like GET /hc.html, if your service is exposed as a HTTP service) or perform a TCP connect check in the same port where data is served . These are checks I call as in-band health checks .  Please don't do these. Based on my experience, the best way to expose health checks is by using an out-of-band mechanism. This means that you expose another port for performing health check. The client can perform a HTTP check or TCP check in the health check port. As a convenience, if you expose health check as HTTP service in health check port, you can consolidate multiple health checks like: GET /he

TIL: Keeping parent directory structure while copying

There had been instances when I wanted to copy "/home/roy" to a target directory "/target" as "/target/home/roy". I used to do some scripting foo to get this done. A few days back, I learned this cool option called "--parents" in cp command that will preserve the parent directory structure while copying. Made my life a lot easier on one of my backup tasks.

Today I Learned (TIL)

Today I Learned (TIL) is a series of posts that contain bit sized information that I learned and found to be worthy of sharing with others and keep as a note to myself. For the last couple of years, I had been devoting most of my time in building the start-up, Zycada Networks , that I co-founded. It makes me happy to share my knowledge. So I would like to get back to the habit of writing blog posts regularly on interesting stories, tips-and-tricks, new ideas, technology trends, etc. TIL is one part of doing it.

TIL: Sort human friendly values

Sorting numeric values in the input is easy. It just takes "sort -n". But what if the input contains human friendly units. For intance, "5G", "3M", "4K", etc. There is a flag to recognize and sort based on the human friendly units: "-h". Incorrect: du -h | sort -nr Correct: du -h | sort -rh Caveat: "sort -h" works only on upper-case units. "K" will be treated as kilos, but "k" will not be!

Aligning text in emacs

Aligning text like a table is often a useful task. I use this workflow to make the text tidier. For instance when I have two columns of text of varying width, aligning them makes it easier to read. Steps: 1) Select the region you would like to align (C-x h will select the entire buffer) 2) C-u M-x align Thats it. The selected region would have been aligned based on the first line of the region. Example: Before: what? who? hello      world After: what? who? hello world By default only the space is used as a delimiter. If you would like to perform a little sophisticated alignment, you can make use of the align-regex function. city, population new york, 8.49M san francisco, 0.85M

Bit twiddling in JDK to generate random number

Image
Some time back a friend asked me an algorithm question: Given an integer random number generator randomN() that can generate random number in the range [0, N), how will you generate random numbers in the range [0, M) where M I used modulo arithmetic to generate the desired random numbers in the range [0, M). And I reasoned out that if N = q*M + r, every number in the range [0, r] has an occurrence probability of (q+1)/N, but the numbers in the range [r+1, M) has an occurrence probability of only q/N. It is easy to visualize this. See the diagram below: You can see that we can divide line of length N units (given in green) by lines of length M units (given in black). When N is not exactly divisible by M, in the last part alone we have only r units. So if we choose a random integer in the line represented in green, and then take a modulo M on the value, all the values except the values in the range [r+1, M) (represented in red) will occur q+1 times. But the values in that int