Posts

Showing posts from October, 2020

Lets learn "Factory design pattern"

 In this tutorial, we'll learn about the factory design pattern as in what it is, in which use cases this is being used and how it works. If you've are not familiar with what are software design patterns and what are its different types check out this tutorial. Introduction A factory design pattern is a creational design pattern that is related to object creation. In this pattern, we'll have a method to create an object without exposing its creation logic to the client. If a class method is creating an object it has to be static.  The idea is to create a static method ( factory method ) which instantiates a class without exposing its logic to the client and the client can use that method every time it needs to create an object of the class. The reason why the factory pattern is useful is that as it does not expose the logic of object creation, so if logic is changed, the client code need not to be changed. Usecases The place where this pattern is mostly used is library cod

Lets learn "Cross Domain Referer Leakage / Cross Site Request Forgery"

Image
 Welcome Back ! Guys Lets get to know about a new web vulnerability known as Cross Domain Referer Leakage . We'll use BurpSuite in this tutorial . If you are not familiar with the burpsuite then I would recommend to visit  Introduction to web Application Security  tutorial , and then come back to this tutorial to learn about Cross Domain Referer Leakage . It is also known as CSRF(Cross Site Request Forgery). What is Cross Domain Referer Leakage or Cross site Request Forgery? Whenever a request is created from browser , a HTTP header is send with the request which contains attributes like Content-type(what type of data is being sent in request) , Agent ( which agent is used to make a request - Chrome or Mozilla or Python ) etc . On of such attributes of interest is " Referer"  indicating request is coming from which site . For example : Say A friend send you the link to some website in facebook message . When you open that link the HTTP header in contains a referer as '

Lets learn "Software design patterns"

Image
  In this tutorial, we'll be learning about the introduction of software design patterns and different design patterns that are being followed while writing the code. This would be an introductory tutorial we'll go in detail about all design patterns in detail in other tutorials. Introduction So whenever we are writing any application code, there are many ways to achieve the same behavior but sometimes we write a code in a way that whenever a new requirement comes it becomes difficult to extend the existing code but to rewrite everything. That's when design patterns would are helpful.  Design patterns are the coding patterns that are adapted over time by experienced object-oriented developers. So such patterns are already tested. Code written with such patterns is scalable, readable, and extendable.  So it's helpful for any developer to use the correct design pattern to write a code in a way that is scalable, readable, and maintainable. Types of design patterns There ar

Lets learn "What is CDN?"

Image
  In this tutorial, we'll learn about What is CDN ( Content delivery network ) and how it works. Introduction Whenever you access any website on your mobile phone or laptop or any other device using the internet connection, you must have seen for some of the websites the pages load quickly, and for others, it takes considerably more time. Why is that?  Basically loading any website requires the data needs to be downloaded from the server where that particular website is hosted. For e.g, if you are accessing a website in Canada which is hosted on a server in India, it will take some time due to the latency but if that website is hosted on servers in Canada itself it will take less time to load due to low latency. So internet experience can be bad for some of the websites when clients and servers are separated by a long distance. One could argue that why not host the website on servers in all regions but that would increase the cost a lot. The better solution is to use CDN. Let's

Let's learn "WhatsApp (or any real-time messaging system ) system design"

Image
  In this tutorial, we'll learn about the system design of WhatsApp, which is the most popular real-time messaging application today.  Features we'll be discussing in this tutorial Detection of message status ( which can be sent, delivered, and seen ) User's status ( online/ last seen) Media sharing ( includes image, videos, etc ) Message encryption ( for security reasons ) Support of telephony ( including audio/video calls ) Group Messaging The general design for a messaging system In any messaging system, the general idea is the client connects to the messaging server which knows the addresses of all the clients. When any client sends any message, the messaging server is responsible for forwarding the message to the correct client. WhatsApp Architecture For a messaging system like WhatsApp which has billions of users, a single messaging server will not be sufficient. So the architecture will look something like the above figure. All the connections are duplex. That means

Lets learn "Different types of database locks"

Image
In this tutorial, we'll learn about different types of locks in the database. Basically, there are two types of locks. Pessimistic Lock Optimistic Lock Pessimistic Lock Pessimistic is a simple mutex lock. In the pessimistic lock, the clients wait for the lock to be acquired before doing the DB update. So the DB operation will never fail, unlike optimistic lock. <acquire lock> perform DB write...... <release lock> Usecase Pessimistic locks are used on RDBMS. Optimistic Lock ID Data VERSION /  HASH /  TIMESTAMP / CHECKSUM 1 Lets v1 2 Learn v1 3 Locks v1 Optimistic Locking is a strategy where you read a record and note its version/hash/checksum and while updating the record, check if the version/hash/checksum is the same before updating the record. Record update fails otherwise if version/hash/checksum is changed. Let's consider an example to understand an optimistic lock using the above DB table data. Suppose there are two clients A and B who wants to update the row w

Lets learn "About TinyURL/bitly system design"

Image
  In this tutorial, we'll learn about the system design for a URL shortener. A URL shortener is a service that basically shortens the URL to a fixed size. There are different services available on the internet to do that like tinyURL or bitly.  At first thought, it seems it is very simple. We basically have one DB containing a mapping of INPUT URL -> SHORTENED URL. When the user requests to convert a URL to a shorted URL it hits the service and the service converts it to a short URL and stores the mapping to DB and when the user provides a shortened URL and service will lookup in DB and provides the actual URL. The high-level idea is correct but there are some issues with this approach on the scale. In this tutorial, we'll discuss the scalable system design for URL shortener service. APIs needed for URL shortener 1. /createShortURL - This API will take a long URL as an input and returns the short URL. 2. /getLongURL -  This API will take a short URL as an input and returns t

Lets learn "Cron job schedule notation"

Image
In this tutorial, we'll learn about the notation that cron jobs use to describe the period in which the job needs to be run. Notation You must have seen the cron jobs scheduled defined like "*/2 * * * *" Let's learn what this means. The general meaning of each field in the cron job schedule is as follows. # ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * * <command to execute> Examples Let's go through some examples. 45 23 * * 6 /home/user/test.sh The above example means that the test.sh script should run at 23:45 ( or 11:45 PM ) of every Saturday. */2 * * * *  /home/user/test.sh NOTE: we can specify */n to run the program every nth interval of the time. Like in the above exampl

Lets learn "How to see the muted status on whatsapp"

Image
  In this tutorial, we'll learn how to see the muted status on Whatsapp. Step 1. Open Whatsapp ;) Step 2. Go to the Status section. Step 3. Scroll to the bottom. You'll see the "Muted status" section which contains all the statuses muted by you. THANKS FOR VISITING. STAY TUNED FOR MORE TUTORIALS :)

Lets learn "About different types of ports in Linux"

Image
  In this tutorial, we will learn about the different types of ports in Linux. A port is basically a communication endpoint in computer networking. A port can be hardware port like USB port, HDMI port etc. And a port can be logical. But the basic purpose of port is data transfer between two different hardwares or application software. In this tutorial, we'll be discussing logical ports. Classification of ports In computer, logical ports are numbers in the range of 0-65535 . The port is classified into three types 1. Well known or system ports Well known or system ports are special ports in the system which are assigned to special processes. Range of well-known ports is 0-1023 . It is recommended to not make non system apps listen on ports that are part of Well known or system ports. Some special ports in this category are as follows: Port No. Transport Protocol Service Name 20, 21 TCP File Transfer Protocol (FTP) 23 TCP Telnet 25 TCP Simple Mail Transfer Protocol (SMTP) 53 TCP &