Posts

Showing posts from September, 2022

JS Hack🤯: Error handling using both .then and .catch is same !?

Image
In this Blog we will see that is there any difference in doing Error handling(catching error) through .then and .catch. FACT : The second parameter for .then is for catching the errors 🤯, don't believe me?, see yourself.   CODE const promise1 = new Promise((resolve, reject) => {      //resolve('Success!');      oihrg; //this line is intentionally written to produce error.      //reject('failed!'); }); promise1.then (     (value) => {          console.log(value); // expected output: "Success!"     }     , // this comma separates both arguments of .then     (err) => console.log("An error catched inside .then - ",err) //👈this is it ! ) .catch (err => console.log("catched by .catch - ",err)); OUTPUT "An error catched inside .then - " ReferenceError: oihrg is not defined    NOTE :- Precedence is given to the second second argument of .then over .catch i.e. if a Promise fails then it'll be first catched inside th

Callbacks, Promises, async, await, try, catch - Heart of Javascript

Image
Callbacks, Promises, async, await, try, catch - Heart❤️ of JavaScript The whole purpose boils down to having Synchronous or Non-Blocking code and let's understand it now, 👇 Most Important thing - Why? - Why we at all need Callbacks, Promises, Async, Await ? Because JavaScript is always in hurry to go through line by line fastly (asynchronous execution). And it differentiate with the code, will talk about this later also. It instantly executes and completes one part of code and doesn't another by skipping on it. Firstly, let's see which kind of code gets executed instantly with no need of extra time ⏩. (doesn't asks for "time-please"). Work                                                                                      Identifiers Initialization and Updation of Variables               let myUser= "Binod", let users = [], users.push(myUser); Loops                                                                                      for(let user of

My Advice to my Juniors, My Biggest College mistakes - Raw

Image
My Advice 🙌 to my🧑‍💻Juniors, My Biggest College mistakes ! I finally gather some courage to concisely speak about my whole, both exciting&boring college journey.   Short but Complete Journey : here you go - What went well ? The half part! First year and second year, I interacted to my class buddies, seniors, teachers through various activities, competitions, platforms and clubs. Attended and Explored every practical session that was possibly happening. That's how I gathered some like minded people around me. "Tried to be like a Rancho of 3 Idiots" - :p At second year end I happen to stumble upon an internship, went to Noida, learned a lot of DSA. Overall Had an exciting Super Human college life, learned adv. Robotics, DSA, One Hackathon Winning experience, Patent writing, Inventorship (btw I miserably  failed very fast trying to pull off a Startup and have a team:p - That marked the end of many above things). What went wrong ? Worry-less innocent life and non-harmi

MongoDB Basics and mongo Shell Commands

Image
MongoDB Basics and mongo Shell Commands NO SQL database. Data is stored as BSON format (i.e. same as our good old JSON but more optimized, see picture!) Comparison with RDBMS: Database = "Database" Tables = "Collections" Rows = "Document"   mongo vs mongod -> mongo A Programmer writes Commands in this Shell. Automatically starts at 27017 port of our local host The Command line S hell that connects to specific instance of "mongod" (mongoDataBase). -> mongod The Host Process of our Database.     FUN FACT :- mongo was also called mongosh before. Handy mongo shell commands. db =>    shows the current working db   use name_of_the_database   =>   creates(if it doesn't exist)  or switches(if it already exists) to the named database   show dbs =>   shows all databases   db.dropDatabase()   deletes the current working db show collections =>   shows all collections       FACT - A database doesn't count to be made if it doesn&

Free & Easy Designing tools for a Software Developer

Image
A. Free(copyright free) images are always good to have. For free stock image we can use pixabay.com , pixels.com , unsplash.com B. Illustrations always helps your user on how to use and navigate through your software product. For free illustrations we use undraw illustrations. icons8.com/illustrations , undraw.co/illustrations , C. Icons and logos are an essential part of our product. For icons and illustrations we use iconmaster , font awesome , easyicon D. Nowadays gradients can be seen everywhere. They give an elegant design to our product. For simple 2D gradients we use ui gradients and coolors.co E. Free designs are always a plus to give you different design ideas. For viewing web/app designs we can use: dribbble.com , or can just google search for “web/app templates”. F. Best free offline image editing software : paint.net (comparable to adobe photoshop) G. Canva.com and figma.com : Best online designing platform to do all of the above stuff. H. For maki

Run Remote Code on Server with pm2

Image
Run Remote Code on Server with pm2 - Simple There are Broadly two types of code:- 1. CRON based (a code which run itself after sometime continuously) 2. Server based Now,     # Deploying Backend Code Steps: 1. Clone the Repository using https. 2. Checkout to your preferable branch. 3. Install all dependencies using npm i 4. Configure pm2 and start the server.  that's all! Process: 1. git clone "https://......" 2. git checkout "branchName" 3. npm i 4. pm2 start "Entry point file path" --name "server name"     For example if your entry point file is app.js then the above command will look like - pm2 start app.js --name backend Tips  * Use command pm2 list to track your recently started server and it's pm2 ID. * Use command pm2 logs "pm2 ID" to check the logs for any error/s.   # Deploying Frontend Code Steps: 1. Clone the repository using https. 2. Checkout to your preferable branch 3. Install all dependencies using npm i 4. Run t