Hash Function

A hash function takes a data like string and outputs a hash, a fixed-size string or number.

E.g MD5 hash for a string “alok” is bad220c335d0c1f53548f6acdb17e265

import hashlib# initializing stringstr2hash = "alok"result = hashlib.md5(str2hash.encode())print(result.hexdigest())bad220c335d0c1f53548f6acdb17e265

Notes

  1. A given file will always have same hash but we can’t go back from hash to original value
  2. Sometime multiple string having same hash value, which is called hash collision.

Use cases of hash map

  1. Unordered map or dictionary : Creating a look up table in programming language.
  2. Preventing man-in-the-middle attack

Q. You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). You need to do this in place.

Question asked in Amazon Google Facebook Design


Photo by Florian Olivo on Unsplash
<!DOCTYPE html>
<html>
<head>
<style>
.container {
width: 400px;height: 400px;position: relative;background-color: yellow;margin: auto;margin-top: 100px;}.animate {width: 50px;height: 50px;background-color: red;position: absolute;}.animate2 {width: 50px;height: 50px;background-color: red;top: 0;right: 0;position: absolute;}button {position: relative;top: 20px;margin-left: 700px;}</style></head><body><!-- <h1 id="demo"></h1> --><div class=container><div class="animate"></div><div class="animate2"></div></div><button onclick="call()">Button</button><script>function call(){const animate = document.querySelector('.animate')const animate2 = document.querySelector('.animate2')var pos=0;var timeInterval=setInterval(function(){pos++;if(pos==350){clearInterval(timeInterval)
}
animate.style.top=`${pos}px`;animate.style.left=`${pos}px`;animate2.style.top=`${pos}px`;animate2.style.right=`${pos}px`;},5)}</script></body></html>

Photo by Nathan Dumlao on Unsplash

Our purpose of this tutorial is to find the number of days between two dates.

In JavaScript, we can create a date object using the Date() constructor. By default, it will display the browser’s timezone.

var today = new Date()
//Tue Oct 13 2020 21:58:37 GMT+0530 (India Standard Time)

Now, suppose we want to check the date of 1 January 2020. There are various methods to find it out. But, the most convenient way, I feel is given below.

var start = new Date("january 1,2020");//Wed Jan 01 2020 00:00:00 GMT+0530 (India Standard Time)

JavaScript Stores Dates as Milliseconds

JavaScript stores dates as number of…


Photo by Shahadat Rahman on Unsplash

RXJS OPERATORS:

Operators are a very essential part of RXJS. It allows complex asynchronous code to be composed in a declarative manner.

  1. interval operator: It’s a function that takes in number as an argument and outputs an observable.
import {interval} from 'rxjs';const observable = interval(1000) // argument is no of milliseconds// subscribe the above observable
observable.subscribe({
next:(val) => console.log(`Demo of interval operator : ${val}`)
})
// outputs
// Demo of interval operator : 0
// Demo of interval operator : 1
// Demo of interval operator : 2
...
...
...

2. take operator: It’s a filter that…


Photo by Tracy Adams on Unsplash

If you are looking for a Software development job in #FAANG. Then, you must be aware…………..!!! Sorry Sorry, not just aware but be master of Data structure and algorithm.

So, why to wait, what the heck Data structure and algorithm. But, before dive directly into Data structure and algorithms. You should know at least one programming language as without implementation, it is just crap.

As there are no restrictions on programming language, I highly suggest picking JAVA as your Programming language. Why I am advocating JAVA because I created JAVA. Just a joke.

So, Most of the popular books I…


Photo by Tracy Adams on Unsplash

If you are looking for a Software development job in #FAANG. Then, you must be aware…………..!!! Sorry Sorry, not just aware but be master of Data structure and algorithm.

So, why to wait, what the heck Data structure and algorithm. But, before dive directly into Data structure and algorithms. You should know at least one programming language as without implementation, it is just crap.

As there are no restrictions on programming language, I highly suggest picking JAVA as your Programming language. Why I am advocating JAVA because I created JAVA. Just a joke.

So, Most of the popular books I…


Photo by Oriol Portell on Unsplash

So, In this tutorial we will cover following things

  1. What are Cookies?
  2. Why are they used on Internet?
  3. Create Django Cookies

1 What are Cookies?

It is always easy to understand a concept using an example. So, suppose you visited a E-commerce website. Let’s take an example of Amazon. You like some products and add them to cart. After one day you again visited the site, you observed that, the cart is still showing those products. So, how these data are saved, where these data are saved? So, these are data are saved into your browser locally, which are actually…


Photo by Chris Montgomery on Unsplash

I have started a series in which I will cover all relevant Javascript Interview topics. I already posted one article The javascript this keyword.

Today we will cover Javascript Function call, which is one of import Interview topic.

  1. Why do we use a call() Function?

So, with call(), an object can use another object method.

Let’s understand through an example.


Understands this keyword in Javascript.

Go to the following Links.

https://medium.com/alokkumar95/the-javascript-this-keyword-215ef7f77585

Feel free to comment and also suggest your views. Your thought is important for us. Please don’t forget to clap. You can clap as much as you want.

Regards,

Alok Kumar

Alok Kumar(Python|Javascript|DJango)

Hire me aloke.kumar95@gmail.com, +917073433041

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