Posts

Showing posts from October, 2022

Top 7 ways to use Interceptors in Angular

  Top 7 ways to use Interceptors in Angular It Intercepts and handles an HttpRequest or HttpResponse. Most interceptors convert the outgoing request before passing it on to the next interceptor in the chain. Handle (transformed rake). An interceptor can also alter the response event stream by applying additional RxJS operators to the stream returned by the next.take care (). An interceptor may rarely fully handle the request and create a new event stream instead of invoking nextHandle(). This is acceptable behavior, but be aware that further interceptors will be skipped altogether. interface HttpInterceptor {     intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>   }   It is rare but valid for an interceptor to return multiple responses on the event stream for a single request. 1. Authentication And first on the list is authentication! It is just so fundamental for many applications that we have a pro...

Angular clear all console logs in production

Image
  Angular – Clear All of Your Console Logs in Production Build with Just a Few Lines of Code When we were developing an application, we probably add a lot of console.log statements everywhere in the code. Sometimes we display such kind of information that your users are not supposed to see, but you think that you're good because most users will not press F12 (most of the time). Showing console logs is not a good practice,it is a creazy thing actually in the production.So we recommend not to use console logs in production. Then question comes,How to remove console.log from production. I will show you a trick where you can remove all your console log statements, when in development mode, and clear all of it when in production mode. Go to your main.ts file and add this: if (environment.production) {   enableProdMode();   if(window){     window.console.log=function(){};   } } Now you have a clean all console log from your code at once, when you build your app ...

AWS EC2 – FileZilla access to upload files on EC2 instance

Image
 AWS EC2 – FileZilla access to upload files on EC2 instance 1.3.1. Download FileZilla (https://filezilla-project.org/download.php?type=client) 1.3.2. Open File > Site Manager > New site 1.3.3. In Host put EC2 public IPv4 DNS 1.3.4. Select Logon type as Key File 1.3.5. Enter User as Ubuntu 1.3.6. Browse key file 1.3.7. Hit connect button 1.3.8.Now you will be successfully SSH to EC2 instance To stay updated for my upcoming blogs,Please do follow my blogspot as well as my Youtube Channel link below https://www.youtube.com/channel/UCMTJnNFqSYzlJsp0Tzu9BDA Thanks For your valuable time to read my blogs.....!!!!!

How to SSH AWS EC2 instance?

Image
 How to SSH AWS EC2 instance? 1.2.1. We are going to use putty to SSH into EC2 1.2.2. Download Putty and Install (https://www.putty.org/) 1.2.3. To connect using Putty we required .ppk file. 1.2.4. Let’s create .ppk file using .pem file generated in Step 1.1.5 1.2.5. Click on PuTTYgen -> File > Load Private Key -> select .pem file created in Step 1.1.5 -> Save Private Key -> Yes -> Save create ppk file in secure location 1.2.6. Open 1.2.5. Click on PuTTYgen -> File > Load Private Key -> select .pem file created in Step 1.1.5 -> Save Private Key -> Yes -> Save create ppk file in secure location 1.2.6. Open Putty 1.2.7. Enter Hostname as EC2 public IPv4 DNS (ubuntu@hostname as Ubuntu is default username) 1.2.8. Expand SSH > Auth and select Private key file for Authentication (.ppk file generated in 1.2.5) 1.2.9. Click on Open to start SSH 1.2.10. Enter sudo su – to get root access

How to create EC2 instance on AWS

Image
 How to create EC2 instance on AWS 1.1. Create EC2 Instance      1.1.1. Click on Launch Instances     1.1.2. Click      1.1.2. Click on Ubuntu Server `1.1.3. Select t2.micro and then click on Review and Launch      1.1.4. Click on Launch      1.1.5. Create New Key pair or existing one (Please note to save      .pem file to some secure location on your computer) and then           click on Launch Instances      1.1.6. Now Click on View Instances to see newly created                          instances      1.1.7. Instances List      1.1.8. Now click on respective Instance ID and then go to                Security tab to see security groups assigned to instance      1.1.9. Now click on Secu...

Route Web Server Request to App server through proxy

Image
 Route Web Server Request to App server through proxy Step 1 – Download and install required dependency on IIS Server  Application Request Routing Module Download URL: - https://www.microsoft.com/en-us/download/details.aspx?id=47333  URL Rewrite Module Download URL: - https://www.microsoft.com/en-in/download/details.aspx?id=7435 Step 2 – Configure ARR as a Forward Proxy  To enable ARR as a proxy, and to create a URL Rewrite rule to enable ARR as a forward proxy, proceed as follows:  1. Open Internet Information Services (IIS) Manager.  2. In the Connections pane, select the server.  3. In the server pane, double-click Application Request Routing Cache 4. In the Actions pane, click Server Proxy Settings. 5. On the Application Request Routing page, select Enable proxy. 6. In the Actions pane, click Apply. This enables ARR as a proxy at the server level. 7. To start the process of turning ARR into a forward proxy, click on the server node in the Connections pane ...

(Resolved) Unknown collation: utf8mb4_0900_ai_ci

Image
  (Resolved) Unknown collation: utf8mb4_0900_ai_ci A collation is a set of rules that defines how to compare and sort character strings in a database server. In this tutorial, we are discussing an error faced during database restoration on another server. To get latest videos on such issues click on below link and subscribe the Youtube channel.Thank You..!! https://www.youtube.com/channel/UCMTJnNFqSYzlJsp0Tzu9BDA Problem During the migration of a web application, I got the below error while restoring a database on another server. The collation id may differ based on the MySQL version. Error message: Error 1273 (HY000) at line 25 Unknown collation: 'utf8mb4_0900_ai_ci' Here you go with a solution. Solution After a little investigation, I found that the MySQL server running on the destination is an older version than the source. So we got that the destination server doesn’t contain the required database collation. Then we do a little tweak in the backup file to resolve this. Edit...

The Regular Expression (RegEx) Cheat Sheet

Image
  The Regular Expression (RegEx) Cheat Sheet This is a cheat sheet that provides the most common RegEx use cases that will help you whenever need a sneak peek at the Regex syntax!

Implement CanActivate route guard in Angular – Auth Guard

  Implement CanActivate route guard in Angular  – Auth Guard Angular allows us to protect routes with guards. An angular Route guard is a way of protecting navigation by allowing or denying a route based on the condition we supply. The most commonly used angular route guard types are CanActivate and CanDeactivate. Angular has several guard interfaces that allow us to mediate navigation to and from a route. Different types of Angular auth guard in Angular ng g guard my-new-guard guard-type CanActivate:  Checks to see if we can visit a route based on condition. First, you need to create a route guard. Run the following command in your terminal to generate a guard service: ng g guard admin/admin Two  src/app/admin/admin.guard.spec.ts  and  src/app/admin/admin.guard.ts  files will be generated. Open the  src/app/admin/admin.guard.ts  file, you should see the following code: import { Injectable } from '@angular/core'; import { CanActivate, Activat...