Skip to content

Instantly share code, notes, and snippets.

View kaniket7209's full-sized avatar
🎯
Focusing

kaniket7209

🎯
Focusing
View GitHub Profile
@kaniket7209
kaniket7209 / FAQ
Created November 24, 2021 09:53
CSS Pseudo Classes | Interview Prep | Browser Module
1. What is the purpose of CSS structural pseudo classes?
Answer: A Pseudo class in CSS is used to define the special state of an element. It can be combined with a CSS selector to add an effect to existing elements based on their states
2. What is the difference between pseudo elements & pseudo classes in CSS?
Answer: A pseudo-element is a 'fake' element, it isn't really in the document with the 'real' ones. Pseudo-classes are like 'fake' classes that are applied to elements under certain conditions, much like how you would manipulate the classes of elements using JavaScript
3. What is the correct syntax of writting pseudo class?
Answer: selector:pseudo-class {
property: value;
}
@kaniket7209
kaniket7209 / FAQ
Created November 24, 2021 08:13
HTTP Verbs (Methods, Status codes, Status type) | Interview Prep | Browser Module
1. Why http has been introduced. What's the need of http protocol?
Answer: To communicate with the client and server . Http enables the link between client and server where client makes a request and server reverts a response.
2. As we know http is a stateless protocol. What does that mean?
Answer: This means that the server doesn’t keep any information about the client after it sends its response, and therefore it can’t recognize that multiple requests from the same client may be related.
3. What do http request comprises of. Describe the anatomy of request?
Answer: An HTTP request is composed of the following parts:
a) method
b) URI(User Resource Identifier)
@kaniket7209
kaniket7209 / FAQ
Created November 24, 2021 07:30
CSS Selectors Specifity | Interview Prep | Browser Module
1. Which selector has the highest specificity?
Answer: D selectors have the highest specificity amongst the CSS selectors
2. Why ID Selector has the highest specificity?
Answer: Because of the unique nature of the ID attribute definition, we are usually styling a really specific element when we call up the ID in our CSS.
3. What is the correct order of selector specificity from most to least?
Answer: CSS style applied by referencing external stylesheet has lowest precedence and is overridden by Internal and inline CSS. Internal CSS is overridden by inline CSS. Inline CSS has highest priority and overrides all other selectors.
4. When two styles have the same specificity who wins?
@kaniket7209
kaniket7209 / FAQ
Last active November 24, 2021 06:37
CORS Error!! (Cross Origin Resource Sharing) | Interview Prep | Browser Module
1. How CORS work(steps/ways) for Simple Requests ?
Answer: For Simple Requests, the CORS Works on the following way,
a) Request is made to a third party site with ORIGIN Header.
b) On the target site, the ORIGIN value is compared with the allowed origins.
c) If the source is an allowed one, then the resource is granted access, else denied.
2. How CORS work(steps/ways) for Complex Requests ?
Answer: For Complex Requests, the CORS Works on the following way,
a) Before the actual request is sent, a pre-flight request is sent to the target site.
b) This pre-flight request is sent via the OPTIONS HTTP Request method.
@kaniket7209
kaniket7209 / FAQ
Last active November 25, 2021 09:41
CSS Background Properties
1. How can we change the position of the background image?
Answer: Using background-position: x y; where x and y is the position keywords. Suppose if you want to position the image in center then instead of x and y write center center
2. How can we repeat the same background image ?
Answer: Using background-repeat: property. Suppose if you want to repeat itself in
i) both x nad y axis then in property write repeat;
ii) just x axis then in propert write repeat-x and if y axis then write repeat-y
3. Suppose I have a background image of size 960px by 640px large.Its aspect ratio is 3 by 2. It's bigger than its original container(which is 150px high).How can I use my image fully here ?
@kaniket7209
kaniket7209 / FAQ
Created November 24, 2021 04:52
Cookies and CSRF Attack!! | Interview Prep | Browser Module
1. How can we prevent CSRF attack ?
Answer: Using XSRF protection Token inside cookies.
2. How can we use XSRF protection token?
Answer: It can be used to prevent CSRF attack by changing the default value of samesite inside cookies as "strict" which will restrict the website to access the cookies information unless it is permitted by the parent website.
3. How csrf Attacks are possible. What is the bug that makes it possible?
Answer: CSRF attacks are possible against web apps that use cookies for authentication because:
a) Browsers store cookies issued by a web app.
b) Stored cookies include session cookies for authenticated users.
@kaniket7209
kaniket7209 / FAQ
Created November 23, 2021 12:51
DOMContentLoaded Vs Load Events | Interview Prep
1. What is the major difference between unload and beforeunload events ?
Answer: beforeunload is used before unload event as an alert to warn the user before performing umload events such as navigation, page close,reload,etc.
2. What does Ready State indicates ?
Answer: It indicates the current loading stage.
3. What is the difference between window.load and document.ready?
Answer: In simple words, window.load is called when all content of window is loaded whereas document.ready is called when DOM is loaded and document structure is ready.
4. How can we obtain a window for a given document ?
@kaniket7209
kaniket7209 / FAQ
Created November 23, 2021 11:20
Debouncing & Throttling | Interview Prep | Browser Module
1. What is the key difference between debouncing and throttling?
Answer: In debouncing, it only makes an API call if the time difference between two keystrokes events is greater than a certain limit.
Whereas, in Throttling, it only makes an API call if the time difference between two function calls is greater than a certain limit.
2. Which one is better?
Answer: It totally depends on the use case and scenario where you are applying these concepts.
3. What is the similarity between Debouncing and Throtting?
Answer: Both of these are meant for performance optimization.
@kaniket7209
kaniket7209 / FAQ
Created November 19, 2021 11:45
GitHub web scraper for open source developer | part-2
1. How can we convert JSON file to pdf File ?
Answer: Perform the following steps:-
a) $ npm install pdfkit //Install pdfkit
b) const PDFDocument = require('pdfkit'); // require it
c) const fs = require('fs');
d) let pdfDoc = new PDFDocument; // create object
pdfDoc.pipe(fs.createWriteStream('SampleDocument.pdf')); // for writing to pdf
pdfDoc.text(JSON.stringify(Array)); // conversion JSON to string and then to text for pdf
pdfDoc.end(); // end the process
@kaniket7209
kaniket7209 / FAQ
Last active November 19, 2021 10:03
GitHub web scraper for open source developer🔥🔥 | Node.js Project (Part - 1)
1. Why is it neccesary to make the full link by adding the homapage to the selected "href" .?
Answer: This is because browser has a feature of adding the homepage link to the href but node doen't have .So to make the href complete ,we add "www.homepage.com/" to href, where homepage is the current page link.
2. What is callback in Node js?
Answer: The callback is an asynchronous equivalent for a function, it is called at the completion of a given task.
3. Why we cant add comments(//) inside the JSON file?
Answer: Because Json doesn't supports comments and it is only a "data syntax" .
4. How can we write arrays inside Json file.?