Skip to content

Instantly share code, notes, and snippets.

@yogain123
Created July 21, 2019 07:43
Show Gist options
  • Save yogain123/5413f0258dbdfca3b3052a8729fd50dc to your computer and use it in GitHub Desktop.
Save yogain123/5413f0258dbdfca3b3052a8729fd50dc to your computer and use it in GitHub Desktop.
Extra Important
@yogain123
Copy link
Author

Replace in JS


let a = "sdfsdf;dsfdsf;dsfds";
let result = a.replace(/;/g,"*");
console.log(result);    // sdfsdf*dsfdsf*dsfds

@yogain123
Copy link
Author

PUG

Installations

npm install -g pug-cli

npm install pug --save

var pug = require('pug');
var html = pug.render('string of pug', {});
var html = pug.renderFile('filename.pug', {});

@yogain123
Copy link
Author

Using Pug

var pug = require('pug');

app.set('views', __dirname + '/public/views');
app.set('view engine', 'pug');

app.get('/', function (req, res) {
    res.renderFile('filename.pug', { title: 'Hey', message: 'Hello there!'});
});

@yogain123
Copy link
Author

yogain123 commented Feb 12, 2020

@yogain123
Copy link
Author

Types of Encryption

Screenshot 2020-02-12 at 2 49 26 PM

@yogain123
Copy link
Author

Lodash

Create an Object from Array of Object

const posts = [{id:1,name:"yogendfdgdra"},{id:3,name:"yfdgfogendra"},
              {id:2,name:"yogdfgdfendra"},{id:4,name:"yogenfdgddra"}]

const res = ._mapKeys(posts,"id");

result will be


{"1":{"id":1,"name":"yogendfdgdra"},"2":{"id":2,"name":"yogdfgdfendra"},
"3":{"id":3,"name":"yfdgfogendra"},"4":{"id":4,"name":"yogenfdgddra"}}

Converting back to Array

const resArray = _.map(res);

@yogain123
Copy link
Author

yogain123 commented Feb 12, 2020

CSR vs SSR

Screen Shot 1941-11-23 at 10 07 56 PM

@yogain123
Copy link
Author

yogain123 commented Feb 12, 2020

@yogain123
Copy link
Author

Terraform

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter.

@yogain123
Copy link
Author

Akash Sahani Video

https://www.youtube.com/watch?v=3KJI1WZGDrg (Event Delegation)

https://www.youtube.com/watch?v=aVSf0b1jVKk (Event Capturing and Bubbling)

https://www.youtube.com/watch?v=MOd5cTJ6kaA (Local Storage and Session Storage)

https://www.youtube.com/watch?v=tcLW5d0KAYE (CORS and Others)

https://www.youtube.com/watch?v=wstwjQ1yqWQ (Prototype and Prototype Inheritance)

https://portswigger.net/web-security/sql-injection (SQL Injection Doc)

https://www.youtube.com/watch?v=5m6dCbYO0Mk (SQL Injection Video)

@yogain123
Copy link
Author

Server Side Authentication

Screen Shot 1941-04-28 at 9 50 01 PM
Screen Shot 1941-04-28 at 9 50 11 PM

@yogain123
Copy link
Author

cookies vs token

Screen Shot 1941-04-28 at 9 51 53 PM

@yogain123
Copy link
Author

Servers

Screen Shot 1941-04-28 at 9 58 25 PM

frontend server is content server
backend server is api server

both server are in different domain so can't use cookies in this case

Seperation on Server Also helps in Load Balancing

Screen Shot 1941-04-28 at 10 00 38 PM

@yogain123
Copy link
Author

CORS

Screen Shot 1941-04-28 at 11 06 09 PM

It checks for all => domain, sub domain, port

@yogain123
Copy link
Author

Theory of Authentication

In HTTP , states/info are not shared among request

Screen Shot 1941-04-29 at 1 44 19 AM



How do we solve it ::

Screen Shot 1941-04-29 at 1 45 07 AM

@yogain123
Copy link
Author

db

Screen Shot 1941-04-29 at 1 57 38 AM

@yogain123
Copy link
Author

Deployment Version Control System

Screen Shot 1941-04-29 at 2 46 32 AM



Screen Shot 1941-04-29 at 2 47 23 AM



Screen Shot 1941-04-29 at 2 46 54 AM



Screen Shot 1941-04-29 at 2 47 13 AM



In Heroku

Screen Shot 1941-04-29 at 3 03 31 AM



Screen Shot 1941-04-29 at 3 04 10 AM

@yogain123
Copy link
Author

INFO

IMG_20190721_002042 (1)

-r means require

nodemon -r dotenv/config
require("dotenv").config();

In create-react-app ,, no need to dotenv import , it is internally done but need to to install dotenv ==> npm install dotenv --save

@yogain123
Copy link
Author

Info

While using create-react-app ==> env are set using REACT_APP_ANYTHING
REACT_APP_PORT=333
REACT_APP_NAME=yogendra
By Default NODE_ENV=development always,,, So use REACT_APP_STAGE = dev/stage/prod

DEV=======>>>STAGE=========>PROD



While Deploying Node/React App, Server Looks for npm start to run , but its not able to find then looks for Procfile ==> web: node server/server.js


.env for dotnet is for running in local and testing things (So that u have all env var in local) , but in server we should define env var from there itself (Should not Push .env file to server)

@yogain123
Copy link
Author

Get vs Post

Screen Shot 1941-12-03 at 11 15 45 AM

@yogain123
Copy link
Author

yogain123 commented Feb 22, 2020

Server Side Render vs Client Side Render (SPA)

Search Engine Optimization
Google bot and bing bot has problem indexing CSR, because with CSR it downloads all file associated with that to your browser and then executes/render that, the site is not actually rendered when the site is not downloaded and it makes google bot hard to index page.
But,
SSR render all page in Server itself and deliver full already rendered page and indexing are easy and fast for google bot.
Initial Page load is fast in SSR as it does not download all page at once, but all subsequent request is slow.
but in CSR initial page load is slow, but All subsequent request is fast.

SSR: www.website.com
SPA: app.website.com

Screen Shot 1941-12-03 at 1 50 08 PM

@yogain123
Copy link
Author

yogain123 commented Feb 22, 2020

OSI Model

Screen Shot 1941-12-04 at 1 38 29 AM



Screen Shot 1941-12-04 at 1 43 29 AM

Presentation layer breaks data on a format which can be understood by source

@yogain123
Copy link
Author

yogain123 commented Feb 23, 2020

Storage

Screenshot_20200223-113921



Screenshot_20200223-114427

@yogain123
Copy link
Author

Agile

Screen Shot 1941-11-07 at 9 58 15 PM

@yogain123
Copy link
Author

Headless Chrome

Screen Shot 2020-05-09 at 4 04 15 PM

@yogain123
Copy link
Author

SOAP vs REST

Screen Shot 2020-05-14 at 1 09 02 PM

@yogain123
Copy link
Author

Alias

Screen Shot 2020-05-15 at 11 16 58 PM

@yogain123
Copy link
Author

How HTTPS works

Screenshot 2022-10-09 at 6 36 18 PM

@yogain123
Copy link
Author

OSI Modal

Aj Firse Test Nahi Dena Padega

Screen Shot 2022-10-09 at 9 04 27 PM
Screen Shot 2022-10-09 at 9 04 39 PM
Screen Shot 2022-10-09 at 9 04 53 PM
Screen Shot 2022-10-09 at 9 05 13 PM

Screen Shot 2022-10-09 at 9 06 20 PM
Screen Shot 2022-10-09 at 9 06 25 PM
Screen Shot 2022-10-09 at 9 06 35 PM
Screen Shot 2022-10-09 at 9 07 11 PM
Screen Shot 2022-10-09 at 9 07 44 PM
Screen Shot 2022-10-09 at 9 09 24 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment