This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOLID principles: | |
S: Single Responsibility Principle: | |
1. The class should have only and only one reason to change. | |
2. Helps in writing maintainable code. If there will be change in requirement you only nee | |
O: OCP => Open Close Principle: | |
1. Classes should be open for extension and closed for modification. | |
2. Eg: Create and abstract class which defines common behaviour and let other developers extend from that class to create their own implementation or extension to existing implementation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///HOISTING IS JAVASCRIPT: | |
/* | |
var a = 10; | |
In above line of code there are two things: | |
1. declaring variable that is: var a; | |
2. defining value of variable: a = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Common algorithm to calculate frequency of each character or number in an array | |
function frequencyCounter(arr) { | |
let result = {}; | |
arr.forEach((i) => { | |
if (result[i]) { | |
result[i]++; | |
} else { | |
result[i] = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSS positions: | |
1. Static: It is default HTML positioning. Elements just placed one after another without overlap or anything. | |
2. Relative: This is exactly like static positioning. The only difference is when u declare position “relative” You can use properties like “TOP”,”BOTTOM”,”LEFT”, “RIGHT”. | |
eg: If you use position relative and top: 10px then element will be placed 10px below its parent element unlike in absolute positioning where element will not have any defined position in DOM. | |
3. Absolute: When position absolute used, element finds its parent where position declared is “Relative” and places element by referring to that parent div. Lets say if this absolute position div doesn’t find any parent for which position is relative then it places element referring to browser window starting point. | |
Any element that is relatively positioned can have absolutely positioned child elements inside of it. And this child elements are positioned relative to parent relative positioned element. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CODE REVIEW CHECKLIST: | |
1. check file names | |
2. check class, method and variable names | |
3. Write Small pure functions | |
4. Remove unused code and comments | |
5. Liverage on TypeScript, use interfaces and union types | |
6. RXJS: USe Pipeable attributes | |
7. avoid subscribe in component and use async pipes, so that when component destroys it will automatically unsubscribe | |
8. Avoid memory leaks: use takeUntil in pipe | |
9. Don’t use nested subscriptions: Use “SwitchMap, forkJoin or combineLatest” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION search_columns( | |
needle text, | |
haystack_tables name[] default '{}', | |
haystack_schema name[] default '{}' | |
) | |
RETURNS table(schemaname text, tablename text, columnname text, rowctid text) | |
AS $$ | |
begin | |
FOR schemaname,tablename,columnname IN | |
SELECT c.table_schema,c.table_name,c.column_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ANGULAR LEARNING: | |
ANGULAR NOTES | |
1. app.module.ts: This is entry point | |
2. app.component.ts: It has backend typescript code | |
3. learn about pipes | use: data formatting | |
4. variable declaration: name:string = “Brad” | |
5. function declaration: changeName(name:string):void => note param type and method return type | |
6. Why SERVICES? A component can delegate certain tasks to services, such as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NPM CACHE CLEAN: | |
npm cache clean —force | |
npm cache verify | |
rm -rf node_modules/ | |
delete package-lock.json | |
npm install —no-package-lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const opn = require("open"); | |
(async () => { | |
await opn("https://www.linkedin.com/feed/"); | |
await opn("some url"); | |
await opn("some url"); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = `https://jsonmock.hackerrank.com/api/medical_records`; | |
const https = require('https'); | |
async function getRecordByPageNumber(pageNumber: number): Promise<any[]> { | |
return new Promise((resolve, reject) => { | |
https.get(`${url}?&page=${pageNumber}`, (resp) => { | |
let data = ''; | |
resp.on('data', (chunk) => { | |
data += chunk; | |
}) |