Tuesday, November 17, 2020

How to find the angular component name ?

 

Use ng.probe($0).componentInstance

You can select a component using the Element Selector from the Elements Tab. And then go to the Console Tab, and type in:

ng.probe($0).componentInstance

Saturday, October 31, 2020

Where to find the files after ng build in angular

Once you run the ng build --prod for deployment build and you are wondering after successfully from where to copy files to deployment. 

You can check path on following setting where its mentioned in angular.json file. 

"outDir": "./location/toYour/dist"

Monday, October 26, 2020

How to remove all elements from JavaScript Array ?

 In case you have an array in JavaScript and you want to remove all elements from that array , there are couple of ways by which you can remove all elements from your array. 


#1 

Arr = [];
#2 

 Arr.length = 0

#3 
 
 Arr.splice(0,Arr.length)

#4 
  
while(Arr.length > 0) {
    Arr.pop();
}





Sunday, October 25, 2020

Import MySQL Dump file using MySQL Command Line tool in windows 10

 

It really pain and may be you are facing same kind of issues which i faced so far to import mysql dump file using MySQL Command line tool in windows 10. 

You will be able to find multiple posts about SOURCE command you need to use but here certain things which might you also not able to find and still struggling with proper information. 


So easy solution here is : 


mysql> use db_name;

mysql> SET autocommit=0 ; source the_sql_file.sql ; COMMIT ;

But few catches here : 
First Catch : 

Just use the absolute path of the file and then, instead of using backslashes, use forward slashes.

Example:

with backslashes : source C:\folder1\metropolises.sql
with forward slashes : source C:/folder1/metropolises.sql



Second Catch : 

 filename must not be in quotes even if it contains spaces in name or path to file.



Wednesday, October 21, 2020

Remove all packages from a specific project within a solution

 Be careful: This will uninstall ALL packages in the project. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package -ProjectName "YourProjectName" | 
Uninstall-Package -ProjectName "YourProjectName" -RemoveDependencies -Force

Remove all packages from all projects in the solution

 Be careful: This will uninstall ALL packages in the solution. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package | Uninstall-Package -RemoveDependencies -Force

Thursday, January 2, 2020

How to check the value of observable in console.log ?

With a regular observable you only get the value when it changes, so if you want to console.log out the value you will need to console.log it in the subscription:



  this.buyer12Org$ = this.GetOrg();
  this.buyer12Org$.subscribe((res=> console.log('buyer12'res));

Saturday, August 17, 2019

package-lock-json vs package-json

package-lock.json: records the exact version of each installed package which allows you to re-install them. Future installs will be able to build an identical dependency tree.
package.json: records the minimum version you app needs. If you update the versions of a particular package, the change is not going to be reflected here.

Thursday, August 15, 2019

Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...?

class App extends React.Component {
render() {
return (
<Header />
<Content/>
);
}
}

This code throw error as follow :

./src/App.js
  Line 9:  Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?

   7 |     return (
   8 |     
> 9 | | ^ 10 | ); 11 | } 12 | }

to solve that error that you need to put your component tags into elclosing tags
like this
return (
    <div>
       <Comp1 />
       <Comp2 />
    </div>
)
or you can use the <React.Fragment>
return (
    <React.Fragment>
       <Comp1 />
       <Comp2 />
    </React.Fragment>
) 

https://reactjs.org/docs/fragments.html 






Error : verbose stack Error: ENOENT: no such file or directory, open 'Roaming\npm-cache\_npx\1768\package.json


When running npx (with any arguments, but -v is easiest to test) from the global install folder, the following error is produced.




The above error is due the white space contain in your username of PC. The command npx create-react-app doesn't work in this situation and shows error.

Solution : 


  1. run npm config edit to edit your config
  2. change cache path,e.g.
    from cache=D:\program file\npm-cache to cache=D:\progra~1\npm-cache



Thursday, August 13, 2015

how-can-i-remove-duplicate-rows

;WITH cte
     AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3 
                                       ORDER BY ( SELECT 0)) RN
         FROM   #MyTable)
DELETE FROM cte
WHERE  RN > 1

nth max salary in sql

WITH CTE AS
(
    SELECT EmpID,EmpName,EmpSalar,
           RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
    FROM dbo.Salary
)
SELECT EmpID,EmpName,EmpSalar
FROM CTE
WHERE RN = @NthRow

Monday, August 10, 2015

interface with same method name in c#










interface IPrinter
    {
        void print(string a);
    }

    interface IPrinter1
    {
        void print(string a);
    }




class Program
    {
        static void Main(string[] args)
        {
            IPrinter p = new Printer();
            p.print("rahul");

            Printer p1 = new Printer();
            ((IPrinter)p1).print("overlaoded");
        }
      
    }

    class Printer : IPrinter, IPrinter1
    {
         void IPrinter.print(string a)
        {
            Console.Write(a + "Printer");
            Console.ReadLine();
        }

         void IPrinter1.print(string a)
        {
            Console.Write(a+"Printer1");
            Console.ReadLine();
        }
    }

Thursday, July 9, 2015

difference between save and insert in mongodb



If the document contains an _id field, then the save() method performs an upsert querying the collection on the _id field:
If a document does not exist with the specified _id value, the save() method performs an insert with the specified fields in the document.
If a document exists with the specified _id value, the save() method performs an update, replacing all field in the existing record with the fields from the document.

Tuesday, May 26, 2015

Child Actions in ASP.NET MVC


Child Actions are the action methods which can be invoked within the view. This is used to work with the data in the view, which are not related to the main action method. For example, if you want to create a data driven widget in the view using data that is not related to the main action method, you will need to use the child action method.
In ASP.NET MVC any action can be used as a child action. However, to use an action only as a child action and attribute it with the ChildActionOnly. It will make sure the action is not called by any user request and will only be used in the view. A child action can be created as shown below:
This child action returns a partial view with the current time as the data in the partial view. The partial view is created as below:
CurrentTime.cshtml
In the main view, the child action can be used as shown below:
Above we are using child action from the same controller in which the main action is defined. To use child actions from a different controller, you have the option of passing the controller name as well. You can also pass input parameters to the child action. To demonstrate this, let us create the child action with an input parameter as follows:
In the view, a parameter can be passed to the child action as follow:
You may consider using the child action method in the following scenarios,
  • To use data in the view which is not related to the main controller
  • To create data driven widgets to be used on different views

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...