Skip to main content

What is $(This) keyword in Node Enviornment

The things i need to remember:

In a normal function / function declaration / named function, “this” keyword refers to the object that the function is called

Arrow functions do not have their own bindings, so when “this” is accesses inside an arrow function, it is taken from outside.

when “this” keyword is used in a named function/function declaration, the “this” keyword is equal to the global object as long as the named function is in the global scope and not called on any object.

In the global scope the “this” keyword refers to module.exports object.

In a function expresson in the gloabal scope this keyword reffers to module.exports object.

EBS Volume

  • Its network volume or Network volume like(Network Pendrive not physical drive) we can add to any EC2 instance as store space.
  • It will not terminate after you terminate your EC2 instacne.
  • You can attach 1 volume to 1 instance at a time and also need to be in same availability zone.
  • Root EBS volume will be deleted not the others attached volume while the EC2 instance terminates

EBS Volume Snapshots

  • Backup your EBS volume by taking a snpshots

AMI

Amazon Machine Images are a customization of an EC2 instance, that means we can customize a ec2 instacne then latter we can reuse that image. The main facility we will get from AMI is faster boot and configuration time because those things are already install in that AMI.

  • AMI create for specific region

EBS Volume types

  • GP2/GP3(SSD) : General purpose SSD volume that balance price and performance
  • io1 / io2 Block Express (SSD) : Highest-performace SSD volumn for mission-critical low latancy or high-throughput(In same Availability zone io1/io2 volume can be use by multiple EC2 instance upto 16 instance)
  • st1 (HDD): Low cost hdd volume
  • sc1 (HDD) :Lowest cost HDD volume designed for less frequently access
  • Only gp2,gp3,io1,io2 can be use as a boot volume

    Better check this https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html

IOPS; I/O ops per sec

Hoisting For (let, const, var)

let and const are hoisted to the top of the block they
are in but not initialized to the default undefined value so
we can not use them until they are declared.
If we do,RerefenceError is thrown.

Variables declared using var can be accessed before they are declared and are equal to undefined.

Remember hoisting means declarations are moved to the top of their scope not the initialization.

What’s the Difference Between IAM Roles and IAM Policies in AWS?

Policy : Policy define permission of aws identity(users, group, roles) or resource within the aws account. Policy ensure that only the authorized usrs have access to specific asstes. Permissions defined within a policy either allow or deny access for the user to perform an action on a specific resource.

A policy can be identity based or resuorce based. Identity-based policies are attached to an identity (a user, group, or role) and ensure the permissions of that specific identity. On the other hand a resource-based policy defines the permissions around the specific resource—by specifying which identities have access to a specific resource and when.

Role : Role are designed so that a set of permissions can easily be assign to users on an individual basis. For example, instead of assigning an individual all their necessary permissions one at a time, they can be assigned a specific role that contains all the necessary permissions in a single step. 

Some important Git command

git reset HEAD~: Rollback your commit data

git reset –hard: Rollback everything includes deleted files.

git rm –cached .idea : remove .idea folder from cached.

git merge development -m “merge development branch with master branch”: Merge development branch data with master branch

git merge –abort: Undo the merge.

git fetch vs git pull : git fetch command fetch all the data from remote and update the remote branch. git pull do the same work and beside that also update the local branch.

All About Mysql Index.

How to create index in MySql table.

CREATE INDEX index_name ON table_name (column_list)

CREATE INDEX jobTitle ON employees(jobTitle);

How to remove Index form a table.

DROP INDEX index_name ON table_name

DROP INDEX name ON leads;

Show index from a table.

SHOW INDEXES FROM table;

SHOW INDEXES FROM employees;

Before query optimization, we usually use EXPLAIN keyword before the query string. This EXPLAIN keyword gives us all the necessary information about that query. Among all the information Access type(type) very important info which is needed to know all the developers. So let see what is Access type.

Access type tells us, how your query accesses all the data from the dataset when you will execute the query. There are 6 types of access type values you will find. when you will put EXPLAIN keyword Before your Query string.

CONST/EQ_REF
Both work the same way so that I treat both the same types. The database is performing a B-Tree traversal to find a single value. Basically is a binary search. It’s only applicable when you have a unique data set in your result. another way you can say you get at most 1 row in your result. Two way you can do it
1. Primary key in your column.
2. You have a unique constraint on that column.
So lastly when you found this value in access type just skip no need to optimize. Because it’s not going to faster than this. it’s super fast.

REF/RANGE
They are known as index range scans. Perform a B-Tree traversal to find the starting point. after that, its scans value from that point on. It actually limits the total number of the row the database has to inspect to perform your query. It’s a good thing.

INDEX
Its also known as a Full index Scan. Index scan still using the index but its not using the limit. Its scan from at the first row and to the last row. Their is no filtering in to the index you just scan all the rows.

ALL
And lastly, All is also known as a Full Table Scan. You just load all rows into the memory not using any index. It’s a very bad access type. we should not expect this type.