Useful ReactJS, NodeJS,Architecture,Programming Tutorials, videos, links

AirBnB ReactJS front-end Performance Fixes

React Performance Fixes on Airbnb Listing Pages, AirBnb worked hard to improve performance of their listing pages, Thanks to their TechBlog which has covered extensive, detailed explanation regarding how they have improved the performance

Reference Link: React Performance Fixes on Airbnb Listing Pages

System Design Resources

System design is a key to any highly scalable, Large scale Softwares, which deals with Entire System Architecture that focus on Performance, scalability, security, stability of the system. Here are few important resource references

Facebook Video Broadcasting: under-the-hood-broadcasting-live-video-to-millions

Netflix Video Encoding at Scale: high-quality-video-encoding-at-scale

Netflix Workflow Orchestration for Microservices: Netflix-Conductor

Practical System Design

YouTube Architecture: youtube-architecture

YouTube scalability 2012: Youtube-Scalability

Distributed Design Patterns: Scalable-system-design-patterns

Circuit Breaker Algorithm: Handling failures in Backend to Backend calls

Uber Rate Limiter: RateLimit

Intra-Service Messaging

AirBnb Idempotency: avoiding-double-payments-in-a-distributed-payments-system

And Many more useful resources are given in below github link

https://github.com/InterviewReady/system-design-resources

Resolving Duplicate class error in React Native Android while integrating Native Modules

What is a Duplicate Class issue?

React native has evolved so much that you will really get helpful docs on external packages for most of the things. But there are some corner cases for which we do not find the npm modules to integrate. In those cases, we have to integrate SDK/package in the native side and then write a bridging code in order to call it from React-Native JS code.
  As your project grows and as you start integrating the new SDKs you will somewhere end up with this issue, “Duplicate class” in android. Basically, this issue says this module is already included in one of the SDK and the new SDK we are including also has the same modules and same classes and its a run time java error
  I was so panicked about this issue since I had got a big list of duplicate class issues as you see in the below image and error text below.

Java.lang.RuntimeException: Duplicate class 

com.google.android.gms.dynamite.descriptors.com.google.android.gms.vision.dynamite.face.ModuleDescriptor found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzca found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar 

(com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzcb found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)

  Duplicate class com.google.android.gms.internal.vision.zzcc found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzcd found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzce found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzci found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzcj found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzck found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar 

(com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzcl found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzcm found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.internal.vision.zzl found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-20.1.3-runtime.jar (com.google.android.gms:play-services-vision:20.1.3)


  Duplicate class com.google.android.gms.vision.face.ChimeraNativeBaseFaceDetectorCreator found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.vision.face.FaceDetectorV2Jni found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)


  Duplicate class com.google.android.gms.vision.face.NativeFaceDetectorImpl found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)

Solution for Duplicate Class Error in React Native

Do not worry about the big error message, basically, everything is a single issue but android is making us complicated in presenting. The solution to this issue is very simple but you need to understand the issue properly. Without understanding the issue and just trying with StackOverflow and Github answers it took about a week to fix this.
You will find plenty of the answers in GitHub and StackOverflow for this issue and, they are correct, but they have not elaborated the answer and think that people from the android background can solve this easily. But if you do not know much about the android part then please have a look at this solution.
For integrating a new SDK I got so many duplicate class issues as my project was big and had already many SDKs. In my list of Duplicate class issues, ALl issues are the same but for different modules. I will just one and explain about it.

Duplicate class com.google.android.gms.dynamite.descriptors.com.google.android.gms.vision.dynamite.face.ModuleDescriptor found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar (com.google.firebase:firebase-ml-vision-face-model:17.0.2) and jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)

So error says that there is a duplicate class in these two modules
Module1: com.google.android.gms.dynamite.descriptors.com.google.android.gms.vision.dynamite.face.ModuleDescriptor found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar(com.google.firebase:firebase-ml-vision-face-model:17.0.2)
Module 2:
jetified-play-services-vision-face-contour-internal-16.1.0-runtime.jar (com.google.android.gms:play-services-vision-face-contour-internal:16.1.0)

https://github.com/react-native-camera/react-native-camera/issues/3031#issuecomment-732135774

https://stackoverflow.com/questions/58808875/how-to-resolve-duplicate-class-exception-caused-by-com-google-firebasefirebase

As per the answers I found from Github, We need the exclude one of the groups and module from one of the modules and remember not both of them.

implementation platform('com.google.firebase:firebase-bom:26.1.0'){
exclude group: 'com.google.android.gms'
}

The hardest part for me with an issue I found was identifying which one is a module and which one is a group. That’s why it took me a week to find the solution. If you know which one is module and group then it just works with one shot.
Now we know that out of two modules we need to exclude only one module and not both. Considering the first module out of two.
com.google.android.gms.dynamite.descriptors.com.google.android.gms.vision.dynamite.face.ModuleDescriptor found in modules jetified-firebase-ml-vision-face-model-17.0.2-runtime.jar(com.google.firebase:firebase-ml-vision-face-model:17.0.2)
In this part we need to identify module and the group to exclude,
Now consider only this part com.google.firebase:firebase-ml-vision-face-model:17.0.2
Module: com.google.firebase
Group: firebase-ml-vision-face-model

The rest of the description and version numbers and all just ignore it.
Now go to your android app/build.gradle and exclude this module configuration

That’s it. Re-run your project and you will find this issue anymore

Posted by:
Anand S,
Software Engineer, NIUM India Pvt Ltd

Notes on Startup – Foundations – Team is Very Important

“Thiel’s Law”: A Startup messed up at its foundation cannot be fixed.

Beginnings are special, they are qualitatively different from all that comes afterward. This was true 13.8 billion years ago, at the founding of our cosmos: something very special happened and universe began to expand and went on to expand by the factor of 10^30 – a million trillion trillion.

Once a country is formed its hard to change constitution, united states since its freedom, after 1791 change it has amended the constitution only 17 times.

Companies are like countries in this way. Bad decisions made early on – if you choose the wrong partners or hire the wrong people, for example – are very hard to correct after they are made. It may take a crisis on the order of bankruptcy before anybody will even try to correct them.

You can not build a great company on a flawed foundation

Founding Matrimony – A Startup starting with – A Team

Image credits https://www.vrfocus.com/

When you start something the first and most crucial decision you make is whom to start it with. Choosing a co-founder is like getting married and founder conflict is just as ugly as divorce. A wise investor will always first study the team, either the investor or a founder what matters most is the team to begin with.

Its not just a founder who need to get along. Everyone in your company needs to work well together. Its very hard to go from 0 to 1 without a team.

Team Culture for a Successful Startup

What would the ideal company culture look like? Employees should love their work. They should enjoy going to the office so much that formal business hours become obsolete and nobody watches the clock, workers should feel at home.

Recruiting is a core competency for any company. It should never be outsourced. You need people who are not just skilled on paper but who will work together cohesively after they are hired. The first four or five might be attracted by large equity stakes or high profile responsibility. More important than those obvious offerings is your answer to this question: Why should the 20th employee join your company?

Talented people no need to work for you, they have better options out with better offerings, hence as a founder we have to ask ourselves why some one should join my company? some of the bad answers are “Your stock options are better than others”, “You will get to work with smartest people in the world”, “You can help solve the world’s most challenging problems”. The only good answer is specific to your company. The good answers are about your mission and about your team.

Reference: Book Zero To One By Peter Thiel

Notes on Startup – Secrets – Believing in Secrets to build Something New

I think we all believe that Every one of Today’s most famous and familiar ideas was once unknown and unsuspected. The mathematical relationship between a triangle’s sides was secret for millennia until Pythagoras has to think hard to discover it.

image credit – https://theskincaremillionaire.typepad.com/

Why aren’t people looking for secrets?

Most people act as if there were no secrets left to find. An extreme example of this is Ted Kaczynski infamously unknown as the Unabomber. Kaczynski was a child who enrolled to Harvard at 16, completed his PhD in math. In late 1995. the authorities didn’t know who or where the Unabomber was. The biggest clue was a 35,000 – word manifesto that Kaczynski had written and anonymously mailed to a press. Kaczynski argued that modern people are depressed because all the world’s hard problems have already been solved. whats left to do is either easy or impossible.

So Kaczynski idea was to destroy existing institutions, get rid of all technology and let people start over and work on hard problems anew 🙂 His methods were crazy but his loss of faith in the the technology frontier is all around us. Its a really bad that one thinks there are no secrets left to think upon and do something new.

What happens when a company stop believing in Secrets?

The sad decline of Hewlett-Packard provides a cautionary tale. In 1990 The company was worth $9 billion. then in 1991 HP released the Deskjet 500C the world’s first affordable color printer. in 1993 it launched OmniBook, one of the first superportable laptops, the next year HP released OfficeJet, the world’s first all-in-one printer/fax/copier. by mid 2000, HP was worth $135 billion.

But starting from 1999, when HP introduced a new branding campaign around the imperative to “invent”, it stopped inventing things, in 2001 the company launched HP Services, a glorified consulting and support shop. in 2002 HP merged with Compaq, presumably because it didn’t know what else to do. by 2005 HP’s market cap had plunged to $70 billion roughly half of what it had been five years earlier.

HP’s board split into two factions, only one of which cared about new technology led by Tom Perkins, an engineer who joined HP in 1963 to run company’s research division. At 73 year old in 2005, Perkins thought board should identify the most promising new technologies and then have HP build them. But Perkins factions lost out to its rival, led by chairwoman Patricia Dunn. As a result by 2012 HP’s market cap was worth just $23 billion.

Moral of the story is, As a company should always keep chasing new secrets, new opportunities, new technologies and build them all from scratch

The Case for Secrets

Fermat’s Last Theorem after 358 years of fruitless enquiry by other mathematicians the kind of sustained failure. Pierre de Fermat had conjectured in 1637 that no integers a, b and c could satisfy the equation a^n + b ^n = c^n for any integer n > 2. He claimed to have proof but died without writing.

Wiles started working on it in 1986, but he kept it a secret until 1993, when he knew he was nearing a conjecture in 1995. He needed brilliance to succeed, but he also needed a faith in secrets. If you think something hard is impossible, you’ll never even start trying to achieve it. Belief in secrets is an effective truth.

Similar stories we can see in business ideas, before Airbnb, travelers had little choice, Airbnb saw untapped supply and unaddressed demand where others saw nothing. Same with Lyft and Uber.

Finding Secrets is Key as a Company

there are two kinds of secrets: Secrets of nature and secrets about people. Natural secrets exist all around us; to find them, one must study some undiscovered aspects of physical world. Secrets about people are different, they are things that people don’t know about themselves.

So when thinking about what kind of company to build, there are two distinct questions to ask: What secrets is nature not telling you? What secrets are people not telling you?

If you find a secret; you have two choice, do you tell everyone ? or do you tell no one and keep it with you? If you keep with you alone and try to build something around that secret then think that you are building something from 0 to 1

Reference: Book Zero To One By Peter Thiel

Continue Reading – Startup Thinking – Foundations – Team is very Important

Notes On Startup – Ideology of Competition – Building Creative Monopoly

Creative monopoly means new products that benefit everybody and sustainable profits for the creator. Competition means no profit for anybody, no meaningful differentiation and struggle for survival, So why do people believe in competition is healthy?

The answer is competition is not economic concept, its an ideology that pervades our society and distorts our thinking.

We Preach competition, internalise its necessity and enact its commandments and as a result we trap ourselves within it, even though the more we compete, the less we gain, this is the simple truth but we have all been trained to ignore it.

Competition in Education System

Our education system both drives and reflects our obsession with competition, Grades themselves allow precise measurement of each student’s competitiveness.

Students who don’t learn just by sitting still at a desk are made to feel somehow inferior, while children who excel on conventional measures like tests, assignments end up defining their identities and it gets worse as they ascend to higher level of education.

for the privilege of being turned into conformists, students pay hundreds of thousands of rupees as tution fees. Why are we doing this ?

Competition – Marx and Shakespeare models

Marx: People fight because they are different, the greater the differences, the greater conflicts.

Shakespeare: By contrast all combatants look more or less alike, its not clear why they should be fighting, Since they nothing to fight about.

Consider the opening line from “Romeo and Juliet”, Two households are alike, yet they hate each other, eventually they lose sight of why they started fighting in the first place.

In the world of business atleast Shakespeare model proves the superior guide. Inside a firm people became obsessed with their competitors for career advancement. Then the firms themselves become obsessed with their competitors.

Shakespeare model of Competition in Real-world business

Gates and Schmidt that is Microsoft vs Google, they both were in a different world as they started with operating system and search engine respectively. As with all good tragedy, they conflict seems inevitable only in retrospect. As they grew they began to focus on each other and hence we started seeing war like Windows vs Chrome OS, Explorer vs Chrome, Office vs Docs, Surface vs Nexus

Just as a War Costs, it cost Microsoft and Google their dominance: Apple took them all in Jan 2013, Apple market capitalization was $500 billion, while Microsoft and Google together $467 billion.

Image credit ocalastyle.com

Rivalry causes us to over emphasise old opportunities and slavishly copy what was worked in the past

Another Example:

In off 2010 a startup square released a card reader for iPhone, it was a great square shaped product.

Imitators sprung in no time, A Canadian company Netsecure released half moon shaped card reader, Intuit brought Cylindrical card reader, Paypal launched Traingle shaped card reader.

So one gets the sense that Shakespear Saga won’t end until the apes run out of shapes 🙂

Image credit cached.imagescaler.hbpl.co.uk

Competition can make people hallucinate opportunities where none exist.

If you can’t beat the rival, it may be better to merge. Thats whay Paypal and X.com did in late 1999 and that helped them to ride out the dot com crash and then build a successful business.

Reference: Book Zero To One By Peter Thiel

Continue Reading – Startup Thinking – Finding out a Secret to build something new

Notes On Startup – A Perfect Competition and Monopoly

“Perfect Competition” Is considered both ideal and default state in economics. Perfectly competitive market achieve equilibrium when producer supply consumer demands.

Every firm in competitive market sells the same homogenous product, no firm has any market power. They must all sell at whatever price market determines.

If money to be made, new firms enters, Increase supply, drive prices down, eliminates the profit that attracted them in the first place. If too many firms enter, they will suffer losses, some will fold and prices will rise back.

Under perfect competition in long run, no company will make profit

“Monopoly” The opposite of perfect competition, where as competitive firms must sell at market price, monopoly owns the market so it can set its own price. Since it has no competition.

Google is good example of a company that went from 0 to 1, it hasn’t competed in search since the early 2000s where it definitively distanced itself from microsoft and yahoo.

The lesson for entrepreneur is clear, if you want to create and capture lasting value, don’t build an undifferentiated commodity business

To the outside observer, all businesses look alike, so its easy to perceive only small differences between them but reality is much more binary than that

Image credit : Zero to One Book

however there is enormous difference between perfect competition and monopoly. Most businesses are much closure to one extreme that we commonly realise. In reality differences are deep

Image credit : Zero to One Book

Reference: Book Zero To One By Peter Thiel

Continue Reading – Startup Thinking – Ideology of Competition

Notes On Startup – Four big Lessons from dot-com Crash

It was the period between 1995 to 2000 where investors across the world started investing on internet based startups hoping that all the internet based companies will make money, however by 1999 dot-com bubble started to collapse which is typically referred as dot-com crash.

image credit zero to one book
image credit zero to one book

Entrepreneurs who stuck in Silicon Valley between 1995 to 2000, learned four big lessons from the dot com crash. That still guide business thinking today.

  1. Make incremental advances
    • Grand vision inflated the bubble, so they should not be indulged. Anyone who claims to be able to do something great is suspect and anyone who wants to change the world should be more humble, small, incremental steps are the only safe path forward
  2. Stay lean and flexible
    • All companies must lean which is code for “unplanned”, You should not know what your business will do, planning is arrogant and inflexible.
  3. Improve on the competition
    • Don’t try to create a new market prematurely. The only way to know you have a real business is to start with an already existing customer, so you should build your company by improving on recognisable products already offered by successful competitors.
  4. Focus on Product not Sales
    • If your product requires advertising or sales people to sell it, its not good enough. Technology is primarily about product development, not distribution. Bubble era advertising was obviously wasteful, so the only sustainable growth is viral growth.

Try things out “Iterate”, Treat Entrepreneurship as agnostic experimentation

These lessons have become dogma in startup world; those who would ignore them are presumed to invite the justified doom visited upon technology in the great crash of zero and yet the opposite principle are probably more correct.

  1. It is better to risk boldness than triviality (lack of seriousness or importance)
  2. A bad plan is better than no plan
  3. Competitive market destroy profits
  4. Sales matters just as much as product

Reference: Book Zero To One By Peter Thiel

Continue reading – Startup Thinking – Perfect Competition vs Monopoly

Notes On Startup – Startup Thinking – 1 to n And 0 to 1 progress

Globalisation is horizontal progress 1 to n, technology is vertical progress 0 to 1. Going back to the history, from 1815 to 1914, period of both rapid technological development & rapid globalisation, between first world war & Kissinger’s trip to China, to re-open relation with China in 1971, there was rapid technological development but not much globalisation. Since 1971 we have seen rapid globalisation

Globalisation brings decade ahead more convergence and more sameness, what developed nations have done in past, now many poorer nations doing the same and caching up thats what we call globalisation

Technology matters not just globalisation

Image Credit – https://www.orfonline.org/

But the truth is technology matters, without technological change if China doubles its power production over next two decades, it will also doubles its air pollution. If every one in India, hundreds of thousands of households were to live the way Amaricans live using only today’s tools the result would be environmentally catastrophic.

image credit https://itchronicles.com/

Spreading old ways to create wealth around the world will result in devastation, not richer. In a world of scarce resource, globalisation without new technology is unsustainable.

Today the challenge is to both imagine and create the new technologies that can make the 21st centuary more peaceful and prosperous than the 20th.

Startup thinking

It is hard to develop new things in big organisations and it is harder to do it by yourselves

Bureaucratic hierarchies move slowly and entrenched interests shy away from risk. At the other extreme, a lone genius might create a classic work of art but he could never create an entire industry.

Startups operate on the principal that you need to work with other people to get stuff done, but you also need to stay small, positively defined, a startup is the largest group of people you can convince of a plan to build a different future.

New Thinking

New companies most important strength is new thinking, even more important than nimbleness, small size affords space to think

Reference: Book Zero To One By Peter Thiel

Continue Reading – Startup Thinking – Four big Lessons

Notes On Startup – Building Something New and Innovative

The Next Bill Gates will not build an operating system, The next Larry Page will not build a search engine, The next Mark Zukerberg will not build Social network.

image credit productiveflourishing.com

If you are copying these guys, you aren’t learning from them

Doing what we already know how to do take the world from 1 to n

But

Every time we create something new, we go from 0 to 1, the act of creation is singular and the result is something fresh and strange

image credit fromthegrapevine.com

The Best Paths are New and Untried

Horizontal or extensive progress means copying things that work going from 1 to n, horizontal progress is easy to imagine because we already know what it looks like.

Vertical or intensive progress means doing new things going from 0 to 1, vertical progress is harder to imagine because it requires doing something nobody else has even done.

Reference: Book Zero To One By Peter Thiel

Continue Reading – Startup thinking – 0 to 1 progress