Skip to main content

Posts

array-rotation-to-left-by-given-distance-d

array-rotation-to-left-by-given-distance-d Array left rotation by a given number d Array left rotation by a given number d Step 1: Take two pointers 1. i = 0 2. j = arr[length] Step 2: 1. Swap index of all elements from i to d. 2. Swap index of all elements from d+1 to arr[length]. Step 3: Swap index of all elements from i to arr[length].

Git : Ignore changes to a file that is already tracked in repository

If you are trying to ignore changes to a file that's already tracked in the repository (e.g. a dev.properties file that you would need to change for your local environment but you would never want to check in these changes) than what you want to do is: git update-index --assume-unchanged If you wanna start tracking changes again git update-index --no-assume-unchanged Reference Reading If you are trying to ignore changes to a file that's already tracked in the repository (e.g. a dev.properties file that you would need to change for your local environment but you would never want to check in these changes) than what you want to do is: ``` git update-index --assume-unchanged ``` If you wanna start tracking changes again ``` git update-index --no-assume-unchanged ``` [Reference Reading](https://www.kernel.org/pub/software/scm/git/docs/git-update-index.html)

Angular : How to start angular CLI on custom port

How to start Angular 2 Application on a Custom port other than 4200 You can start the angular project using the angular cli using command ng serve The above command will start the project on port 4200 . If you want to start the application on a prot different that 4200 then you can start the project using the following command. ng serve --port <port-number> where <port-number> can be any valid port that is not in use.

Angular : How to Inject Nested Service in Component

How to Inject Nested Services in Component Let's create a service url.service.ts that will will be injected in other services. import { Injectable } from '@angular/core' ; @Injectable () export class UrlService{ // business logic } Now lets create another service http.service.ts that will Inject this service. import { UrlService } from './url.service.ts' ; export class HttpService extends UrlService{ // business logic } Now, we need to inject the HttpService in some component to make http calls. So now we can inject the HttpService in component as shown below. import { Component ,OnInit } from '@angular/core' ; import { UrlService } from './url.service.ts' ; import { HttpService } from './http.service.ts' ; @Component ({ selector : 'some-selector' , templateUrl : 'some.html' , providers: [HttpService, UrlService] }) export class SomeComponent implements OnInit{ // busin

Angular : Getting started with Angular with Angular CLI, Installation and Hello World Example

Install and Setup Angular Before we start, lets install the angular cli with the following command npm install -g @angular/cli Angular CLI is a tool that can make a new project, compile your typescript files, configure your typescript compiler run your code with live preview, build and package your project. Note Make sure you have latest node and npm installed, at least node version 6.9.x and npm version 3.x.x . To see the versions you can run commands node -v and npm -v for node and npm versions respectively. Warning While installation you might get the following warning npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/@angular/cli/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) You can sk