First, let us understand why do we need hooks?

When we create function components instead of class components, we miss some of the main functions provided by react i.e. life cycle components like componentDidMount, etc. So we to overcome this limitation we have hooks. Hooks allow us to hook into the react state and also life cycle features from function components.

There are many react hooks, let us discuss some of them

  • useSelector()

This hook can be used when the application wants to read any data from the redux store. For example, we have a redux store and we want…


What are streams ?

Streams are used to move the data from server to client bit by bit (In chunks), Instead of loading everything in the server memory to transfer the data. Let’s understand this with an example,

Say we have a business to transfer the water. And we need to transfer the water from bucket A to bucket B, What you will do is move the water from source to your factory(auxiliary storage) and from there you move it to the destination.

Image for post
Image for post
Store water from S to B and then transfer from B to D

Hmm, But we have another approach which is better than this, Why can’t we introduce a pipe between S and D…


If you are javascript developer, till now you might have used it only for client side operations. Now what if you can use the knowledge of javascript to write code for server side interesting right ? NodeJs allows you to write server side code using javascript. NodeJs is runtime based on chrome’s V8 engine.

Why NodeJs ?

* NodeJs is Javascript runtime based on chrome’s V8 engine.

* NodeJs is event-driven, non-blocking IO model, that makes it light weight and more efficient.

What is event-driven?

Event driven means there is generally a main loop that listens for events and then triggers the callbacks based on the…


Indexing

It is used to speed up the look up operation but it causes the insertion to be slow. Let’s take an example if you reading a book and you want to see some topics. So what we generally do is we check the index of book for page number and directly go to that page. Similarly in MongoDB we create index and when we any specific record then instead of going through entire collection we just take it with the help of index.

Some common types

Single Field — It creates a lookup table for that specific field and reduces the time to…


Why should we prefer Mongo DB instead of SQL Server?

SQL Server / Relational Database

  • Relational Database are organised by tables, the data is stored in the form of rows and columns.
  • Keys are used to tie the data between different tables.
  • Relational database can be relatively very complex for the simple schema like getting the info of single user we need to combine multiple tables as shown below,
Image for post
Image for post
Relational Database
  • Creating relational database schema can have several disadvantages, like the design can be complex, etc.
  • Changes to schema can require the changes for the entire database.
  • Complex queries to join the…


In this story we will be discussing about the Authorization code flow, the basics of OAuth, when to use, how to register is already covered in my previous story.

Image for post
Image for post
Code Flow

In Short what is happening here is,

  • Client opens the application
  • Client app requests for the access token from auth server.
  • Auth server asks the client to choose IDP
  • Now the user login’s with the selected IDP
  • The IDP ask user consent about the data sharing.
  • User allows the IDP to share the information
  • The Auth server gets the auth code
  • Auth Code is exchanged with IDP for Access token
  • After…

Quick sort is based on divide and conquer strategy. The time complexity for quick sort in worst case in O(n²) and in average case is O(nLogn). The Space complexity is O(1). Let’s start with quick sort algorithm,

Image for post
Image for post

Initially we can take consider pivot element as any one of the following,

  • Last element of array,
  • First element of array,
  • Middle element of array,
  • Any random element from the array

Why do we take pivot element?

We take pivot element as a boundary, so that we can have all the elements to left of it as small than it and towards of right of it will be greater…


Let’s understand what is OpenID in simple terms, When you launch Zomato you get many options to sign in like login with google, Facebook. Have you ever thought what is happening behind the scene. Let’s take a look at the process.

Image for post
Image for post
Zomato Login Screen

When you select Continue With Google, you will be redirected to google page and you need enter the user name and password and google shares your information with Zomato.

Let’s explore more…

When zomato want to use google as Identity provider it should register itself with the google. We can register our application from — https://console.developers.google.com/. …


Time complexity is the time taken by your algorithm to execute in the worst case. Time Complexity is analysed for,

  • Very large input size
  • Worst case scenario

Rules to find out the time complexity,

Single Loop

for( i =1 ; i≤n; i++){x =y+z}

Here x = y+z takes constant time c and the loop is executed n times so the time taken will be n * c, so O(n)

Nested Loops

for(i=1;i<=n;i++)
{
for(j=1; j<=n; j++){
x = y+z // constant time
}
}

So here we have two loops and a constant expression, we can calculate the time as const expression takes c…


Stack is a linear data structure. Which allows you to insert and retrieve the elements in LIFO(Last in first out) order.The element added at last will be retrieved first, you can also consider stack as CD Holders in which we add CD’s on top of each other and we can retrieve the CD starting from the top i.e the last CD inserted. Common operations on stack are Push, pop, peek.

Push — Insert an element in stack

Pop — Remove the top element

Peek — See the top element

Image for post
Image for post
Book Stack Example

Python Implementation

We are now going to implement the stack in python,

Lokesh

Software Engineer | Understanding how the computer works.Curious Guy. To know more about me check https://lokesh-online.web.app

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store