<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Indira Raghavan on Medium]]></title>
        <description><![CDATA[Stories by Indira Raghavan on Medium]]></description>
        <link>https://medium.com/@indira-raghavan?source=rss-d3d4bd36394e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WxrJODflJ0wWyFsW.jpg</url>
            <title>Stories by Indira Raghavan on Medium</title>
            <link>https://medium.com/@indira-raghavan?source=rss-d3d4bd36394e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:21:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@indira-raghavan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[msal-angular Authenticating Angular app with Azure Active Directory]]></title>
            <link>https://indira-raghavan.medium.com/msal-angular-authenticating-angular-app-with-azure-active-directory-88ae21301cc6?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/88ae21301cc6</guid>
            <category><![CDATA[aml]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[azure-active-directory]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Thu, 22 Jul 2021 18:42:52 GMT</pubDate>
            <atom:updated>2021-07-22T18:42:52.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*w9bG0xJeUZFjMnuwXXjEkA.png" /><figcaption>Authentication Sequence Flow Diagram</figcaption></figure><p>We can achieve Angular app to authenticate with Azure Active Directory in 2 parts.</p><p>Complete App registration with Active Directory.</p><p>Utilize the above app registration to implement authentication of the user using the Microsoft Authentication Library (MSAL).</p><p>App Registration:</p><p>Here are the steps to create SPA app registration got PKCE(Proof Key for Code Exchange) flow:</p><ol><li>Sign in to the <a href="https://portal.azure.com/">Azure portal</a>.</li><li>Open Azure Active Directory.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*kVqUzY5Cy2s9Se2IDt4Frg.png" /></figure><p>Under Manage, select App registrations &gt; New registration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*ZhnurL9LGi99_FmK02dquw.png" /></figure><p>Enter a Name for your application. Users of your app might see this name, and you can change it later. Select Register to create the app registration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*1OEMWJaDwP0MITYJ5Tn1Uw.png" /></figure><p>Once Registered, you can get the Authority, ClientId and TenantID for your application. These are important to be included in your SPA for the authentication process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*-HpV91YxndVHXGAY7AREKA.png" /></figure><p>Let’s move on to the Angular app, If you already have an app great. Or we can quickly build one using angular cli</p><pre>ng new angular-msal-authentication<br>npm install @azure/msal-browser @azure/msal-angular@latest</pre><p>This is just a plain angular app, default with no other html or custom code in it. The above 2 packages provide the code necessary to complete the authentication process.</p><p>Add the following code to app.module.ts</p><pre>import { HTTP_INTERCEPTORS } from &#39;<a href="http://twitter.com/angular/common">@angular/common</a>/http&#39;;<br>import { IPublicClientApplication, PublicClientApplication, InteractionType, BrowserCacheLocation, LogLevel } from &#39;<a href="http://twitter.com/azure/msal-browser">@azure/msal-browser</a>&#39;;<br>import { MsalGuard, MsalInterceptor, MsalBroadcastService, MsalInterceptorConfiguration, MsalModule, MsalService, MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalGuardConfiguration, MsalRedirectComponent } from &#39;<a href="http://twitter.com/azure/msal-angular">@azure/msal-angular</a>&#39;;</pre><pre>export function loggerCallback(logLevel: LogLevel, message: string) {<br>  console.log(message);<br>}</pre><pre>const isIE = window.navigator.userAgent.indexOf(&quot;MSIE &quot;) &gt; -1 || window.navigator.userAgent.indexOf(&quot;Trident/&quot;) &gt; -1;</pre><pre><strong>// Creates custom client application to implement login <br>// functionality<br>export function MSALInstanceFactory(): IPublicClientApplication {<br>  return new PublicClientApplication({<br>    auth: {<br>      clientId: &#39;&lt;client-id&gt;&#39;,<br>      authority: &#39;</strong><a href="https://login.microsoftonline.com/"><strong>https://login.microsoftonline.com/</strong></a><strong>&lt;tenant-id&#39;,<br>      redirectUri: &#39;</strong><a href="https://localhost:4200&#39;"><strong>https://localhost:4200&#39;</strong></a><strong><br>    },<br>    cache: {<br>      cacheLocation: BrowserCacheLocation.LocalStorage,<br>      storeAuthStateInCookie: isIE, // set to true for IE 11<br>    },<br>    system: {<br>      loggerOptions: {<br>        loggerCallback,<br>        logLevel: LogLevel.Info,<br>        piiLoggingEnabled: false<br>      }<br>    }<br>  });<br>}</strong></pre><pre><strong>// provides authRequest configuration<br>export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {<br>  const protectedResourceMap = new Map&lt;string, Array&lt;string&gt;&gt;();<br>  protectedResourceMap.set(&#39;</strong><a href="https://graph.microsoft.com/v1.0/me&#39;"><strong>https://graph.microsoft.com/v1.0/me&#39;</strong></a><strong>, [&#39;user.read&#39;]);</strong></pre><pre><strong>return {<br>    interactionType: InteractionType.Redirect,<br>    protectedResourceMap<br>  };<br>}</strong></pre><pre><strong>export function MSALGuardConfigFactory(): MsalGuardConfiguration {<br>  return { <br>    interactionType: InteractionType.Redirect,<br>    authRequest: {<br>      scopes: [&#39;user.read&#39;]<br>    }<br>  };<br>}</strong></pre><pre><a href="http://twitter.com/NgModule">@NgModule</a>({<br>  declarations: [<br>    AppComponent    <br>  ],<br>  imports: [<br>    BrowserModule,<br>    AppRoutingModule,    <br>    HttpClientModule,<br>    <strong>MsalModule</strong><br>  ],  <br>  providers: [<br>    <strong>{<br>      provide: HTTP_INTERCEPTORS,<br>      useClass: MsalInterceptor,<br>      multi: true<br>    },<br>    {<br>      provide: MSAL_INSTANCE,<br>      useFactory: MSALInstanceFactory<br>    },<br>    {<br>      provide: MSAL_GUARD_CONFIG,<br>      useFactory: MSALGuardConfigFactory<br>    },<br>    {<br>      provide: MSAL_INTERCEPTOR_CONFIG,<br>      useFactory: MSALInterceptorConfigFactory<br>    },<br>    MsalService,<br>    MsalGuard,<br>    MsalBroadcastService</strong><br>  ],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Add the login and Accesss token request code in app.component.ts file</p><pre>import { Component, Inject, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;</pre><pre>import { NavigationEnd, Router } from &#39;<a href="http://twitter.com/angular/router">@angular/router</a>&#39;;<br>import { MSAL_GUARD_CONFIG, MsalGuardConfiguration, MsalService, MsalBroadcastService } from &#39;<a href="http://twitter.com/azure/msal-angular">@azure/msal-angular</a>&#39;;<br>import { AuthenticationResult, InteractionStatus, InteractionType, PopupRequest, RedirectRequest, SilentRequest } from &#39;<a href="http://twitter.com/azure/msal-browser">@azure/msal-browser</a>&#39;;<br>import { Subject } from &#39;rxjs&#39;;<br>import { filter, takeUntil } from &#39;rxjs/operators&#39;;<br>var ga: any;<br><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;]<br>})<br>export class AppComponent implements OnInit {<br>  title = &#39;Portfolio&#39;;<br>  isIframe = false;<br>  loginDisplay = false;<br>  private readonly _destroying$ = new Subject&lt;void&gt;();</pre><pre>constructor(public router: Router,<br>    <a href="http://twitter.com/Inject">@Inject</a>(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration,<br>    private authService: MsalService,<br>    private msalBroadcastService: MsalBroadcastService<br>  ) {}</pre><pre>ngOnInit(){    <br>    this.isIframe = window !== window.parent &amp;&amp; !window.opener;</pre><pre><strong>this.msalBroadcastService.inProgress$<br>      .pipe(<br>        filter((status: InteractionStatus) =&gt; status === InteractionStatus.None),<br>        takeUntil(this._destroying$)<br>      )<br>      .subscribe(() =&gt; {<br>        this.setLoginDisplay();<br>        this.login();<br>      });    <br>  }</strong></pre><pre>setLoginDisplay() {<br>    this.loginDisplay = this.authService.instance.getAllAccounts().length &gt; 0;</pre><pre>console.log(this.loginDisplay);<br>  }</pre><pre><strong>login() {    <br> if (this.msalGuardConfig.authRequest &amp;&amp; this.loginDisplay){<br>      this.msalGuardConfig.authRequest.account = this.authService.instance.getAllAccounts()[0];<br>      this.authService.acquireTokenSilent({...this.msalGuardConfig.authRequest} as SilentRequest)<br>        .subscribe((response: AuthenticationResult) =&gt; {<br>          this.authService.instance.setActiveAccount(response.account);<br>          console.log(response.accessToken);<br>          console.log(this.authService.instance.getAllAccounts());<br>        });<br>      } else {<br>        this.authService.loginRedirect();<br>    }  <br>  }</strong></pre><pre>logout() {<br>    this.authService.logout();<br>  }</pre><pre>ngOnDestroy(): void {<br>    this._destroying$.next(undefined);<br>    this._destroying$.complete();<br>  }<br>}</pre><p>modify app-routing.module.ts</p><pre>import { NgModule } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { Routes, RouterModule } from &#39;<a href="http://twitter.com/angular/router">@angular/router</a>&#39;;<br>import { MsalGuard } from &#39;<a href="http://twitter.com/azure/msal-angular">@azure/msal-angular</a>&#39;;</pre><pre>const routes: Routes = [<br>  {<br>    path: &#39;**&#39;,<br>    component: HomeComponent,<br>    canActivate: [<br>      MsalGuard<br>    ]<br>  }<br>];</pre><pre>const isIframe = window !== window.parent &amp;&amp; !window.opener;<br><a href="http://twitter.com/NgModule">@NgModule</a>({<br>  imports: [RouterModule.forRoot(routes, {<br>    initialNavigation: !isIframe ? &#39;enabled&#39; : &#39;disabled&#39;<br>  })],<br>  exports: [RouterModule]<br>})<br>export class AppRoutingModule { }</pre><p>That’s it. Now when we run the code. This will be workflow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*YU7DqZGxy9K7OhlCUtOWqQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88ae21301cc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular *ngFor a deep-dive]]></title>
            <link>https://indira-raghavan.medium.com/angular-ngfor-a-deep-dive-c9580cbee22b?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9580cbee22b</guid>
            <category><![CDATA[ngclass]]></category>
            <category><![CDATA[angular-directive]]></category>
            <category><![CDATA[ngfor]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 15:32:44 GMT</pubDate>
            <atom:updated>2021-01-04T15:32:44.302Z</atom:updated>
            <content:encoded><![CDATA[<p>Less known variables usage of *ngFor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xeYcM1dmron7badzdJWn_g.png" /><figcaption>Photo courtesy: <a href="https://malcoded.com/static/047bfa202ead56f5b368ddc443072d86/ba299/angular-ngfor.png">https://malcoded.com/static/047bfa202ead56f5b368ddc443072d86/ba299/angular-ngfor.png</a></figcaption></figure><h3>Introduction:</h3><p>We all know that *ngFor is a structural directive used to render a template for each item in a collection. *ngFor has a few tricks up its sleeve to make it easy to use and provides variables that reduces template code to render the html.</p><p>Example collection:</p><p>I am going to use the following example collection to show different variables and its usage.</p><p>Collection:</p><pre>public tempCollection = new Array&lt;string&gt;();</pre><pre>constructor() { }</pre><pre>ngOnInit() {</pre><pre>  this.tempCollection.push(&quot;Cur Temp: -4°C&quot;);      <br>  this.tempCollection.push(&quot;Max Temp: 1°C&quot;);  <br>  this.tempCollection.push(&quot;Min Temp: -4°C&quot;);  <br>  this.tempCollection.push(&quot;Real Feel: 1°C&quot;);</pre><pre>}</pre><p>Basic template:</p><pre>&lt;div class=&quot;row text-center&quot;&gt;<br>  &lt;div class=&quot;col-12 px-4 text-center&quot;&gt;<br>    &lt;div <br>        class=&quot;mt-1 mb-1 notice notice-secondary shadow bg-light <br>               text-dark w-25&quot; <br>        <strong>*ngFor=&quot;let temp of tempCollection&quot;</strong>&gt;{{temp}}<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt; </pre><p>Rendered template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*OuEu6uQKGfgzIVQIolKhMQ.png" /><figcaption>Plain *ngFor</figcaption></figure><p><strong>Index:</strong></p><p>Index is commonly used in *ngFor implementation to keep track of the index in the collection. Here I am attempting to add serial numbers(index numbers) for the collection.</p><pre>&lt;div class=&quot;row text-center&quot;&gt;<br>  &lt;div class=&quot;col-12 px-4 text-center&quot;&gt;<br>    &lt;div <br>        class=&quot;mt-1 mb-1 notice notice-secondary shadow bg-light <br>               text-dark w-25&quot; <br>        <strong>*ngFor=&quot;let temp of tempCollection; <em>let i=index</em>&quot;</strong>&gt;<br>        {{i + 1 + &quot;) &quot;}}{{temp}}<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Rendered template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*m5hO2aI_CrZuL9THh092pg.png" /><figcaption>With index as serial numbers</figcaption></figure><p><strong>First and Last:</strong></p><p>What if I want to add a specific formatting for only first element in the above list or only the last element. We can use *ngClass directive and the variable first/last exposed by *ngFor to identify the first or last element.</p><pre>&lt;div class=&quot;row text-center&quot;&gt;<br>  &lt;div class=&quot;col-12 px-4 text-center&quot;&gt;<br>    &lt;div <br>        class=&quot;mt-1 mb-1 notice notice-secondary shadow bg-light <br>               text-dark w-25&quot; <br>          <strong>*ngFor=&quot;let temp of tempCollection; let i=index; <br>                  let first=first; let last=last;&quot;  <br>          [ngClass]=&quot;{ &#39;text-success&#39;: first, &#39;text-danger&#39;: last }&quot;</strong><br>&gt;<br>        {{i + 1 + &quot;) &quot;}}{{temp}}<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Rendered template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*DzJcGXVR4abQhH1at2suHw.png" /><figcaption>first item has text-success, last item has text-danger class applied to them</figcaption></figure><p>Even and Odd:</p><p>Let’s say I want to add certain background based on the even or odd index number. We can use *ngclass to render striped html for even/odd items in the collection.</p><pre>&lt;div class=&quot;row text-center&quot;&gt;<br>  &lt;div class=&quot;col-12 px-4 text-center&quot;&gt;<br>    &lt;div <br>        class=&quot;mt-1 mb-1 notice notice-secondary shadow bg-light <br>               text-dark w-25&quot; <br>          <strong>*ngFor=&quot;let temp of tempCollection; let i=index; <br>                  let even=even; let odd=odd;&quot;<br>          [ngClass]=&quot;{ &#39;bg-info&#39;: even, &#39;bg-warning&#39;: odd }&quot;</strong></pre><pre>&gt;<br>        {{i + 1 + &quot;) &quot;}}{{temp}}<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Rendered template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*y8ZIb8J5EkIUgjuW5y1a4g.png" /><figcaption>even items has bg-info and odd items has bg-warning class applied to them.</figcaption></figure><h3>In conclusion:</h3><p><a href="https://angular.io/api/common/NgForOf">NgForOf</a> provides exported values that can be aliased to local variables. The above examples provide simple way to understand the local variables. Have fun using the variables to render different templates!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9580cbee22b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Server on Docker]]></title>
            <link>https://indira-raghavan.medium.com/sql-server-on-docker-7fa3fec44472?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fa3fec44472</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Tue, 22 Dec 2020 18:46:01 GMT</pubDate>
            <atom:updated>2020-12-22T18:46:01.352Z</atom:updated>
            <content:encoded><![CDATA[<p>Ease of having containerized SQL server for isolated programming</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YYOPZ439o0KECWO9PIuQNw.png" /></figure><p>Often programming teams use a single SQL server for their coding work. This limits how much a developer can find creative solutions for the problem at hand. What if we can isolate a copy specifically for the developer, and maintain the integrity of the SQL server for the rest of team? What if we do not need to install SQL server instance running on your local computer? SQL Server can be run on any platform by leveraging container technology. Let’s look at how to setup a SQL Server database inside of a Docker container.</p><h3>Prerequisites:</h3><ol><li>Docker Desktop</li><li>Powershell</li></ol><h3>Install docker desktop:</h3><p><a href="https://docs.docker.com/docker-for-windows/install/">Install Docker Desktop on Windows</a></p><h3>Let’s get started:</h3><p>With the use of only 2 docker commands, we can have a localhost instance of SQL server to connect to.</p><p>The first command pulls mssql image to your local container.</p><pre>docker pull <a href="http://mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04">mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*ITbKu0ZuiywoW7wbLGDKmQ.png" /></figure><p>The 2nd command creates a local DB with the name my-local-db. Now you can connect to the database using SQL Server management studio.</p><pre>docker run -d -e &quot;ACCEPT_EULA=Y&quot; -e &quot;SA_PASSWORD=Str0ngPwd&quot; --name &quot;my-local-db&quot; -p 1433:1433 <a href="http://mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04">mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04</a></pre><pre>docker ps -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*1aGfMe9gR4PQBWS9gZUySw.png" /></figure><p>As you can see, you have a container hosting your SQL DB, locally.</p><h3>Connect to localhost:</h3><p>To view your container images Visual Studio provides container window</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*05nObKiLbEID1meEkshV7w.png" /></figure><p>To connect using SQL server management studio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*MBe76j8_pQVwOqYmHZvIeQ.png" /></figure><p>Now you can use this as a regular SQL Server, and execute CRUD operations. One thing to remember though, if the containers are removed, the data is lost. If you wish to use this as connection string in your applications:</p><pre>&quot;DbContext&quot;: &quot;Data Source=tcp:localhost,1433;Initial Catalog=my-local-db;Persist Security Info=True;User ID=SA;Password=Str0ngPwd&quot;</pre><h3>In Conclusion:</h3><p>SQL Server can be run on any platform by utilizing container technology. We can drop and recreate tables, databases, functions, stored procedures. This is specially useful to debug docker DB related issues on pipelines. We can load the exact script used in pipelines for unit tests into the local DB and identify the issues with Unit test tasks.</p><p>For more SQL image versions and tags on docker: <a href="https://hub.docker.com/_/microsoft-mssql-server">click here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fa3fec44472" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build & Serve 3rd party Assets and Static files — Angular]]></title>
            <link>https://indira-raghavan.medium.com/build-serve-3rd-party-assets-and-static-files-angular-2fd2e0e010a7?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd2e0e010a7</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[components]]></category>
            <category><![CDATA[component-libraries]]></category>
            <category><![CDATA[angular-cli]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 20:22:54 GMT</pubDate>
            <atom:updated>2020-12-02T20:22:54.744Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build &amp; Serve 3rd party Assets and Static files — Angular</h3><p>Build and serve 3rd party images in your Angular app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*alow47-KtE86sFy1KkgvwQ.png" /></figure><p>Many a times we may need to include 3rd party assets or static files in the consuming angular application. 3rd party could also mean your own private or organization’s component library. Angular provides a way to export the assets for build and serve in your local as well as built files.</p><p>For simplicity I am going to show how to use images from a private component library in the angular app. Lets see how to do this:</p><ol><li>To build and deploy to server: Add glob configuration in angular.json</li><li>To serve locally over localhost:4200: Add Copy command in package.json</li></ol><h3>Build and deploy to server:</h3><p>Let’s say we have our component library installed in angular app:</p><pre>npm install @angular/cli -g<br>ng new TestProject</pre><pre>npm install @myComponentLibrary</pre><p>The above command will add myComponentLibrary under node_modules C:\Workspace\Projects\TestProject\node_modules\myComponentLibrary . All assets are under node_modules\myComponentLibrary\assets\img .</p><p>Let’s go to angular.json and add the glob section to ensure the assets are copied over during build(either on pipeline or for local dist folder).</p><pre>&quot;projects&quot;: {<br>    &quot;test-project&quot;: {<br>      &quot;projectType&quot;: &quot;application&quot;,<br>      &quot;schematics&quot;: {<br>        &quot;<a href="http://twitter.com/schematics/angular">@schematics/angular</a>:component&quot;: {<br>          &quot;style&quot;: &quot;scss&quot;<br>        }<br>      },<br>      &quot;root&quot;: &quot;&quot;,<br>      &quot;sourceRoot&quot;: &quot;src&quot;,<br>      &quot;prefix&quot;: &quot;app&quot;,<br>      &quot;architect&quot;: {<br>        &quot;build&quot;: {<br>          &quot;builder&quot;: &quot;<a href="http://twitter.com/angular">@angular</a>-devkit/build-angular:browser&quot;,<br>          &quot;options&quot;: {<br>            ...<br>            <strong><em>&quot;assets&quot;: [<br>              &quot;src/favicon.ico&quot;,<br>              &quot;src/assets&quot;,<br>              {<br>                &quot;glob&quot;: &quot;**/*&quot;,<br>                &quot;input&quot;:   <br>                    &quot;./node_modules/</em></strong><strong><em>myComponentLibrary/assets/img&quot;,<br>                &quot;output&quot;: &quot;/img/&quot;<br>              }<br>            ],</em></strong><br>            ...<br>          },<br>          &quot;configurations&quot;: {<br>            ...  <br>          }          <br>        },<br>        &quot;serve&quot;: {<br>  ...<br>        }<br>      }<br>    }<br>  },</pre><p>The glob pattern allows you to specify the desired package assets and where to load them in your build. The end result is <a href="https://your.project.url/img/assets">https://your.project.url/img/assets</a> should be able to load component library’s images. The paths are mentioned with src/ as root folder. Angular CLI will write the images to dist/test-project/img . You can also add ignore patterns or some images to filter the static assets.</p><pre>&quot;assets&quot;: [<br>  {<br>    &quot;glob&quot;: &quot;**/*&quot;,<br>    &quot;input&quot;: &quot;src/assets/&quot;,<br>    &quot;output&quot;: &quot;/assets/&quot;<br>  },<br>  {<br>    &quot;glob&quot;: &quot;favicon.ico&quot;,<br>    &quot;input&quot;: &quot;src/&quot;,<br>    &quot;output&quot;: &quot;/&quot;<br>  },</pre><pre>  { <br>   &quot;glob&quot;: &quot;**/*&quot;,<br>   &quot;input&quot;: &quot;src/assets/&quot;,<br>   &quot;ignore&quot;: [&quot;**/*.svg&quot;],<br>   &quot;output&quot;: &quot;/assets/&quot; <br>  }<br>]</pre><h3><strong>Serve locally over localhost:4200:</strong></h3><p>By adding glob configuration in angular.json we ensure that the images get served while accessing through dev or prod sites. To ensure that the same images are being served while running the angular project, we will have to add a copy command for the assets.</p><pre>&quot;scripts&quot;: {<br>    &quot;ng&quot;: &quot;ng&quot;,<br>    <strong>&quot;start&quot;: &quot;npm run copy:assets &amp;&amp; ng serve&quot;,</strong><br>    &quot;build&quot;: &quot;ng build&quot;,    <br>    &quot;lint&quot;: &quot;ng lint&quot;,<br>    &quot;e2e&quot;: &quot;ng e2e&quot;,<br>    <strong>&quot;copy:assets&quot;: &quot;cp -R node_modules/myComponentLibrary/assets/img src/ &quot;,</strong></pre><pre>},</pre><p>Here we add a copy command to copy the assets first and then serve the app locally.</p><h3>In conclusion:</h3><p>By utilizing node-glob and copy assets commands we can import static files and images from component library to serve in your angular app, locally/on server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd2e0e010a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build and Serve Angular apps]]></title>
            <link>https://indira-raghavan.medium.com/build-and-serve-angular-apps-6b2d7ef49368?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b2d7ef49368</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[environment-variables]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[config]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Sun, 29 Nov 2020 03:20:34 GMT</pubDate>
            <atom:updated>2020-11-29T03:20:34.120Z</atom:updated>
            <content:encoded><![CDATA[<p>Build specific options for Angular apps targeting different environments</p><p>Most SPA’s/projects will have different configurations for targeted environments. For e.g., the app will have to make a different API call based on development, staging or production. Angular provides a way to configure the application to introduce build variables for different environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOKr7DGBca-5W8C6ZFkPdQ.png" /></figure><h3>How do I do that?</h3><p>Let’s see how to define variables for different targets:</p><ol><li>Environment files: One for each target environment.</li><li>Serve configuration: Modify angular.json for file replacements</li><li>Script configuration: Add build scripts in package.json</li></ol><h3><strong>Environment files:</strong></h3><p>Each of the files in environments folder contains a mix of keys, API urls, values, production environment indicator. Simply a mix of different information in json format. There is no set keynames to be used. You can define your variables in this files. And it can be accessed across the entire application.</p><p>The same variables are defined on development, staging, production environment files. Angular by default provides 2 files under environments folder, you can add as many as possible based on your requirement.</p><pre>src/environments/<br>           ---environment.ts<br>           ---environment.dev.ts<br>           ---environment.stg.ts<br>           ---environment.prod.ts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*wACLXLcBoHRvTb7-kqmiNw.png" /></figure><h3><strong>Provide file-replacement configurations:</strong></h3><p>The file angular.json provides a lot of config for both running an app locally and building artifacts for the angular app. We need to narrow in on fileReplacements section. This section is defined under production configurations. This provides a way to replace the right environment file based on the target.</p><pre>&quot;<strong>configurations</strong>&quot;: {<br>            &quot;production&quot;: {<br>              <strong><em>&quot;fileReplacements&quot;: [<br>                {<br>                  &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,<br>                  &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;<br>                }</em></strong><br>              ],<br>              &quot;optimization&quot;: true,<br>              &quot;outputHashing&quot;: &quot;all&quot;,<br>              &quot;sourceMap&quot;: false,<br>              &quot;extractCss&quot;: true,<br>              &quot;namedChunks&quot;: false,<br>              &quot;extractLicenses&quot;: true,<br>              &quot;vendorChunk&quot;: false,<br>              &quot;buildOptimizer&quot;: true,<br>              &quot;budgets&quot;: [<br>                {<br>                  &quot;type&quot;: &quot;initial&quot;,<br>                  &quot;maximumWarning&quot;: &quot;2mb&quot;,<br>                  &quot;maximumError&quot;: &quot;5mb&quot;<br>                },<br>                {<br>                  &quot;type&quot;: &quot;anyComponentStyle&quot;,<br>                  &quot;maximumWarning&quot;: &quot;6kb&quot;,<br>                  &quot;maximumError&quot;: &quot;10kb&quot;<br>                }<br>              ]<br>            },</pre><p>We can add more configurations after the production configurations are complete. Note: Production section has more configurations, bundle size limits etc. Make sure you find the right spot to insert your file replacements for other configurations, as shown below.</p><pre>&quot;configurations&quot;: {<br>            &quot;production&quot;: {<br>              &quot;fileReplacements&quot;: [<br>                {<br>                  &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,<br>                  &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;<br>                }<br>              ],<br>              &quot;optimization&quot;: true,<br>              &quot;outputHashing&quot;: &quot;all&quot;,<br>              &quot;sourceMap&quot;: false,<br>              &quot;extractCss&quot;: true,<br>              &quot;namedChunks&quot;: false,<br>              &quot;extractLicenses&quot;: true,<br>              &quot;vendorChunk&quot;: false,<br>              &quot;buildOptimizer&quot;: true,<br>              &quot;budgets&quot;: [<br>                {<br>                  &quot;type&quot;: &quot;initial&quot;,<br>                  &quot;maximumWarning&quot;: &quot;2mb&quot;,<br>                  &quot;maximumError&quot;: &quot;5mb&quot;<br>                },<br>                {<br>                  &quot;type&quot;: &quot;anyComponentStyle&quot;,<br>                  &quot;maximumWarning&quot;: &quot;6kb&quot;,<br>                  &quot;maximumError&quot;: &quot;10kb&quot;<br>                }<br>              ]<br>            },            <strong><br>            &quot;development&quot;: {<br>              &quot;fileReplacements&quot;: [<br>                {<br>                  &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,<br>                  &quot;with&quot;: &quot;src/environments/environment.dev.ts&quot;<br>                }<br>              ]<br>            },<br>            &quot;staging&quot;: {<br>              &quot;fileReplacements&quot;: [<br>                {<br>                  &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,<br>                  &quot;with&quot;: &quot;src/environments/environment.stg.ts&quot;<br>                }<br>              ]<br>            }</strong>            <br>          }          <br>        },</pre><h3>Script Configuration:</h3><p>Last step is to configure the build for the environments in package.json . The file contains section for scripts. The scripts defined here is for build, serve, run e2e, tests, code coverage etc.</p><pre>&quot;scripts&quot;: {<br>    &quot;ng&quot;: &quot;ng&quot;,<br>    &quot;start&quot;: &quot;ng serve&quot;,<br>    <strong>&quot;build&quot;: &quot;ng build&quot;,</strong>    <br>    &quot;lint&quot;: &quot;ng lint&quot;,<br>    &quot;e2e&quot;: &quot;ng e2e&quot;,<br>    &quot;test&quot;: &quot;ng test --code-coverage --watch=false&quot;    <br>  },</pre><p>Angular framework provides a few default scripts. Now lets add our custom configuration build scripts.</p><pre>&quot;scripts&quot;: {<br>    &quot;ng&quot;: &quot;ng&quot;,<br>    &quot;start&quot;: &quot;ng serve&quot;,<br>    &quot;build&quot;: &quot;ng build&quot;,    <br>    <strong>&quot;build:dev&quot;: &quot;ng build --prod --configuration=development --aot,<br>    &quot;build:staging&quot;: &quot;ng build --prod --configuration=staging --aot,<br>    &quot;build:production&quot;: &quot;ng build --prod --aot,</strong><br>    &quot;lint&quot;: &quot;ng lint&quot;,<br>    &quot;e2e&quot;: &quot;ng e2e&quot;,<br>    &quot;test&quot;: &quot;ng test --code-coverage --watch=false&quot;   <br>  },</pre><p>--configuration=development or --configuration=staging provides custom configration tags, this string should match the configurations we added under angular.json .</p><h3>Usage:</h3><p>The build configuration settings are especially useful on CI/CD pipelines for different stages of deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hJhrXLxJDKX-pda4-i3TA.png" /></figure><h3>In conclusion</h3><p>You can define different named build configurations for your project, such as <em>development, staging </em>and <em>production</em>, with different defaults. The Angular CLI build, serve, and test commands can then replace files with appropriate versions for your intended target environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b2d7ef49368" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Title, Meta, SEO Tags binding — Angular]]></title>
            <link>https://indira-raghavan.medium.com/dynamic-title-meta-seo-tags-binding-angular-115c1dd3a7c0?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/115c1dd3a7c0</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Tue, 10 Nov 2020 20:47:44 GMT</pubDate>
            <atom:updated>2020-11-10T20:47:44.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dynamic Title, Meta, SEO Tags binding — Angular</h3><p>Update page title/SEO Meta tags based on Route</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5Mg6QEzU4r66RSwTzaQ9A.png" /></figure><h3>Setting Page Title or Meta tags:</h3><p>Angular provides ways to set title or add/update Meta tags through Title, Meta services. You can import Title, Meta from @angular/platform-browser. This information can be changed in constructor/ngOnInit() or in any function inside the component. This helps in dynamically binding the values for the page, instead of the title being set in index.html or app.component.ts file.</p><pre>import { Title, Meta } from &quot;@angular/platform-browser&quot;;</pre><pre>...</pre><pre>constructor(private titleService:Title, private metaService: Meta) {<br>  this.titleService.setTitle(&quot;My page title&quot;);<br>  this.metaService.addTag({ name: &#39;description&#39;, content: &#39;changing   tags&#39; });</pre><pre>this.metaService.updateTag({ name: &#39;description&#39;, content: &#39;changing tags&#39; });</pre><pre>}</pre><h3>Dynamic binding based on routes:</h3><p>Often the page titles may change based on views. Some cases we may need to have new meta tags based on current view(route). Angular provides a way to keep a simple name value collection, attached to specific routes. We can keep the list of items needed as tags and title in the Route definition.</p><pre>const routes: Routes = [<br>  {<br>    path: &#39;landingpage&#39;,<br>    component: LandingPageComponent,<br>    <strong>data: {<br>      title: &#39;My Title&#39;,<br>      meta:&#39;My landing page&#39;<br>    }</strong> <br>  }<br>]</pre><p>We can retrieve the information from routes, and update the title based on the data in the Route definition.</p><pre>import { Title, Meta } from &quot;@angular/platform-browser&quot;;</pre><pre>...</pre><pre>constructor(private titleService:Title, private metaService: Meta) {<br>  this.route.data.subscribe(value =&gt; {<br>    // contains meta tag and title. update<br>    this.meta = value.meta;<br>    this.title = value.title;<br>  });</pre><pre>  this.titleService.setTitle(this.title);<br>  this.metaService.addTag({ name: &#39;description&#39;, content:    <br>      this.meta });<br>  this.metaService.updateTag({ name: &#39;description&#39;, content:   <br>      this.meta });<br>}</pre><h3>In Conclusion:</h3><p>Data: Represents static data associated with a particular route. Data associated with a route can be used to update Title and meta tags dynamically based on views.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=115c1dd3a7c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Content projection]]></title>
            <link>https://indira-raghavan.medium.com/angular-content-projection-43bf5633829e?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/43bf5633829e</guid>
            <category><![CDATA[component-libraries]]></category>
            <category><![CDATA[component-driven]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[content-projection]]></category>
            <category><![CDATA[reusable-component]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Mon, 02 Nov 2020 18:07:03 GMT</pubDate>
            <atom:updated>2020-11-02T18:07:03.881Z</atom:updated>
            <content:encoded><![CDATA[<p>Powerful way to build reusable components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fDwGaUXLj6xG4_IXIZg0A.png" /></figure><p>To better understand ng-content projection let’s talk about the design problem we are trying to solve. Let’s say we have a basic card design — Title, Text and submit button. Based on the content of the website we are about to build, let’s say we have 3 different types of templates:</p><ol><li>A card with just plain information text.</li><li>A card with bulleted list(or numbered list) of information.</li><li>A card with text and image(perhaps)</li></ol><p>Does that mean we build 3 different components? For each of the above scenario? But, our basic card design is the same. Same colors, same borders, same text font-size etc. Not efficient to build 3 different when we can make one Card component a dynamic component. Can we build a Card-component that will <strong>project </strong>different <strong>content</strong> only for the text section (card body). Yes we can! And that’s what I will show how to build.</p><p>Let’s start with basic Angular app, named ContentProjection</p><pre>npm i @angular/cli -g</pre><pre>ng new ContentProjection</pre><p>For ease of explaining the concept, I have added bootstrap styles to angular.json file</p><pre>&quot;styles&quot;: [<br>  &quot;node_modules/bootstrap/dist/css/bootstrap.css&quot;,<br>  &quot;src/styles.scss&quot;<br>]</pre><p>Let’s create a Card &amp; Display components: Card is our reusable component, Display is going to display the card component with different content mentioned above.</p><pre>ng generate component Card<br>ng generate component Display</pre><p>Paste the following html for card.component.html</p><pre>&lt;div class=&quot;card&quot; style=&quot;width: 18rem;&quot;&gt;<br>  &lt;div class=&quot;card-body&quot;&gt;<br>   &lt;h5 class=&quot;card-title&quot;&gt;Card title&lt;/h5&gt;<br>     <strong>&lt;ng-content&gt;&lt;/ng-content&gt;</strong><br>   &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;Card link&lt;/a&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>This is the basic card from bootstrap site. It just have the text section. As mentioned above we are going to have the title and link as common factors across all cards on the site. The middle section(bolded section) will change based on what we wish to project. Now let’s go to display component and add the card component with different content inside the card body.</p><p>Paste the following html into display.component.html</p><pre>&lt;div class=&quot;container&quot;&gt;<br>    &lt;div class=&quot;row mt-5&quot;&gt;<br>        &lt;div class=&quot;col-4&quot;&gt;<br>            <strong>&lt;app-card&gt;<br>                &lt;p class=&quot;card-text&quot;&gt;Some quick example text to <br>                   build on the card title and make up the       <br>                   bulk of the card&#39;s content.&lt;/p&gt;<br>            &lt;/app-card&gt;</strong><br>        &lt;/div&gt;</pre><pre>        &lt;div class=&quot;col-4&quot;&gt;<br>            <strong>&lt;app-card&gt;<br>                &lt;ul&gt; Sample list items:<br>                    &lt;li&gt;Item 1&lt;/li&gt;<br>                    &lt;li&gt;Item 2&lt;/li&gt;<br>                    &lt;li&gt;Item 3&lt;/li&gt;<br>                &lt;/ul&gt;<br>            &lt;/app-card&gt;</strong><br>        &lt;/div&gt;</pre><pre>        &lt;div class=&quot;col-4&quot;&gt;<br>            <strong>&lt;app-card&gt;<br>                &lt;h5 class=&quot;card-title text-success&quot;&gt;Success card <br>                   title&lt;/h5&gt;<br>                &lt;p class=&quot;card-text text-danger&quot;&gt;Texts with warning <br>                     or success color system to bring user&#39;s <br>                     attention to it&lt;/p&gt;<br>            &lt;/app-card&gt;</strong><br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>If you notice the usage above, all three references of &lt;app-card&gt;&lt;/app-card&gt; is different. Projected content is different for each usage, though all references the same Card component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hr-4fNctLzE1WMRdEiCN_w.png" /><figcaption>Result for the above implementation</figcaption></figure><h3>In conclusion:</h3><p>Angular directive ng-content helps solve a design problem where template inside a component is provided as an input instead of hiding the template inside the component itself. This simplifies and solves a lot of design problems. Identifying common templates and isolating the component, helps in focusing the actual varying template.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43bf5633829e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git day-in and day-out]]></title>
            <link>https://indira-raghavan.medium.com/git-day-in-and-day-out-b3c47ae1ec03?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3c47ae1ec03</guid>
            <category><![CDATA[git-pull]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-merge]]></category>
            <category><![CDATA[cli]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Mon, 19 Oct 2020 14:00:24 GMT</pubDate>
            <atom:updated>2020-10-19T14:11:27.305Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyday commands at a glance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Cki89AcHAaqsWAh1kFNAg.png" /></figure><h4>Here is a list of Git commands that might be useful for daily work along with how they work:</h4><ol><li>Let’s start with cloning a repository:</li></ol><pre>just to clone a project:<br>$ git clone <a href="https://clone/">https://clone</a>-url-for-the-project.com</pre><pre>Clone a project into specific folder:<br>$ git clone <a href="https://clone/">https://clone</a>-url-for-the-project.com &quot;c:/path-to-your-folder/&quot;</pre><p>2. Branches:</p><pre>create new branch<br>$ git checkout -b my-new-branch-name</pre><pre>checkout existing branch<br>$ git checkout existing-branch-name</pre><p>3. Working with changes:</p><pre>check the files changed<br>$ git status</pre><pre>stage all changes<br>$ git add .</pre><pre>commit the changes<br>$ git commit -m &quot;your-commit-message&quot;</pre><pre>push changes to origin<br>$ git push</pre><p>4. Get latest:</p><pre>get the changes for the branch you are in<br>$ git pull</pre><pre>pull another branch into your local<br>$ git pull origin other-branch-name</pre><p>5. Abort merge or Rebase:</p><p>If and When pull from different branch was a mistake. For more details on when to Merge or Abort, <a href="https://medium.com/@indira.raghavan/git-merge-vs-git-rebase-a23423734975">click here</a></p><pre>if there are merge conflicts, you will have a branch name with MERGE or REBASE attached to your branch name:</pre><pre>$ git pull origin other-branch-name<br>Resolve the conflicts<br>c:/Workspace/Project(my-existing-brnach|MERGE)<br>$ git abort --merge</pre><pre>or<br>c:/Workspace/Project(my-existing-brnach|REBASE)<br>$ git abort --rebase</pre><p>6. Reset commits:</p><pre>wish to reset all of your commits<br>$ git reset --hard HEAD</pre><pre>wish to remove just last 2 commits<br>$ git rest --hard HEAD~2</pre><pre>if you want to know how many commits to undo<br>$ git log</pre><pre>choose number based on the log of commits</pre><p>7. Reconcile your repository and branches:</p><p>IDE keeps information about all your previous branches. Even if the branches were deleted from origin. To update your information.</p><pre>$ git prune</pre><pre>if you wish to check what information is missing<br>$ git prune --dry-run</pre><p>Prune command is especially useful when you are trying to switch to a branch but your shell doesn’t know the branch exists. You can also do git pull on your existing branch to get the latest for the repository.</p><p>8. Stash your changes:</p><pre>wish to keep your changes that are not ready to be committed<br>$ git stash save your-stash-name</pre><pre>to apply the stash back<br>$ git apply stash your-stash-name</pre><p>9. Cherry-pick:</p><p>To pick and choose commit hashtags for the new branch:</p><pre>do a git log on the branch to get the commit SHA<br>$ git log<br>output will be something like this:<br>commit 255dac3....... (HEAD -&gt; branch, origin-branch)<br>Author: Indira.Raghavan &lt;<a href="/service/mailto:Indira.Raghavan@Staples.ca">y</a>our-email&gt;<br>Date:   Tue Oct 13 18:10:26 2020 -0400</pre><pre>choose the exact hash you need for your branch:<br>$ git cherry-pick &lt;commit-SHA)</pre><p><strong>In conclusion:</strong></p><p>Command line inputs are all in the now, everyone is using them. IDE’s are working on making it easier to provide UI tool that does all of these functions(often more intuitive) without command-line inputs. It is your preference to use the CLI instead of GUI. If you do wish to use the CLI, hope this article helps you with day-to-day commands.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3c47ae1ec03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Merge vs Git Rebase]]></title>
            <link>https://indira-raghavan.medium.com/git-merge-vs-git-rebase-a23423734975?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a23423734975</guid>
            <category><![CDATA[development-commits]]></category>
            <category><![CDATA[git-merge]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-rebase]]></category>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Mon, 19 Oct 2020 13:49:51 GMT</pubDate>
            <atom:updated>2020-10-19T13:49:51.534Z</atom:updated>
            <content:encoded><![CDATA[<p>What do I choose? 🤔</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dImx00VIvCSWysu8auauyg.png" /><figcaption>merge vs rebase</figcaption></figure><p>All of us have heard about git merge and git rebase. But what should I use when, is still a mystery. Let’s understand how each command works.</p><p>Let’s say we have a production branch that you created your branch for your feature. You made changes on this feature-branch. Now, you hear there were more changes pushed to production branch. You should have your branch updated to the latest changes before you can continue.</p><p><strong>Rebase:</strong></p><pre>$ git rebase production</pre><p>How does this work:</p><pre>$ git switch production<br>save all the commits done to current branch in a teamporary place<br>$ git reset --hard HEAD<br>reset all commits to production branch<br>re-apply commits saved from temp place one by one. </pre><pre>if there are conflicts it will show up on your conflicts section. you need to resolve them manually and type<br>$ git rebase --continue</pre><p>To understand better — Rebase command will rewrite your commits as if it happened after the branch was updated, including the commit logs.</p><p><strong>Merge:</strong></p><pre>$ git merge production</pre><p>How does this work:</p><pre>$ git pull origin production</pre><p>Very simply nothing is changed in terms of logs, it just tries to merge the origin branch and keeps your original commits. If there are conflicts you need to merge them manually and complete the merge.</p><h3>Which one to use?</h3><p>If you are in a Software development team, with multiple developers working with same production branch, Rebase is not a good option. Since it rewrites commit history, you may be affecting branch history for other developers too. If you are the sole owner of the origin branch, then by all means go ahead and rebase.</p><p>Merge — does all of the functions Rebase does and it is simpler to use without compromising branch integrity for your team members. My simple advise — don’t play with commit hashes if you don’t have to.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a23423734975" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Insights: .NET Core API]]></title>
            <link>https://indira-raghavan.medium.com/azure-insights-net-core-api-e0363b0e30d3?source=rss-d3d4bd36394e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0363b0e30d3</guid>
            <dc:creator><![CDATA[Indira Raghavan]]></dc:creator>
            <pubDate>Mon, 05 Oct 2020 00:58:16 GMT</pubDate>
            <atom:updated>2020-10-05T00:58:16.901Z</atom:updated>
            <content:encoded><![CDATA[<p>Monitor your ASP .NET Web API with Azure Application Insights</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chdgjWASWHCCgfrw4a9Mcg.png" /></figure><p>Create your .NET Core Web API</p><p>Include Application insights in the .NET Core API.</p><p>Deploy the code to Azure API service</p><p>View Insights and metrics on Azure dashboard</p><p>For our article purposes I am using my personal API with the following route’s and methods, we will be able to see these routes GET requests on Insights dashboard.</p><h3>Create new or use existing .NET Core API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*kY2jR7QteChg1ST-jgz12Q.png" /></figure><h3>Add Application Insights NuGet packages to your project:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*ENZmNgDHrBxiay9HWvlQsw.png" /></figure><p>Go to Azure portal and use the Application Insights that comes with your API service plan and get the Instrumentation key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZesdbFCwoRGUXV-Q52yMMQ.png" /><figcaption>App-service plan comes with Application insights</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQ6dhCu8NN2RcoNUf-v8bw.png" /><figcaption>Copy the instrumentation key to appsettings.json file</figcaption></figure><p>Add the instrumentation key into ApplicationInsights section in appsettings.json</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*TQ6Ew22y6ondo-9eehm9dw.png" /><figcaption>appsettings.json</figcaption></figure><pre>{<br>  &quot;ApplicationInsights&quot;: {<br> &quot;InstrumentationKey&quot;: &quot;putinstrumentationkeyhere&quot;<br>  },<br>  &quot;Logging&quot;: {<br> &quot;LogLevel&quot;: {<br>   &quot;Default&quot;: &quot;Warning&quot;<br> }<br>  }<br>}</pre><p>Add configuring Application insights telemetry in Startup.cs file</p><pre>public void ConfigureServices(IServiceCollection services)<br>{<br>  ...<br>  services.AddApplicationInsightsTelemetry();       <br>  services.AddControllers();<br>}</pre><p>Run your application locally and test your API (using Postman or any Rest Client). These queries can be seen on the insights dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O0R7cT01Ij3EAhjoQqnj6w.png" /><figcaption>Logs on the dashboard.</figcaption></figure><p>Application Insights are provided along with your App Service plan, even for free tier. Make use of some default log queries provided to filter and also see exceptions and failures. This helps debug your API as well.</p><h3>In conclusion:</h3><p>The <a href="https://nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore">Application Insights </a>can monitor your applications no matter where or how they run. If your application is running and has network connectivity to Azure, telemetry can be collected. Application Insights monitoring is supported everywhere .NET Core is supported.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0363b0e30d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>