Friday, July 23, 2021

Sitting in the cafe, I just dropped my coffee cup and it broke down into the floor. Then I automatically pressed "Undo" button in the code editor.

How to choose business interview to watch - look at the position of the person being interviewed

 So if we would like to become a CEO, we search YouTube for "interview with CEO".

If we would like to create our own startup and become a founder, we search YouTube for "Interview with a founder"

Thursday, July 22, 2021

Strategy

Body posture
In soccer, we use our body to protect a ball. During war, we hold the position and defend it. So often defense is the best way of attack. Don't try to intrude. Just hold your position and let the enemy get tired.

Attack
As per Chinese generals, the battle is to be won before the battle. Planning is everything. The battle itself is just a formality to realize the plan.




Friday, July 16, 2021

Standards of future community (country)

Intro

One day I will create my own community (country, city or whatever). It will eliminate all the disadvantages current societies have. The following standards should be met:

Ecology

Saving our planet means saving our grandchildren. We don't want our descendants to be ugly mutants suffering from radiation.

Clean air

Polluting the air should be prohibited. Fire in any form will be allowed only in extraordinary cases. The best way to reduce CO2 exhaust is to stop producing it. For now, IMHO 95% of fires are to serve redundant people needs, which are not necessary to survive. 2020 covid pandemic proved tha tgovernments can easily force people to abstain from pleasure and other activities not necessary for survival. Of course, social needs, rest etc should be satisfied, but again, it could be done without fire.

Most food can be cooked without fire. Moreover, raw food is even more healthier than cooked (boiled, fried etc) ones.


Politics

Responsibility

The best way to hold politician responsible is to force him to live with his voters. Most politicians live in expensive houses behind the high fence and security guard. Politicians should live in apartments, or even better hostels with the poorest people of the country (which are the majority). So then the politician could hold a direct contact with the majority of his voters. Politician should eat in the shared kitchen with voters, 3 times a day, 365 days a year. Not once a year for TV camera like thy do now.

He can still be paid much, he deserves high salary and high pension for his work. However, he should not be allowed to live far from ordinary people, otherwise he will lose contact with them.







Wednesday, July 14, 2021

How to set up a solar panel

Intro

Here I will document my own learning is solar setup. I will update this post as I learn more.
I don't distinguish the way of panels use: whether on a vehicle, on a building or just separately. The main accent is of how to combine three main components: a panel, a controller and an invertor.

Choosing equipment

Criteria for any type of equipment:
Find certain brand on Amazon, and check:
- average reviews rating
- number of reviews
- the price (whether the current store overprices a lot)

How to choose a solar panel

Temperature Coefficient

The lower the better.

Warranty

Warranty of 25 years is usually provided by manufacturers. No warranty is a bad sign.

Monocrystalline vs Polycrystalline

Mono is more efficient and hence more expensive per square. So if we have much square space like on the building roof, we can use poly. Or, if we have less space like on the vehicle roof, we can use mono.

Brands

Panasonic
LG
Renogy

How to choose a battery

Criteria

Safety. Some batteries are toxic when charging or discharging. It is fine to keep a AGM/GEL/LiFePO4)
 battery in a living space.
Warranty. It should be.
Temperature range.
Maintenance.
Price.
Review rating on Amazon.

Types of batteries

Flood lead acid (or wet cell) batteries

They take lots of space, need regular maintenance. Disadvantage when we have a lack of space like in the vehicle (unlike a building). Charge slow. Trademarks: Trojan.

Sealed Lead Acid (AGM) batteries

Resistant to cold, easier to maintain. Trademarks: ExpertPower, Renogy, Universal, Mighty Max, WindyNation.

Gel Batteries

Great both for extreme heat and cold. Resistant to physical damage. Charge fast.

Lithium-Ion (LiFePO4) batteries

Best for solar. No maintenance required for about 15 years. Charge fast. Doesn't take much space. Easy to install.  Trademarks: Renogy. 

How to choose a controller

Ampers of the controller = next available value not less than (total watts of solar panels divided by voltage of the battery).
PWM or MPPT
150,200,250,600 V
Manual and auto EQ
Built in GFP and arc fault
Online status monitoring
Hyper VOC extend VOC limits
12-72 volt battery charging
Solar, wind and hydro MPPT modes
Brands:
Zamp

How to choose an invertor

Wattage of the inverter should be as total wattage of solar panels. 

Installation

Cover with a blanket

Cover the solar panels with a heavy blanket so that no sunlight is reaching the panels. This is important so that when we connect the wiring we don’t burn out the charge controller or any of the other electronic devices. Only uncover the solar panels once we are finished setting up the entire solar system and have all of the electronic cables in their proper position.

Stacks
We can multiply power by using stackable batteries and solar panels.



Thursday, July 1, 2021

Ethno Drum Fest - Kharkiv

Freedom is the most important need

Humanistic theory of Abraham Maslow listed basic human needs including socialization and self-actualization. However, it missed IMHO the most important human need: freedom. I believe in the modern society it is most important and most non-satisfied.

1000 years ago people were slaves of each other. Today, nothing changed. Children are slaves of parents at the young age. At least in the morning and in the evening. During the day, they are slaves at school. Then they become adults and fall into slavery of employers. At night, they are slaves for spouses.

Society and government consider all these institutes as normal (schools, jobs, marriage). It is logical because government per se was created as a form of slave owner. However, here we come to oxymoron and can catch government with its logic: apart from death penalty, the most serious sentence for a crime is imprisonment, i. e. restriction of freedom. In the prison, a man has everything he needs to be happy as per Abraham Maslow: food, social friends, ability for self-actualization etc. Still, imprisonment is the hardest penalty because of lack of freedom.

Today, we are all addicts of money. We sell our souls into slavery for money. We are though to do that. In the childhood, parents teach to study well to find a good job, to find good spouse etc. False and fake. Don't forget the Sermon on the Mount (Matthew 5-7):

No one can serve two masters, for either he will hate the one and love the other, or he will be devoted to the one and despise the other. You cannot serve God and money.

Sometimes I think up a joke and then loudly laugh at my own joke. Is it normal ?

Monday, June 28, 2021

Never pay to the university for the education!

Here I describe my own experience. I believe it could be useful because it cuts the common stereotypes of software engineering science studying. There are a lot of myths people believe in. Current study curve in schools and universities is defective. It kicks out and demotivate large percentage of people who could become a talented coders.

School and university is not to teach. It is an institute to filter people out. University filters students at the entrance to get only those with high intelligence. No university accepts students without tests/recommendations/school marks etc. Then, during the studying process, university filters students via its own tests and marks. At the end, only talented graduate, so the university is proudly saying how great it is. In fact, it is not the university which is great. Students are great, university is not. The only great thing about the university is it is a great filter. And maybe networking parties.

University does not provide teaching process with more value than YouTube and Google. All the scientific information in 21st century is available for free on the Internet and in public libraries. Teachers at university know less than e. g. stackoverflow or other public forums. The only difference is price. In the US students could pay $100,000 per year in the university unlike $500 (or even less) for Internet provider. Difference is 200 times. Why should we pay more? Or our parents? Even if government subsidizes study process this money could be spent in more efficient way. E. g. to feed poor and sick people, resolve ecology problems, decrease taxes etc.

What is much worse: in many countries military service is compulsory, at least for males. And stupid government thinks that: 

  • 1) People must serve in military (to allow government to protect kill more). Even in well-developed countries like the US, though military service is not compulsory, it is highly encouraged by giving subsidies to veterans for free university education, immigration benefits etc.
  • 2) Universities are useful, thus military duty is waived for those studying at university. The most useless and harmless waiver resulting in widespread corruption and harm for economics.

As per my estimation, only 1% of coders apply algorithms theory in daily work. At the same time this is the basic and main course in the university program. Even worse, many employers test applicants by giving them algorithms tasks. And after the job offer the engineer is surprised that he should do absolutely different type of job..



Emerging markets: good for startups and new ideas

Firebase functions - tips and tricks

Functions emulator

Start emulator:

    firebase emulators:start

Stop emulator:

    sudo lsof -i tcp:<port> 

    kill -9 <process id>

    close the localhost webpage

    close the terminal window

Deploy to production

    firebase deploy --only functions

Debug

In the function body, we can log the performance:

    functions.logger.log("tag", "some text", original);

or:

    console.log("tag", "some text"); 

Then we can see logs in the Emulator supra:

It is so valuable, logs how certain code line in the functions file, e. g. on the screenshot above we see "index.js:49".

Also, logs are at the Firebase Console if functions are deployed to production:

Get data

Official Firebase manual provides sample code for trigger functions. In the function, we might need to get data of the certain document the function is called for.

exports.respondToRequest = functions.firestore
    .document('requests/{requestId}')
    .onUpdate((change, context) => {
              const requestUpdated = change.after.data();
              const requestPrevious = change.before.data();
              const respondedUpdated = requestUpdated.responded;
              const respondedPrevious = requestPrevious.responded;
              const topic = context.params.requestId;

          }
        );

I emphasize here two main parameters: "change" and "context". So "change" is to get values of the document fields. Context is to get id of the document only. E. g. if we log output of change and context:

              console.log("change data is:", change.after.data());
              console.log("context data is:", context.params);

We can get the full set of data available to be extracted:

        07:17:42
        function[us-central1-respondToRequest]
        change data is: { description: 'first request', responded: true }
        07:17:42
        function[us-central1-respondToRequest]
        context data is: { requestId: 'HBQ7cRYAT5yliHdWNnpc' }

Sunday, June 27, 2021

Decision taking, making choices

Intro

Often stress is caused by overwhelming of tasks. It is difficult to prioritize them, it is difficult to resolve them simultaneously. They attack us like a pride of predators, biting from multiple sides.

Or, we could have a one task with multiple choices. And it is difficult to choose the right one. We are afraid to make a mistake. What should we do then?

Whatever solution we take, it is always convenient to structure mind by documenting everything in the spreadsheet or mind map.

Possible solutions

"Minimax" strategy

In mathematics, there is a thing called game theory. It is used in computer algorithms when our electronic enemies in Starcraft make their decisions. 

"Minimax" is for minimizing maximum loss. First we define a maximum possible loss for every problem if it is not resolved timely. Then we sort problems by this maximum loss in descending order. Then we concentrate on the first one (with the greatest loss possible).

E. g. we see simultaneously falling from the table down to the floor the following:

- a bottle of milk

- a spoon

- a little baby

Which one would we catch first, letting others to break down on the floor?

Let the problem resolve themselves

Some problems can be postponed if they are not urgent. Surprisingly, many of them are resolved by themselves after a while. Or we just realize we don't need to resolve them.

Delegate

If another man can repair my car cheaply, I better pay to him. 

Intuition

What our God tells to us? Do not neglect intuition - sometimes it is the only instrument we have.

Make the first step and wait

Often the way is unpredictable and step on a road depend on each other. There is no need to spend time on thinking about every step if some of them could become redundant.

E. g. the problem is the car won't start. And we don't know the certain reason behind that. The process is we check possible failures step by step. First, we check whether battery is dead: try to start the car with the jump starter. If the reason is battery, we will lose our time thinking beforehand about all the other failure.



Loosing yourself - thoughts about relationship and depending on other people and organizations...

God gave us a mission and he is waiting for us to complete it. However, instead of being slaves of God we voluntary become slaves of other people and organizations: parents, spouses, employers, governments etc.

We are afraid of being hungry and slave for an employer.

We are afraid of being lonely and slave for a spouse.

We are afraid of being prosecuted and slave for a government.

In fact there should be only one fear: fear of God. If we are not afraid of God - we don't believe in him. God is the strongest power in this world. If we have God, we have no fear for everything else.

By becoming slaves of somebody else, we lose ourselves. We lose our life mission, we don't want to hear internal voice of intuition. We close our heart.

Saturday, June 19, 2021

Applying Sermon on the Mount to startups.. Money is not important..

Sermon on the Mount for startup founders

I believe Sermon on the Mount (Matthew 5-7) is the best study book for startup founders mindset. Surprisingly enough, I find more and more confirmations of its validity in lives of the world's greatest people.

Do not store up for yourselves treasures on earth, where moths and vermin destroy, and where thieves break in and steal. But store up for yourselves treasures in heaven, where moths and vermin do not destroy, and where thieves do not break in and steal. For where your treasure is, there your heart will be also.
You are the salt of the earth. But if the salt loses its saltiness, how can it be made salty again? It is no longer good for anything, except to be thrown out and trampled underfoot.
...
You are the light of the world. A town built on a hill cannot be hidden. Neither do people light a lamp and put it under a bowl. Instead they put it on its stand, and it gives light to everyone in the house. In the same way, let your light shine before others, that they may see your good deeds and glorify your Father in heaven.
...
No one can serve two masters. Either you will hate the one and love the other, or you will be devoted to the one and despise the other. You cannot serve both God and money
... 
Therefore I tell you, do not worry about your life, what you will eat or drink; or about your body, what you will wear. Is not life more than food, and the body more than clothes? Look at the birds of the air; they do not sow or reap or store away in barns, and yet your heavenly Father feeds them. Are you not much more valuable than they? Can any one of you by worrying add a single hour to your life?
...
And why do you worry about clothes? See how the flowers of the field grow. They do not labor or spin. Yet I tell you that not even Solomon in all his splendor was dressed like one of these. If that is how God clothes the grass of the field, which is here today and tomorrow is thrown into the fire, will he not much more clothe you—you of little faith? So do not worry, saying, ‘What shall we eat?’ or ‘What shall we drink?’ or ‘What shall we wear?’ For the pagans run after all these things, and your heavenly Father knows that you need them. But seek first his kingdom and his righteousness, and all these things will be given to you as well. Therefore do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.
...
Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. For everyone who asks receives; the one who seeks finds; and to the one who knocks, the door will be opened.
...
Enter through the narrow gate. For wide is the gate and broad is the road that leads to destruction, and many enter through it. But small is the gate and narrow the road that leads to life, and only a few find it.
...
Therefore everyone who hears these words of mine and puts them into practice is like a wise man who built his house on the rock. The rain came down, the streams rose, and the winds blew and beat against that house; yet it did not fall, because it had its foundation on the rock.  But everyone who hears these words of mine and does not put them into practice is like a foolish man who built his house on sand. The rain came down, the streams rose, and the winds blew and beat against that house, and it fell with a great crash.
Sermon on the Mount, Matthew 5-7

Life mission makes us happy

Life is about the process. There is no need to run for the result: eventually everybody have the same result: death. So it makes sense to live just to be happy. This is about the process, not about the result. However, there is a tricky dual connection: we are happy with the process when it directs us to the right result (right goal) perspective. We are happy when we are moving to the right direction, even though not achieved it yet. The most admirable goal is life mission.

What makes us happy most? Apart from short term regular daily needs and pleasures there is some kind of long-term happiness. It is love. While love is usually referred to some feeling between sexes, I prefer another kind of love. The best love we could have is the love to our life mission. John Kennedy once met a janitor mopping up the floor at NASA. Kennedy asked what is he doing. The janitor responded, “I’m helping send a man to the moon.” The janitor is a happy man because he has a life mission. Once we find a mission, we can become happy also.

You are the salt of the earth. But if the salt loses its saltiness, how can it be made salty again? (Sermon on the Mount)

Once we find our mission to change the world, nothing else matters. I can sleep in the garage and eat expired food leftovers if I am on the way to my life mission. If I have no mission, the most luxurious apartments and the most expensive food will not make me happy.

World greatest people don't care about money

Grigory Perelman, a Russian mathematician turned down a million dollar prize from the mathematician society. Knowing the secret of universe is more important for him than money.

In 2006, Yahoo offered Mark to sell Facebook for $1 billion. This sounds like Zillion. Mark famously responded to his investors: 

This is kind of a formality, just a quick board meeting, it shouldn't take more than 10 minutes. We're obviously not going to sell here.

Later Mark and his wife pledged to donate 99 percent of their Facebook shares to charity fund.

Do not store up for yourselves treasures on earth, where moths and vermin destroy, and where thieves break in and steal. But store up for yourselves treasures in heaven, where moths and vermin do not destroy, and where thieves do not break in and steal. For where your treasure is, there your heart will be also. (Sermon on the Mount)

Today Mark's net worth is about $120 billion.

Steve turned down prestigious Reed College diploma. Then he slept on the floor in his friends' room. Later he traveled to India and became homeless there. His famous quote is: 

Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked.

Therefore I tell you, do not worry about your life, what you will eat or drink; or about your body, what you will wear. Is not life more than food, and the body more than clothes? Look at the birds of the air; they do not sow or reap or store away in barns, and yet your heavenly Father feeds them. Are you not much more valuable than they? Can any one of you by worrying add a single hour to your life? (Sermon on the Mount)

First time in Silicon Valley was not luxurious for Elon. He slept on the couch in the office with his brother. They took shower in the local fitness club.

And why do you worry about clothes? See how the flowers of the field grow. They do not labor or spin. Yet I tell you that not even Solomon in all his splendor was dressed like one of these. If that is how God clothes the grass of the field, which is here today and tomorrow is thrown into the fire, will he not much more clothe you—you of little faith? So do not worry, saying, ‘What shall we eat?’ or ‘What shall we drink?’ or ‘What shall we wear?’ For the pagans run after all these things, and your heavenly Father knows that you need them. But seek first his kingdom and his righteousness, and all these things will be given to you as well. Therefore do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own. (Sermon on the Mount)

There is something more important than money

There are many followers in every religion. However only small percentage of them really believe in God. Those who believe, are really happy. They don't need money, they don't care about problems of the current life.

No one can serve two masters. Either you will hate the one and love the other, or you will be devoted to the one and despise the other. You cannot serve both God and money. (Sermon on the Mount)

There are many startup founders who apply for investments. However only small percentage of them are ready to work 12 hours a day for 2 years, no salary, no weekends, sleeping on the floor, eating twice a day. Only those have life mission. Mission is more valuable than money and other pleasures. Mission is life, life is mission. Life is what we exchange for mission, mission is exchanged for life. Life is more valuable than money. Life is more valuable than anything else.

Therefore everyone who hears these words of mine and puts them into practice is like a wise man who built his house on the rock. The rain came down, the streams rose, and the winds blew and beat against that house; yet it did not fall, because it had its foundation on the rock.  But everyone who hears these words of mine and does not put them into practice is like a foolish man who built his house on sand. The rain came down, the streams rose, and the winds blew and beat against that house, and it fell with a great crash. (Sermon on the Mount)

Let's interpret Jesus's words: money is a sand whilst life mission is a rock.

Psychiatrists would call this schizophrenia. If Jesus would visit psychiatrist, he would be diagnosed with a hardest form of schizophrenia and involuntary hospitalized. Well, better I have schizophrenia rather than being an ordinary person, living ordinary life and dying like everybody else. So nobody except for grandchildren remember me.

The best illustration ever is provided in Matrix (1999):

- What are you trying to tell me? That I can dodge bullets?
- No, Neo. I'm trying to tell you that when you're ready, you won't have to.

Will good startup founder easily get an investment? No. When he is ready, he doesn't have to.

Most reasonable people would like to get highly paid job to sustain a comfort level of life. However, let's ask an average reasonable person the following question: 

You can get indefinite life (so you can live for thousands of years). Or: you can get $1 billion, but then you will die like everybody else in within this century. What would you choose? 

I bet most regular people choose indefinite life. The trick is everybody wants it, however nobody knows that everybody already has it. Everybody just thinks they live only once. And this life is all they have.

Don't waste lifetime

Good time management books start with identifying the whole life goal (unlike micro-managing daily tasks). They suggest to ask yourself the following questions:
- What would I do if I die in one week?
- What would I want to be written on my graveyard?
- What would I would if I would have one billion of dollars?
- What job I can do for free?

Steve asked himself the similar question:

For the past 33 years, I have looked in the mirror every morning and asked myself: “If today were the last day of my life, would I want to do what I am about to do today?” And whenever the answer has been “No” for too many days in a row, I know I need to change something.

And his even more important words are:

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma — which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary...
... Stay Hungry. Stay Foolish.

I believe Steve and time management experts would agree with the Bible "Parable of the Talents", in Matthew 25:14–30. Master gave to slaves talents (money). Then he punished the slave who didn't get any profit from the talents. And he admired the slave who put talents into business, used them efficiently and came back with double amount.

For it will be like a man going on a journey, who called his servants and entrusted to them his property. To one he gave five talents, to another two, to another one, to each according to his ability. Then he went away. He who had received the five talents went at once and traded with them, and he made five talents more. So also he who had the two talents made two talents more. But he who had received the one talent went and dug in the ground and hid his master's money. Now after a long time the master of those servants came and settled accounts with them. And he who had received the five talents came forward, bringing five talents more, saying, ‘Master, you delivered to me five talents; here, I have made five talents more.’ His master said to him, ‘Well done, good and faithful servant. You have been faithful over a little; I will set you over much. Enter into the joy of your master.’ And he also who had the two talents came forward, saying, ‘Master, you delivered to me two talents; here, I have made two talents more.’ His master said to him, ‘Well done, good and faithful servant. You have been faithful over a little; I will set you over much. Enter into the joy of your master.’ He also who had received the one talent came forward, saying, ‘Master, I knew you to be a hard man, reaping where you did not sow, and gathering where you scattered no seed, so I was afraid, and I went and hid your talent in the ground. Here, you have what is yours.’ But his master answered him, ‘You wicked and slothful servant! You knew that I reap where I have not sown and gather where I scattered no seed? Then you ought to have invested my money with the bankers, and at my coming I should have received what was my own with interest. So take the talent from him and give it to him who has the ten talents. For to everyone who has will more be given, and he will have an abundance. But from the one who has not, even what he has will be taken away. And cast the worthless servant into the outer darkness. In that place there will be weeping and gnashing of teeth.’

Master is God. Talents are lifetime and other gifts given to us by God: skills, connections, ideas, chances, dreams etc. If we waste talents, most importantly the lifetime as a talent, we are bad slaves. That's why Steve worried that he is moving to wrong direction when his lifetime is limited. Wasting the time is a sin in front of God. Spending time on life mission is admirable by God.

Every morning we wake up. The first thing we notice is we are alive. That means, God gave us one additional day on purpose. Don't waste this day.

The happiness of belonging to life mission destroys the fear of being poor and homeless till the end of the life. Because life mission gives something more than money.

Fear of God

Since God assigned us lifetime for a purpose, we should have fear of wasting it. We should have fear of God. We should be afraid of God's anger. God is a boss who helps us to fulfill his mission and who punishes us if we deny to obey.

There is no power greater than God. Hence, we should be afraid of nothing but God. Americans say:

Don't tell God how big your problems are. Tell your problems how big your God is.

The best illustration by artists is in the "Indiana Jones and the Last Crusade" (1989):

How to find life mission?

Steve clearly answers this question supra:

... have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary...

We see strong connection between "courage" and "your heart" in the same phrase. Heart shows us the way to the life mission. To see this way, we need a courage. Courage is needed when we have fear. Thus, I dare to say: fear shows us the way of the heart. Every time we have fear - it is a signal of the right way. We need to follow our fears and overcome them.

E. g. we see some injustice and would like to oppose it. However injustice is committed by a stronger person and we feel fear to oppose. That means we are on the right way. Another example: say we have highly paid office job and great carrier perspective. However we hate what we do. Our dream is say to become an artist, but an artist at the starting point is not paid at all. We have a fear of becoming poor if we follow our dream. Nevertheless, fear shows us the right way.

Enter through the narrow gate. For wide is the gate and broad is the road that leads to destruction, and many enter through it. But small is the gate and narrow the road that leads to life, and only a few find it. (Sermon on the Mount)

We never know the destination point assigned to us by God. However we need to trust our heart to get there. As Steve explains:

...you can’t connect the dots looking forward; you can only connect them looking backward. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life...

If nothing helps, a prayer is a great way to get answers. We think we talk to ourselves. However, it is God who talks to us.

Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. For everyone who asks receives; the one who seeks finds; and to the one who knocks, the door will be opened.

Have we ever cried while reading or watching something? A tear is a clear indicator of the proper way.

Thursday, June 17, 2021

Jared Friedman - the most exciting guy in YC

Key disadvantage of the school system

School teaches children anything but creativity. Ability for creativity and innovation is a key for motivation to get new knowledge. Innovation is the best pool for spending energy of youth. I stead, students spend energy on disorderly conduct because they are absolutely not motivated to study. 

Wednesday, June 16, 2021

Git tips and tricks

0_Unsorted_

See status of the repository:

    git status

See status in certain directory:

    git status <path to directory>

See status in the current directory:

    git status .

Branching

0_Unsorted_

Jumps to another branch:

    git checkout <branch name>

Rename branch:

    git branch -m <old name> <new name>

See what branches are in your repository:

    git branch

Create

Creates new branch and jumps to it:

    git checkout -b <branch name>

Create a branch from mainline:

    git branch <new branch name> mainline

Create a branch from a specific commit:

    git branch <new branch name> <commit name>

Remote repository branches

To create a branch in the remote repository, need to explicitly push (the -u sets local branch to track the remote branch):

    git push -u origin <local branch name>:<new remote branch name>

Push the newly created local branch to repository:

    git push -u origin <local branch name>

Delete

Delete a local branch:

    git branch -d <branch to delete>

Delete a remote branch. When you delete a remote branch, you are in effect, pushing a null commit to the server.

    git push origin :<branch to delete> 

    git push origin --delete <branch to delete>

Merge

Merge changes from one branch into another

    git merge <branch to merge from> 

Resolve the conflict

    Open the file and make any necessary changes

    Use the git add a command to stage the new merged content

    Create a new commit with the help of the git commit command

    Git will create a new merge commit to finalize the merge

Hardcoded Red Neck Way for Resolving Conflicts

    After the merge, the worse thing git does is it makes changes in the file per se. So it is easy to mess up everything. Paying attention to that git adds additional comments to the file. Sometimes after resolving the merge nothing works. Debug fails because the new "resolved" file looks like neither of the 2 previous. Moreover, it can contain new errors for debug. 

    Let's say we have conflicts only on one or two files. Than it is easy to hardcode the merge conflict. Say the conflict in the file is between its previous version A and version B. Say we know that we want to keep version A because we are sure that it works stable. Then we just copy and paste all the version A file to the separate folder on a disk out of the git control and call it copyOfVersionA. We can get that version A from one of previous commits (git checkout <commit_name>). 

    After git flags a merge, we just replace the current file in the local repository with the copyOfVersionA that we created earlier. Then add and commit. Merge is resolved.

Abort in case of disaster

    git merge --abort

We can always go back to the safe state with this command.

Cherry-pick 

This is to transfer commits between branches. To transfer commits made at another branch: Cherry picking in git means to choose a commit from one branch and apply it onto another. Make sure you are on the branch you want to apply the commit to.

    git checkout <branch-to-apply-commit-to>

    git cherry-pick <commit-hash>

Abort cherry-pick in case of disaster:

    git cherry-pick --abort

Commit

Make a commit

    git commit -m "<description>"

Temporary switch to another commit

    git checkout commit_hash

Switch back to the latest commit in the branch

    [or] git checkout [branchname]

Difference

Differences between branches:

    git diff <branch1>..<branch2>

Differences between a remote branch called origin/mainline, and the local mainline branch:

    git diff origin/mainline..mainline

Changes between two commits:

    git diff <commit1> <commit2>

Changes in certain commit

    git show <commit>   

Staged changes diff

    git diff --all

Show names of changed files, status (deletion/removal), number of lines changed:

    git diff --stat

Show only names of changed files and addition/deletion status:

    git diff --name-status

Show only names of changed files and addition/deletion status

    git diff --summary

Show only names of changed files

    git diff --name-only

Ignore temporary files

1. Go to package folder

2. vim .git/info/exclude

3. In the end of the file, write: *~

The same mask can be applied for other types of files

Log

See a history of the commits on the current branch

    git log

See also difference for every commit listed

    git log -patch (or git log -p)

See only latest number of commits

    git log -<number of commits to be listed> git log -3

See graph of branches

    git log --graph

Reset

Delete everything uncommitted

    git reset --hard

Abandons uncommitted changes of certain file to last commit

    git checkout -- <file_name>

Remove the last commit and delete all of the changes to the files intact

    git reset --hard HEAD~1

Remove the last commit but leave all the changes

    git reset --soft HEAD~1

Monday, June 14, 2021

How to find idea for the startup as per Y-Combinator

Y-Combinator has a great schools for startups. The problem for a startup is easy to find. We just need to solve the customers' problem. In the present world, number of problems is huge, and these number is growing. Many of the problems are not solved yet. Or they are solved in not proper way (like ecology e. g.)

As per Y-Combinator, the following are types of problems that could result in a successful startup:

  • Popular
  • Growing
  • Urgent
  • Expensive
  • Mandatory
  • Frequent

Sunday, June 13, 2021

Self-regulation of temperature

Heat.. How to become colder when it is warm..

Find any organization with air conditioner like library store etc.

Find a canopy or shadow.

Water is the great source to become cooler. Merely swimming and sitting in the water helps a lot. If we have only bottled water, it is useful to soak clothes with that. Then put on wet clothes, they will serve as a coolant longer than if we just spray this water on a naked body. Clothes dry longer, especially those made of particular kinds of fabric like jeans e. g.

Underground and basement. Soil provides great insulation against high temperature. 

Cold.. How to get warmer when it is cold outside..

Find any organization where interior temperature is high enough - library, store etc.
Put on all the clothes we have.
Stretch. I don't know how it works, but stretching helps to make body temperature higher. Simple stretching for 5 minutes works fine: kiss your knees etc.
Push-ups and squats. Don't take care about people opinion around. Body temperature is more important.
Running. Good to combine with some useful goal - like running to the store etc.
Snow. In the extreme conditions like if we are alone in the wild forest we need to use extreme means to become warmer. While snow per se is cold, it provides a great temperature insulation. Northern people make igloo of snow and ice. Igloo is very warm inside. We can try to make something like that faster, by merely digging a hole (a cave) in the existing snow pile. Meanwhile, digging is also physical exercise, it per se makes us warmer in the process of doing it.


Saturday, June 12, 2021

Blogger tips and tricks

How to paste code in Blogger

I mean how to paste the code so it looks nice. On the Internet, guys advise to use <code> tags, other special tags and even to install some add-ons or scripts. In addition to all these ways, here is one more trick. Copy the code and paste it in any file in any file of the current code editor project. E. g. for me it is Android Studio or Intellij. Then, copy it from the code editor and paste in the Blogger post by simple Ctrl+V (not by pasting as a plain text). This way it will save formatting of the original. So finally we will get something like that:

Firebase.messaging.token.addOnCompleteListener(OnCompleteListener { task ->
if (!task.isSuccessful) {
Log.w(TAG, "Fetching FCM registration token failed", task.exception)
return@OnCompleteListener
}
val token = task.result
})

In the end, do not forget to delete the buffered code from the code editor.


Friday, June 11, 2021

...

When somebody asks a question, the question contents per se is least important. Instead, we firstly need to think about (or ask the other person):

- why this question was asked?

- is this question proper?

When talking, the best position is asking questions instead of providing the information.

Keytool and Keystore tips and tricks

When releasing or debugging the app, Google often yells at us regarding the improper SHA-1 keys. Here are some tricks for accessing keys via the keytool program. Keytool is the software by Oracle for creatin and accessing SHA-1 keys. If the keys are generated via Android Studio, the keytool cannot apply the previous initial password to access them because Android Studio assigns its own password to the keystore.

Default password for the keytool program (that is eventually used for keys generation and storing them) is "changeit". Default password that Android Gradle assigns to the keystore is "android".

To see the current keys, run 

    ./gradlew signingreport 

from the project's folder. It will show keys, their aliases and storage path e. g. /home/oleg/.android/debug.keystore.

To change the key password, go in the terminal to the storage of the keys that is listed in the above ./gradlew signingreport as "Store". Than run 

    keytool -storepasswd -keystore debug.keystore 

and follow the instructions. As an old (current) password we can write "changeit" or "android" supra.

Wednesday, June 9, 2021

MVP - the minimum viable product - necessary for startup

Books recommended by Max Levchin

Full interview of Max to Carnegie Mellon University is here

  • Influence: Science and Practice by Robert Cialdini
  • Contagious: Why Things Catch On by Jonah Berger
  • Predictably Irrational by Dan Ariely


If I follow my life mission, God helps me. So I don't care about anything else. So the proper question is not what to do with the problem. Rather it is how to find my life mission?

Empirical principles of human efficiency

Scientists do not create laws of nature. Instead, they open them. That means, laws of nature existed, exist and will exist independently of us and our knowledge about them.

Similar should be applicable to laws of human nature. God created a human. We didn't create ourselves. We can just reproduce our genes by making children. However without artificial (and often non-successful) intrusion into DNA we cannot change our genome in the short term.

Laws of human nature affect all the aspects of our life - success, relationship, happiness etc. What are they?


Firebase database model - tips for querying

0_Unsorted_

Storage, documents and collections

Let's distinguish all the terms in three groups: storage, documents and collections.
Storage is the mostly memory consuming part of database. Any data submitted by the user is stored in the storage. Whether it is text, picture or geo location. In the code, we don't call the storage directly. Instead, we use documents to reference it.
Documents present hash maps to reference the storage. Hash map is needed because the document has multiple fields and each field should have a reference to the value.
Collections are merely tags to combine documents into groups. So if we would not have collections initially, we could easily create them. For that, just create a new "collection" field in the document and place there some collection name. So all the documents with that value will be combined into the same collection group. 
That's why we cannot create subcollection inside of the collection. We can create subcollection only inside of the document. Because the document can easily reference anything in its hash, whether it is value in storage, name of the collection etc. Collection cannot reference anything because the collection per se is merely the name of the tag which is referenced by the document.
For the same reason, multiple documents in the same collection (though it would be proper to say "of the same collection") can contain different fields with different types of values. Collection does not restrict the document. Instead, it just places a marker on the document, it marks the document with some kind of tag and nothing else.
Say we have multiple dogs in the yard. Some of them are white and some are not. Our task is to call all the white dogs and gather them for a walk to the park. In a regular database, dogs don't want to listen to our commands. So we need to build up a crate called "table of white dogs" and lock all the white dogs into that crate. So we don't need to spend time for searching for dogs of particular color.
In NoSQL database like Firebase, dogs are smarter and they can listen to our commands. Every white dog has a "white" tag on its collar. Instead of being locked and crowded in the crate, they can freely walk in any free area of the yard. When we need them, we just call "white dogs come here!". And all the white dogs run with us for a walk to the park.

Difference between retrieving and referencing

The database distinguishes retrieving operation from reverencing it. Retrieving means actually getting data by calling the remote server and retrieving real values of records. Unlike retrieving, referencing operation does not call the Firebase server. It just saved address of data into certain variable. That variable can be used in the future for actual retrieving. For the purposes of this post, I consider adding data under the retrieving section also, because adding data actually connects to the database, not merely creating a reference.
So in terms of postal office, referencing is like writing an address on an envelope. And retrieving is actually mailing an envelope and getting a response.

Retrieving

Add data to Firestore collection

Credits to native Firebase manual
val cities = db.collection("cities")

val data1 = hashMapOf(
       
"name" to "San Francisco",
       
"state" to "CA",
       
"country" to "USA",
       
"capital" to false,
       
"population" to 860000,
       
"regions" to listOf("west_coast", "norcal")
)
cities
.document("SF").set(data1)

Retrieve filtered collection

Credits to native Firebase manual.

db.collection("cities")
       
.whereEqualTo("capital", true)
       
.get()
       
.addOnSuccessListener { documents ->
           
for (document in documents) {
               
Log.d(TAG, "${document.id} => ${document.data}")
           
}
       
}
       
.addOnFailureListener { exception ->
           
Log.w(TAG, "Error getting documents: ", exception)
       
}

Retrieve document and its field values

The trick is we need to use addOnSuccessListener to retrieve the field value. So retrieving from the remote database is launched in separate flow. Then, if we want to use this value right in the next line of code, it could raise a null error if the value didn't come from the database yet.
Possible solutions are the following:
1) Place the next line of code (where we use the value to be retrieved) right inside the brackets of the onSuccessListener flow:
request.get()
.addOnSuccessListener { documentSnapshot ->
val userCreatedId = documentSnapshot.get("user_created_id") as String
request.update(mapOf(
user_responded_idLabel to currentUser?.uid
)
)
}

2) Store data offline beforehand. E. g. if the major part of the app is working around the same request, it makes sense to create an offline hash of the request object as soon as possible, in the beginning of the user session. Then just don't forget to update the hash if the request fields values change.

3) The best practices option. Operate with objects (instances of classes) values and periodically sync them with database. Kind of ORM (object relational mapping) - work with classes and objects instead of database tables and records.

Referencing

Reference filtered collection

Credits to native Firebase manual.

citiesRef.whereNotEqualTo("capital", false)

Reference certain document

First way to reference the document:
val alovelaceDocumentRef = db.collection("users").document("alovelace")
Another way to reference the document:
val alovelaceDocumentRef = db.document("users/alovelace")

Re





Tuesday, June 8, 2021

While I am completely dissatisfied with the Airbnb service as a customer, its story as a startup and interviews with its founders is a good lesson for others..

Hearing impairment as a result of earwax

In no way under the health label I post professional medical advice. Instead, only my own experience is there, that can be useful for myself only.

Possible reasons of hearing impairment

Swimming in the dirty river water

Probably, earwax absorbs dirty water and becomes puffed. That results in ears clogged. Water in the natural reservoir (river, lake) makes other surfaces sticky. It contains silt and sludge which are oily. If we swim in the water without washing head afterwards, hairs become very sticky. I assume the same happens with the earwax in our ears.

Fasting

Probably there is more intensive production of earwax during fasting. Maybe because of toxins excretion etc I don't know..
Wearing earbuds for a long time
Earbuds create isolated space and skin sweats inside. So the earwax becomes wet and puffed.

Earwax is pushed towards Eardrum

To prevent any problems with ears, never use cotton swabs or any other sticks go clean  them. Two adverse outcomes are:
- Earwax is pushed towards eardrum. Hearing will be impaired and it would be more difficult to take it out.
- Eardrum will be damaged. That will take a lot of time to heal. Doctor's help might be needed.

Solutions and treatment

Visit the doctor

Only doctor can diagnose the damaged eardrum which is more serious problem.

Use hydrogen peroxide

Instead, to clean ears use simple and cheap hydrogen peroxide. Drip it into the ear and turn the head perpendicular for 10-20 minutes. There will be a noise of hissing - that means hydrogen peroxide does it's work. It might need multiple days to repeat this process once or twice a day to completely dissolve the earwax.

Monday, June 7, 2021

How to implement sign-in via Google account with Firebase at the Android app

Google and Firebase manuals are not ideal and sometimes even contradicting. So I met some obstacles trying to implement simple sign in process with Google via the Firebase at the Android app. Some of problems are described here.

Finally, nuclear solution worked for me, so I needed to recreate the Firebase project. Here is the consequence of steps that worked:

  1. Delete and recreate values at the local computer storage
    1. Delete SHA-1 key at the local keystore and generate new debug SHA-1 via new build.
    2. Rename the package via refactoring, e. g. from com.example.myproject to com.example.mynewproject. Clear some leftovers remaining after refactoring by searching old name "com.example.myproject" in the project files and manually renaming them. Package name is the same essential as SHA-1 for Google Cloud and Firebase consoles. So these consoles don't allow to use old SHA-1 keys from the old deleted projects. Neither might they allow to use old project names which are unique for the particular app I guess.
  2. Delete and recreate projects in the cloud
    1. Delete cloud projects:
      1. Delete Firebase project and verify in the Firebase console that there no active projects yet.
      2. Delete Google Cloud project. Verify at the consequent console that there are no active projects listed. Often Google Cloud is deleted automatically after deleting the Firebase project.
    2. Recreate cloud projects:

      1. At the Firebase console, create new project.
      2. At the Google Cloud Console, nothing is needed to be done. Despite that Firebase manual cross references to Google manual directing us to create new Google Cloud app, we don't need to do this. Because later it will be created automatically by Firebase.
      3. In the created Firebase project create an Android app, pass there new package name and new SHA-1 key that were created at the previous steps.
      4. In the Google Cloud Console, see that Firebase automatically created Cloud project with the same name as was passed to Firebase. Then confirm that two of OAuth 2.0 Client IDs were automatically created there by Firebase.
  1. Final changes on local:
      1. From the Firebase console, download new google-services.json file and delete old file at the local machine which similarly named in the app folder.
      2. In the Google Cloud Console, copy client id labelled "Web application" (not "Android") and hardcode it in the local app code:

                                val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)

                                .requestIdToken(getString(R.string.default_web_client_id_hardcoded))

For the code itself, this is the only part where we can rely on Google and Firebase official manuals. Here is an example of Google sign in fragment that works with the settings listed above:

package com.exa.mynewproject.login

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.exa.mynewproject.R
import com.exa.mynewproject.list.ListNonRespondedActivity
import com.exa.mynewproject.unsorted.Global.Companion.TAG
import com.exa.mynewproject.unsorted.Global.Companion.toastString
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.SignInButton
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.Task
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.auth.GoogleAuthProvider
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase

private const val RC_SIGN_IN = 100

class GoogleSignInFragment : Fragment(){
    lateinit var auth: FirebaseAuth
    var googleSignInClient: GoogleSignInClient? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id_hardcoded))
            .requestEmail()
            .build()
        googleSignInClient = this.activity?.let { GoogleSignIn.getClient(it, gso) }
        auth = Firebase.auth
    }
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
            val view = inflater.inflate(R.layout.fragment_google_sign_in, container, false)
            val signInButton: SignInButton = view.findViewById<View>(R.id.sign_in_button) as SignInButton
            signInButton.setOnClickListener {
            signIn()
        }
        signInButton.setSize(SignInButton.SIZE_STANDARD)
        return view
    }
    override fun onStart() {
        super.onStart()
        val currentUser = auth.currentUser
        updateUI(currentUser)
    }
    private fun signIn() {
        val signInIntent = googleSignInClient?.signInIntent
        startActivityForResult(signInIntent, RC_SIGN_IN)
    }
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == RC_SIGN_IN) {
            val task = GoogleSignIn.getSignedInAccountFromIntent(data)
            handleSignInResult(task)
        }
    }
    private fun firebaseAuthWithGoogle(idToken: String) {
        val credential = GoogleAuthProvider.getCredential(idToken, null)
        this.activity?.let {
            auth.signInWithCredential(credential)
                .addOnCompleteListener(it) { task ->
                    if (task.isSuccessful) {
                        Log.i(TAG, "signInWithCredential:success")
                        val user = auth.currentUser
                        updateUI(user)
                    } else {
                        Log.i(TAG, "signInWithCredential:failure", task.exception)
                        updateUI(null)
                    }
                }
        }
    }
    private fun updateUI(model: FirebaseUser?){
        val signInStatus = if (model == null) getString(R.string.user_not_signed) else
            getString(R.string.welcome) + model.displayName
            toastString(signInStatus)
        if (model != null) {
            val intent = Intent(this.activity, ListNonRespondedActivity::class.java)
            startActivity(intent)
        }
    }
    private fun handleSignInResult(task: Task<GoogleSignInAccount>) {
        try {
            val account = task.getResult(ApiException::class.java)!!
            Log.d(TAG, "firebaseAuthWithGoogle:" + account.id)
            firebaseAuthWithGoogle(account.idToken!!)
        } catch (e: ApiException) {
            Log.w(TAG, "Google sign in failed", e)
            updateUI(null)
        }
    }
}