Where is Faiz?

Chat

Hey guys! It has almost been a year since I last updated this website. I guess I got busy with stuff but I wanted to provide a quick professional update.

In August 2020, I moved from Santa Clara, CA to Seattle, WA. I decided to leave NetApp and join Facebook as a production engineer. It was a conscious decision to leave California because I wanted to explore a new place and also meet new people in the process. The world is huge and there are so many things to checkout and experience! It was a bit tricky though because I moved in the middle of the COVID pandemic and therefore, it was harder to meet new people and make friends. But I think I did a decent job on that in spite of COVID.

Since moving to Seattle, I got to hike a bunch, go camping, and even go to Alaska to see the lights! Although, TBH, the lights were a bit of a disappointment. Maybe I’ll create a separate post on that. Anyway, I finally got to live in a high-rise building with a good view in downtown Seattle. I like my new apartment.

Working for Facebook has been nice so far. Although, I do sometimes feel that the work-life balance can be improved. Maybe that is also something in my control but I am currently not doing a good job on that. Something to work on! Because of COVID, I haven’t yet been able to go to the office and only working remotely. I am not particularly a big fan of work from home but it is what it is for now and hopefully the offices open soon.

Anyway, till my next post, you all take care and stay safe!

Sexism, misogyny, and prejudice against women

Chat

This post is going to be a relatively long reflection against all the sexism, misogyny, and male supremacy prevalent in our society today.
*******************************************************************
A wife stays back at home while her husband goes to work to earn a living for the house. The husband works at the office while the wife stays back making and keeping the house up and running. She is happy doing that.

Another scenario is that a wife and her husband both go to the office. The wife gets pregnant and discontinues her work while her husband continues his usual office routine. The wife would remain out of the office for several months and in many cases, by her own will, never going back to work again.

In both the above scenarios, the wife can be happy doing that. And there is absolutely nothing wrong in that either. But, for a moment, picture the opposite scenario. The wife gives birth to a child and the husband goes on an extended paternity leave feeding the child from the bottle full of mother’s breast milk. The husband in this situation should be equally willing and happy as the wife would have been staying back in the house taking care of the baby, no?
*******************************************************************
The parents are worried for their daughter who is already 30 and not married. They fear she might not get any suitable matches.

The parents are tiny-miny worried about their son who is 30 and not married. But they are okay with that, at least for a few more years. They don’t yet fear that their son might not get any suitable matches.
*******************************************************************
The husband once in a blue moon hits his wife. And he profusely apologizes after that. He is truly and deeply sorry for his actions. He knows that he made a mistake. The wife forgives him only to find herself in a situation a few years later when the episode gets repeated. She swallows her anger and “forgives” her husband after he profusely and sincerely apologizes, yet again. She doesn’t want to break her marriage. She is concerned about her daughter, her family, and what the society would think of them.
*******************************************************************
A husband forces himself on the wife assuming that it is his right to do so being her husband. The woman wants to resist but doesn’t because in her head, this is possibly normal.
*******************************************************************
A wife cooks all the food while the husband sits in the drawing room talking to the guests and keeping them entertained. The wife doesn’t find anything wrong in it since she saw her mother doing the exact same thing. She doesn’t resist this setup and has not a shred of doubt in her head that this is normal.
*******************************************************************
A wife picks up all the utensils after she and her husband are done eating dinner. She saw her mother, aunties, and her grandmother doing the same. And, of course, they can’t all possibly be wrong. She accepts this and continues picking up and cleaning the utensils every night after dinner.
*******************************************************************
The parents have a son and a daughter. The son wants to go abroad for further education. The parents are happy and they will try their best to afford that education for their son. A few years later their daughter wants to do the same. This time the parents hesitate a bit. They do want to support their daughter as well but they are not as confident about it. “She’ll turn 30 by the time she is done with her education. She might also get over qualified to be able to find a suitable groom later. ” is what they might ponder upon amongst other things.
*******************************************************************
There are so many other examples that I can write in this already lengthy post. There is nothing that most of us reading this don’t already know in their conscious or subconscious mind. It is sexist if you give any kind of preferential treatment to your son as against your daughter. It is wrong to expect your wife to do all the household chores while you “earn a living” for the house. It is wrong to expect your wife to give up on her career while you go on to achieve “big things” professionally banking on your wife to support you throughout and be content with your professional success when in fact she might have wanted to do all those things for herself as well. It is sexist if you don’t help clean up the dining table after you are done eating food. It is a crime if you think that your wife is your property with whom you can “make love” to anytime you want. It is sexist if you assume that all women are bad drivers. It is a crime if you pay your male employee more than your female employee for the same position. It is wrong if you boast about not knowing how to cook food but expect your wife to be a great cook. These are just a few cases in point that are simply unacceptable but our society more often than not accepts without questions. And if you do question, you risk being considered a social outcast.

This patriarchy is not just limited to India (although, I’ll argue that it is more pervasive in India). And if you consider domestic violence as well, you can find several examples in the so-called socially developed western and European nations. Shakira, Madonna, Rihanna, Marilyn Monroe, Halle Berry and so many others were victims of domestic violence. And while I am not arguing that it is only the women who suffer in all such cases because there are examples of men being mentally and physically abused as well, the stats show that women are the overwhelming majority who are at the receiving end of such extremities of domestic violence.

I believe that in most cases all the subconscious biases start developing from an early age. The society that you grow up in, observing how women and men get treated leaves a deep impression in your mind. That said, I do also believe that as one grows up, they can change their thought process and alter their subconscious by reading more, keeping an open and flexible mind, and just applying more common sense (which I understand is hard for some people). There is an Indian movie called “Thappad” where a woman files for a divorce when her husband “just slaps” her at a party. In the moment of that one slap she realizes all the things that were not right in her married life and how blindly and happily she was ignoring that. I am not going to spoil the movie for anyone. The movie is streaming on Amazon Prime and I would urge everyone to watch it. I don’t think that there is anything shown in the movie that we do not already know but it might serve as a good reminder to both the women and the men about what they ignore as being normal when, in fact, the real normal couldn’t be far from it.

If you are here I am glad that you read the entire post. I will end this with a quote from an American actor, John Wayne. He said, and I quote:

“Women have the right to work wherever they want, as long as they have the dinner ready when you get home.”

That, my friend, is the crux of the problem we are still facing today and unless everyone doesn’t take a stand in their own personal lives, acknowledge the prejudice and the wrongs against the women, and make a sincere effort to fix it, nothing will change.

quote by Alix Kates Shulman

Figure 1. A quote by Alix Kates Shulman

Source: https://www.azquotes.com/quote/1175444

Why complain?

Chat

“……Nothing is never gonna be perfect. There is always gonna be a problem……Moral of the story is why complain? I kept doing what I kept doing and I got better at what I kept doing and I beat you all. Complaining isn’t really gonna get you nowhere but where you are now……”

-Ronnie Coleman

Part 1: Understanding Crypto Currencies and Blockchain for Newbies (5-7 minute read)

Chat

Note: This is only part 1 of the series “Understanding crypto currencies and blockchain for newbies”. I intend to make a part 2 as well where I’ll dive into the details of crypto currencies and what is blockchain. But before I do that I felt it was necessary to do a recap on what currency or money really means. Without clearly understanding how currency works, it might not make sense why crypto currencies exist or how do they work and what advantages and disadvantages do they hold.

Below is a 5-7 minute read. I have intentionally kept it brief but if you want more details on something, please refer to the references section at the end of the article or just leave a comment and I’ll try to answer as best as I can.

Let us now dive into part 1 of this series.

Before any form of currency existed, people used to exchange goods or services for other goods or services they needed. For example, assume that person A has plenty of rice while person B has plenty of fish. Person A is ready to let go of 2 kilograms of rice in exchange for 1 kilogram of fish from person B. This way of exchanging goods or services is also called a bartering system.

bartering system

Figure 1. Bartering system

Source: https://historyplex.com/barter-services-history-of-barter-system

The bartering system has its own disadvantages[1] – there is a need for people to be willing to buy the product that you want to sell. If I want to exchange fish for rice, first I need to be able to find someone who has rice and wants fish. Another major problem of the barter system is the difficulty in storing and transporting the goods to exchange. For all these and several other reasons, it was important to have some form of a common currency that could solve these problems.

According to sources[2] [3], the earliest known form of currency can be dated back to almost 5,000 years. It was called “The Mesopotamian shekel”, which, in physical form, consisted of how heavy a precious metal like gold or silver weighed. Similar forms of coinage were discovered in Europe, Asia, Africa, and other parts of the world suggesting that coinage system was indeed considered as a medium of commodity money to buy goods and services. These kind of currencies are called Representative Money that are backed by a physical commodity like gold. An example of Representative Money was the US dollar until 1971 when President Nixon decided to abandon the gold standard[4] according to which 1 ounce of gold was then worth US $35. Representative Money is not affected by inflation and the governments could only print enough money for the amount of gold they had in reserve.

Representative Money has its own disadvantages that are beyond the scope of this article. Fiat Money[5] is what replaced Representative Money and all the countries in the world now use Fiat Money. Fiat Money does not hold any value by itself. Instead, it holds value since the government of a country puts a value to it and backs it up. This also means that Fiat Money is susceptible to inflation and might lose its value in case of an unstable government or if the economy of a country collapses.

An interesting question that I used to think about is this – why can’t the government just print as much money as it wants in exchange for goods or just to give it to the poor people? The answer isn’t straightforward but in simplistic terms, a government can and should print only so much money as it needs. If there is more than needed money printed then the cost of all the goods and services will also go up, which effectively means that the value of the currency would go down. The demand and supply need to be in balance otherwise the over supply of currency can lead to hyperinflation – something that happened to Zimbabwe in 2007 that ultimately made them change their currency to the US dollar[6].

fiat currency

Figure 2. Fiat Money only has value because the governments assign a value to it

Source: https://www.investopedia.com/articles/investing/092413/how-currency-works.asp

Another interesting question is who controls this Fiat Money and decides how much to print? In the USA, it is the responsibility of the Federal Reserve to take care of it. Similar organizations in other countries like the RBI in India decide how much currency to print and regulate its flow. This is based on lots of factors like the interest rates, fiscal deficits, exports, etc. that are beyond the scope of this article.

So, next time you hold a $100 bill, think about what you really own. What is the actual value of the piece of paper that you have in your hand and what can you buy with it today vs. 10 years from now? Some food for thought 🙂

References:

  1. de MIRAMON, J., 1983. Advantages and Disadvantages of Countertrade. J. Comp. Bus. & Cap. Market L., 5, p.347.
  2. Chapurukha Kusimba, smithsonian.com 2017. “Making Cents of Currency’s Ancient Rise”. https://www.smithsonianmag.com/history/making-cents-currencys-ancient-rise-180963776/. [Online; accessed 11-Nov-2019].
  3. worldhistory.biz, 2015. “Mesopotamian Money and Weights”. https://www.worldhistory.biz/ancient-history/71590-mesopotamian-money-and-weights.html. [Online; accessed 11-Nov-2019].
  4. history.com, 2019. “FDR takes United States off gold standard”. https://www.history.com/this-day-in-history/fdr-takes-united-states-off-gold-standard. [Online; accessed 11-Nov-2019].
  5. Jason Hall 2017. “Fiat Currency: What It Is and Why It’s Better Than a Gold Standard”. https://www.fool.com/investing/general/2015/12/06/fiat-currency-what-it-is-and-why-its-better-than-a.aspx. [Online; accessed 11-Nov-2019].
  6. Tejvan Pettinger 2017. “Hyper Inflation in Zimbabwe”. https://www.economicshelp.org/blog/390/inflation/hyper-inflation-in-zimbabwe/. [Online; accessed 11-Nov-2019].

Gym routine

Chat

Hello people!

So I was following a gym routine for some time that I would like to share. I wouldn’t say it’s for beginners but if you have been working out for a while and want to change it up, this is a decent routine. It assumes that you workout 4 days a week and the routine alternates between 1 week of building endurance and 1 week of heavy lifting.

Without further ado, below is the routine that also mentions the source it was taken from. But please remember, being fit is roughly about 70% what you eat and 30% how much you workout.

Good luck!

What is depression?

Chat

Q: I see it happening all around us that as we grow older, depression becomes a natural emotion within all of us, and takes a toll on human beings. How do we adjust to this situation which is inevitable and happening all the time?

Sadhguru: Once you declare that depression is a natural process, there is no way out. When you were a child, being joyful was natural to you, not being depressed. So do not declare that depression is natural. Depression means you are unable to maintain the exuberance of life in you. It happens even in your body. If you are depressed, even the physical body flops. Life within you is not exuberant – it has just gone down and lost its exuberance because you are not doing the right thing with it. You are imposing too much outside nonsense upon the inside. You have not done anything to keep your life energies high.

The Source of Depression

Depression is a kind of agony. If you have become agony and not ecstasy, it is because a large part of your life energy is happening compulsively, not consciously. It is happening as a reaction to external situations. Once you are happening compulsively, becoming depressed is very normal, because external situations are never hundred percent in your control. There are so many things happening in the world; if you compulsively react, getting lost and becoming miserable is natural. The more exposed you are to life, the more miserable you will become.

Depression means you are unable to maintain the exuberance of life in you.

When people are unable to handle life outside, they try to curtail their life and withdraw. But even that goes out of control, doesn’t it? There is one part of you which is constantly seeking expansion – you want to constantly increase the boundaries and areas of your activity. There is another part of you which is getting depressed every time something does not go the way you think it should go. Getting depressed is subject to the non-fulfillment of your expectations.

If the stock market gets depressed today, so many people will get depressed. Many of them may never have even touched that money, but every day they were watching the graphs rising and their mood was in ascendancy. Now they see the graph falling, so their mood is falling. It is just that what they expected to happen, did not happen.

Fixing the Inside

People can cause depression in their mood in so many ways. If you take away what they think is precious, they become depressed. The tragedy with a lot of people, especially in affluent societies, is that they have everything and yet they have nothing. Depression means somewhere, a certain hopelessness has set in. If you go to some very poor village in India, they are really impoverished, but you will see joyful faces because they have hope – it is going to be better tomorrow. In affluent societies that hope is gone. Depression has set in because everything that can be used externally has been fixed. There is food, there is housing, there is clothing, there is everything, but still there is something wrong. They just do not know what.

A poor man may think, “Tomorrow, if I get a new pair of footwear, everything will be fine.” If he gets a new pair of footwear, he will walk like a king with great joy on his face because he has hope; the outside is not yet fixed. In affluent societies, the outside is fixed, but the inside is not fixed, so there is hopelessness and depression.

As we work on the outside, we must also fix the inside. Then the world would be beautiful. What we call as a spiritual process is just this – not just fixing the objective aspect of your life but taking care of the subjectivity of who you are. If that is not taken care of, you will have everything, and you will have nothing.

Source: https://isha.sadhguru.org/us/en/wisdom/article/solution-for-depression-from-inside-out

Mental strength

Chat

Many people out there forget how important mental strength is. If you don’t believe you can do something then you won’t…simple as that. If you can visualize yourself being successful and gain confidence through training and hard work…you will succeed!

-Brian Shaw

LRU Cache

Chat

I had heard a lot about this interview question from people but honestly, I never studied it in school. Maybe I skipped one of those classes that talk about it 🙂

LRU stands for least recently used (add cache to that, it becomes LRU cache. But LRU could be of anything like LRU disk, LRU threads, etc.). When an interviewer asks you this design question (I consider it as a design question), they are not expecting you to explain how caching works and what cache is but are in fact looking for an algorithmic solution to the LRU problem.

So what do we mean by LRU? Suppose you have two cats of ages 1 and 2 and you are asked to let go of the one that’s older – you let go of the second cat. What did we do here? We compared the ages of the two cats and only kept the one that was younger. Something similar happens with LRU design questions. We want to keep X (could be cache, drives, threads, etc.) but when we run out of capacity, we have to let got of something and this something is decided based on what was not used in recent times.

fstab file

Fig 1. High-level LRU working
Source: http://katrinaeg.com/lru-cache.html

How do we maintain the least recently used items? One way is to maintain something like a hashmap of ages and based on what is oldest, we remove it. But what would be the time complexity of this solution? We will have to traverse the entire map to find the oldest age and thus, it would take O(n) time. See HERE for this solution.

Can we do better? Turns out we can if we maintain a doubly linked list (DLL). The oldest item would always remain at the back of the list while the youngest at the front. In this way, we can delete an item in O(1) time. Whenever we access an element from the list, we push it to the front since it then becomes the most recently used item.

A doubly linked list solution in C++ should ideally not use pointers if you are using STL. But if you still want to write your own doubly linked list, HERE is a solution. But if you want to use STL, take a look at THIS.

To surmise, LRU implementation is a popular interview question and not that hard to grasp the concept of it. Give yourself a few hours and see if you fully understand what LRU demands and ways of designing it.

Feel free to leave comments if you have any questions.

Hadoop on containers

Chat

I have started working on a project to make Hadoop/Spark run effectively in a containerized environment. And while microservices like a web server are well suited to run in a container (being stateless), running any big data technology like Hadoop/Spark/Kafka can be a challenge thanks to their need of being stateful (opposite of what containers provide). There are some workarounds available and I have written a one-page report that takes no more than 2-3 minutes to read providing a brief, high-level overview. If you have any questions, please leave a comment and I’ll try to address them.

Monitors: An Operating System Structuring Concept

Chat

While re-visiting to recall the differences between Semaphores and Monitors, I came across one of my OS class homework where I had written a summary on Monitors. So I thought I may as well blog about it.

Paper: Monitors: An Operating System Structuring Concept

Author: C. A. R. Hoare

Date: 1974

What is it about?

  1. One of the major problems in building an operating system is to allow sharing of computer installations among different processes that may make unpredictable demands upon its resources. The paper attempts to address this issue by introducing the concepts of “signal” and “wait”.
  2. Creating resource allocation algorithms for different kinds of resources can be a challenge for a developer. There wasn’t an easy way to construct separate schdeulers for each class of resource. The paper introduces the concept of monitors that attempts to solve this issue.
  3. The paper also talks about the problem where multiple processes are trying to access the same resource and what can be done to prevent this race condition.
  4. The author has built upon the work done in the paper “Proof of correctness of data representations. Acta Informatica” by Hoare.

Some key contributions

  1. The paper talks about monitors – a synchronization structure. A monitor is a class like structure that contains data and functions. One significant property of monitors is that only one program may be executing a monitor procedure at any given point in time.
  2. The paper demonstrates the usefulness of monitors in structuring operating system designs. Monitors provide an effective way to enforce synchronization of processes (like critical sections).
  3. It also introduces the concept of condition variables. The condition variables stop one process to acquire resources being used by another process. It creates a queue of processes waiting in line to acquire the resource.
  4. “Signal” and “wait” operations are also introduced in the paper. Like the name suggests, “signal” means resume the execution of a process waiting in the queue, while “wait” is used to cause a delay in the execution of a process.
  5. How to implement semaphores using monitors is also described in the paper. Monitors are powerful like semaphores but provide a higher level of abstraction by providing data and code encapsulation.
  6. Introduce a new type of variable called “condition” for cases where there may be more than one reason for waiting and they need to be distinguished by both the waiting and the signalling operation.

Experimental methodology

  1. The paper talks about how semaphores can be implemented using monitors and vice-a-versa. They also provide a proof that the monitor condition concepts are not any less powerful than semaphores and that they can be used for all the same purposes.
  2. The paper makes some good suggestions towards the end and one of them is “Never seek to make an optimal decision; merely seek to avoid persistently pessimal decisions.” This observation calls for the need of good scheduling algorithms and the paper presents one.

The above is only a high-level summary and doesn’t contain all the details mentioned in the paper. For a thorough review, please go through the entire paper. If you have any questions, feel free to leave a comment.

Happy reading!