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

How to make a choice. How to take a decision.

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?

What could happen in the worst case scenario? Let's make a choice with the less harm in case of worst scenario.

MiniMax is a mathematical term from so called games theory. When having multiple choices, each of them has possible loss ("minimum"). So we merely minimize the risk by choosing "maximum of minimums", taking the option with less harmful loss.

Maximin

Opposite to minimax. Instead of minimizing losses, we maximize outcomes.

Intuition

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

Option for return

If the choice is wrong, is there way to return back? Is this expensive? If we can easily return, it makes sense to make an attempt.

Make the first step and wait

Often the way is unpredictable and step on a road depend on the other factors. 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.

Visualize every option

For every choice, just imagine we already made it happened. Do we like it?

Exclude components (what if?)

If we think too much about that some factor is an obstacle to make a choice... What if there would not be such factor at all? Would we make a choice or not?

Say we don't want to move to another country because language barrier seems like an obstacle for this move. What would be if we would know such language perfectly? Would we move to this country immediately or there is some other reason preventing us from making this choice?

Count long term perspective

Preferable is the option resulting in long term dividends. It is better for me to study engineering at school rather than say cooking skills. In the future, robots constructed by engineers will cook food for us. Though for someone else cooking can bring long term benefits.

What would my favorite super hero do if he would be me? 

Or my favorite politician? Or any other person I respect much? 

Minimize regrets by your 80s

What would I regret about when I am in my 80s?

Give it a time

Wait - maybe the solution will come later. The more we wait the more information we have. Today we might not be willing to do the same as yesterday. Thus, if we have a recurring reminder in our mind for a long period of time - maybe it's time to do it.

Review the list of all the possible outcomes 

...

Collect information 

Google, ask for an advice etc

Go to your fear

People say, huge resource is there. Even if the decision is eventually wrong, huge learning is here.

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

Remove the last commit from the remote repository (i. e. github), undo last push (if the last push consisted of one commit):

    git push -f origin HEAD^:master

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 for Android app

Intro

Keystore is literally the storage for the keys. The keys are to sign the app either for debug or for production release. See also the official docs from Android here

Keys for Android app could be generated internally via Android Studio (which is more convenient) or externally via the Oracle keytool program.

There are three different keys: debug key, upload key and app signing key 

Yep, there is such a mess with all those keys. Let's go through them.

Debug key

As per the official Android docs

When running or debugging your project from the IDE, Android Studio automatically signs your app with a debug certificate generated by the Android SDK tools. The first time you run or debug your project in Android Studio, the IDE automatically creates the debug keystore and certificate in $HOME/.android/debug.keystore, and sets the keystore and key passwords.

When the app is built for the first time, Android Studio generates the key. Thus, if we build the app from another machine, new different key will be generated. This could become a problem because the new key should be synced with Firebase and Google Cloud.

Also, docs provide:

Because the debug certificate is created by the build tools and is insecure by design, most app stores (including the Google Play Store) do not accept apps signed with a debug certificate for publishing.

That means we can't use the debug key as an upload key or app signing key for publishing the new release of the app.

How to see the current debug key

From the Android Studio

In Android Studio, open Gradle window: View -> Tool Windows -> Gradle. Or in the main menu choose Help -> Find Action -> type "Gradle". 

In the Gradle window, in the top left corner press the button "Execute Gradle Task", this button looks like an elephant. Type there:

gradle signingreport

and press Enter.

Go to the Run window: View -> Tool Windows -> Run, or press Alt+4.

We should see something like

> Task :app:signingReport

Variant: debug

Config: debug

Store: /home/liker777/.android/debug.keystore

Alias: AndroidDebugKey

MD5: [censored]

SHA1: [censored]

SHA-256: [censored]

Valid until: Wednesday, June 23, 2049

----------

Variant: release

Config: none

----------

Variant: debugAndroidTest

Config: debug

Store: /home/liker777/.android/debug.keystore

Alias: AndroidDebugKey

MD5: [censored]

SHA1: [censored]

SHA-256: [censored]

Valid until: Wednesday, June 23, 2049

----------

From the terminal

In the terminal, run 

./gradlew signingreport 

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

How to recreate the debug key



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 FIrestore - tips and tricks

0_Unsorted_

Hereinafter code examples are in Kotlin (not Java).

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 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

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) Retrieve data to custom object. There are 2 notes here:

- The object class should be with "data prefix"
- Official manual suggests us to use "toObject<Class>" function, however the compiler yells with an error. Instead, we use toObject(MyClassName::class.java) even though MyClassName is defined as Kotlin class.. See also this stackoverflow answer.
None of the following functions can be called with the arguments supplied: 
public open fun <T : Any!> toObject(p0: Class<TypeVariable(T)!>): TypeVariable(T)? defined in com.google.firebase.firestore.DocumentSnapshot
So the working code is as follows:
data class Request(
val id: String? = null,
val description: String? = null,
val user_created_id: String? = null,
val user_responded_id: String? = null,
val status: String? = null
)

val docRef = Request.COLLECTION_REFERENCE.document("hDsbP2yW4jIC40mUE13z")
docRef.get().addOnSuccessListener { documentSnapshot ->
val request = documentSnapshot.toObject(
Request::class.java)
}

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")

Async, coroutines, await etc

await() is not recognized

If await() keyword is not recognized, importing the following library could help:

implementation 'com.google.android.gms:play-services-tasks:9.6.1'


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.
    3. 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)
        }
    }
}

Venkat Subramaniam - the cool guy with cool lectures about software engineering

How to make sure the van/truck is secure during van dwelling

This information is mostly for Eastern countries (former USSR) though many options are applicable everywhere. Security is split in to parts: day and night

Security during the day

During the day, the main risk is theft. Following are some ideas of how to prevent it.

Insurance

Almost 100 percent assurance is given by an insurance. However, when travelling in the foreign country, insurance companies often wouldn't sell their plans to foreign plates cars. Even if they would, comprehensive insurance is extremely much more expensive in comparison with the regular insurance. This is in Eastern countries (former USSR) unlike the US. Nevertheless, if possible it is always better to have the comprehensive insurance rather than not to have it. It is better to choose big and long standing insurance company because small companies are known to disappear from the market on a regular basis.

Steering wheel locker

There is already built in steering wheel locker in the most of 21 century cars. In addition to this, we can buy a $20 external steering wheel locker, which is easy to setup in 1 minute.

Choosing parking space

Unlike the stereotypes, store parking lot is not the most secure place for parking. Instead, we can park the car close to police station.

Security during the night

In general, at night the van is more secure because someone is inside of it. I mean someone is sleeping inside. I mean I am sleeping inside..

Thus, merely theft is not possible without notifying me about it. So the only option for the criminal is forcible theft I. e. assault. So the criminal needs to forcibly kick me out of the truck to take my truck. Assault is much more serious crime than a theft, thus penalty for this felony is extremely serious and hard in most countries of the world.  Hence, this risk is much lower than the risk of theft.

Nevertheless, nothing is impossible. So there are still some ideas to prevent the bad from happening.

Turn on white lights

Most trucks have white lights on the back of the cabin, on the rear bumper. They can be turned on for the whole night. So everyone knows that someone is inside of the car. Though these lights consume less power than the front regular lights, we still need to take care of the car battery. Setup solar or have a jumpstarter in the xarin case the battery drains during the night and in the morning we will not be able to drive.



Thursday, June 3, 2021

Can I set up a rack on the roof of my truck?

So my roof is divided into 2 parts: metal roof of the cabin and roof of the fiberglass camper. Can I setup a rack there to store my stuff or to install solar panels? Like a rack for ladders that van owners do.

Heat gun - cool machine for arts with plastics

Wednesday, June 2, 2021

Huge natural resources are free

 Water in the world ocean, air in the atmosphere, fish in the ocean, ice at the North, information on the Internet etc..

Great perspectives for entrepreneurship.

Need to take care of ecology though..

Science and tech news - better to watch rather than political stuff..

Tuesday, June 1, 2021

There are still some areas with low competition

These areas are considered as of high tech and thus are of a low competition. Such as space, crypto (development, not just trade) etc.

Should I travel to Asia, China and Japan especially?

These countries are one of the leaders in business and technology. Moreover, the unique culture is very interesting there.. Can we hitchhiking there? Van dwelling? Living in the hotel?

Tar soap - that stuff should resolve problem with allergy and dandruff after head wash..

Treat, tread, treath...

Tricky words differ just by 1 letter. And that changes the whole meaning of the word in English. Moreover, many of these words sound identically.

Start of the word / End of the wordtdth
ttreattreadtreath
ddreatdreaddreath
ththreatthread