Skip to content

Instantly share code, notes, and snippets.

View vipul-zambare006's full-sized avatar

Vipul vipul-zambare006

View GitHub Profile
@vipul-zambare006
vipul-zambare006 / solution.ts
Last active June 1, 2024 10:35
3. Medical records by age
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;
})
@vipul-zambare006
vipul-zambare006 / node-script-auto-open-tabs-in-browser.js
Last active April 28, 2020 15:38
NODE SCRIPT TO OPEN TABS IN DEFAULT BROWSER
const opn = require("open");
(async () => {
await opn("https://www.linkedin.com/feed/");
await opn("some url");
await opn("some url");
})();
NPM CACHE CLEAN:
npm cache clean —force
npm cache verify
rm -rf node_modules/
delete package-lock.json
npm install —no-package-lock
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
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
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”
@vipul-zambare006
vipul-zambare006 / css-positioning
Last active March 21, 2021 16:20
CSS Positioning:
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.
@vipul-zambare006
vipul-zambare006 / Frequency-counter
Last active April 21, 2021 13:48
Common interview coding questions
//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;
///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;
@vipul-zambare006
vipul-zambare006 / solid-principles
Created April 21, 2021 16:31
Solid principles
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