<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">

<channel>
	<title>Hamzeen Hameem</title>
	<atom:link href="https://hamzeen.wordpress.com/feed/" rel="self" type="application/rss+xml"/>
	<link>https://hamzeen.wordpress.com</link>
	<description>Developer. Designer. Tea addict. </description>
	<lastBuildDate>Thu, 27 Jun 2019 07:34:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">1393805</site><cloud domain="hamzeen.wordpress.com" path="/?rsscloud=notify" port="80" protocol="http-post" registerProcedure=""/>
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>Hamzeen Hameem</title>
		<link>https://hamzeen.wordpress.com</link>
	</image>
	<atom:link href="https://hamzeen.wordpress.com/osd.xml" rel="search" title="Hamzeen Hameem" type="application/opensearchdescription+xml"/>
	<atom:link href="https://hamzeen.wordpress.com/?pushpress=hub" rel="hub"/>
	<itunes:explicit>no</itunes:explicit><copyright>All rigths reserved, Lonely Coder.</copyright><itunes:image href="http://a.wordpress.com/avatar/hamzeen-128.jpg"/><itunes:keywords>Technology,Open,Source,Java,PHP,SEO</itunes:keywords><itunes:summary>It's all about how you think. Not how you code - Lonely Coder.</itunes:summary><itunes:subtitle>Plan your Code. Code your Plan.</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Podcasting"/></itunes:category><itunes:author>Lonely Coder</itunes:author><item>
		<title>Angular Testing</title>
		<link>https://hamzeen.wordpress.com/2018/10/08/angular2-testing/</link>
		
		
		<pubDate>Mon, 08 Oct 2018 15:35:28 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">http://hamzeen.wordpress.com/?p=1122</guid>

					<description><![CDATA[Testing a Simple Component Testing Template Test a Simple Class Mock Event Service Testing Testing Services in Angular 2 https://blog.realworldfullstack.io/real-world-angular-part-9-unit-testing-c62ba20b1d93 https://stackoverflow.com/questions/42440234/unit-test-a-angular2-service-that-uses-rxjs-subjects Template Testing https://codecraft.tv/courses/angular/unit-testing/components/ GAnalytics https://codeburst.io/using-google-analytics-with-angular-25c93bffaa18]]></description>
										<content:encoded><![CDATA[<h3>Testing a Simple Component</h3>
<pre class="brush: jscript; title: ; notranslate">
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('AppComponent Tests', () =&gt; {
  beforeEach(async(() =&gt; {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  }));

  it('should create the app', async(() =&gt; {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));

  it('should render greeting', async(() =&gt; {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    const compiled = fixture.debugElement.nativeElement;
    expect(compiled.querySelector('h1').textContent).toContain('Welcome!');
  }));
});
</pre>
<h3>Testing Template</h3>
<pre class="brush: jscript; title: ; notranslate">

// EX1
import { async, TestBed } from '@angular/core/testing';
import { SomeComponent } from './some.component';

beforeEach(() =&gt; {
  TestBed.configureTestingModule({
    declarations: [
      SomeComponent
    ],
    imports: [
      // HttpModule, etc.
    ],
    providers: [
      // { provide: ServiceA, useClass: TestServiceA }
    ]
  });
});

it('should do something', async(() =&gt; {
  TestBed.compileComponents().then(() =&gt; {
    const fixture = TestBed.createComponent(SomeComponent);

    // Access the dependency injected component instance
    const app = fixture.componentInstance;
    expect(app.something).toBe('something');

    // Access native element
    const element = fixture.nativeElement;

    // detect changes
    fixture.detectChanges();
    expect(element.textContent).toContain('something');
  });
}));


// EX2
it('should get quote', () =&gt; {

  fixture.debugElement.componentInstance.getQuote();
  fixture.detectChanges();
  var compiled = fixture.debugElement.nativeElement;

  expect(compiled.querySelector('div'))
    .toHaveText('Test Quote'); 
});
​

// EX3
import {TestBed, ComponentFixture, inject, async} from '@angular/core/testing';
import {LandingComponent, User} from './landing.component';
import {Component, DebugElement} from "@angular/core";
import {By} from "@angular/platform-browser";


describe('Component: Landing', () =&gt; {

  let component: LoginComponent;
  let fixture: ComponentFixture;
  let submitEl: DebugElement;
  let usernameEl: DebugElement;

  beforeEach(() =&gt; {

    // refine the test module by declaring the test component
    TestBed.configureTestingModule({
      declarations: [LandingComponent]
    });


    // create component and test fixture
    fixture = TestBed.createComponent(LandingComponent);

    // get test component from the fixture
    component = fixture.componentInstance;

    submitEl = fixture.debugElement.query(By.css('button'));
    usernameEl = fixture.debugElement.query(By.css('input[type=text]'));
  });

  it('Setting enabled to false disabled the submit button', () =&gt; {
    component.enabled = false;
    fixture.detectChanges();
    expect(submitEl.nativeElement.disabled).toBeTruthy();
  });

  it('Setting enabled to true enables the submit button', () =&gt; {
    component.enabled = true;
    fixture.detectChanges();
    expect(submitEl.nativeElement.disabled).toBeFalsy();
  });

  it('Entering email and password emits loggedIn event', () =&gt; {
    let user: User;
    usernameEl.nativeElement.value = "test";

    // Subscribe to the Observable and store the user in a local variable.
    component.loggedIn.subscribe((value) =&gt; user = value);

    // This sync emits the event and the subscribe callback gets executed above
    submitEl.triggerEventHandler('click', null);

    // Now we can check to make sure the emitted value is correct
    expect(user.name).toBe("test");
  });
});


</pre>
<h3>Test a Simple Class</h3>
<pre class="brush: jscript; title: ; notranslate">

import { countries } from './countries';
import { Util } from './util';

let testClass: Util = null;
describe('Util Tests', () =&gt; {
  beforeEach(() =&gt; {
    testClass = new Util();
  });

  it('should ensure getCountries is based on countries file', () =&gt; {
    const actual = testClass.getCountries;
    expect(actual[0].id).toEqual(countries[0].id);
  });
});

import { countries } from './countries';
export class Util {

  public countries: any[] = countries;

  public getProducts() {
    return this.countries;
  }
}

</pre>
<h3>Mock Event</h3>
<pre class="brush: jscript; title: ; notranslate">
  const mockEvent: Event = {
    srcElement: {
      classList: ''
    },
    charCode: 64,
    stopPropagation: ( ( e: any ) =&gt; { /**/ }),
    preventDefault: ( ( e: any ) =&gt; { /**/ }),
  };
</pre>
<p>Service Testing</p>
<blockquote class="wp-embedded-content" data-secret="UEvlDgb8eh"><p><a href="https://semaphoreci.com/community/tutorials/testing-services-in-angular-2">Testing Services in Angular 2</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Testing Services in Angular 2&#8221; &#8212; Semaphore" src="https://semaphoreci.com/community/tutorials/testing-services-in-angular-2/embed#?secret=YkiDvbRcP6#?secret=UEvlDgb8eh" data-secret="UEvlDgb8eh" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br />
<a href="https://blog.realworldfullstack.io/real-world-angular-part-9-unit-testing-c62ba20b1d93" rel="nofollow">https://blog.realworldfullstack.io/real-world-angular-part-9-unit-testing-c62ba20b1d93</a><br />
<a href="https://stackoverflow.com/questions/42440234/unit-test-a-angular2-service-that-uses-rxjs-subjects" rel="nofollow">https://stackoverflow.com/questions/42440234/unit-test-a-angular2-service-that-uses-rxjs-subjects</a></p>
<p>Template Testing<br />
<a href="https://codecraft.tv/courses/angular/unit-testing/components/" rel="nofollow">https://codecraft.tv/courses/angular/unit-testing/components/</a></p>
<p>GAnalytics<br />
<a href="https://codeburst.io/using-google-analytics-with-angular-25c93bffaa18" rel="nofollow">https://codeburst.io/using-google-analytics-with-angular-25c93bffaa18</a></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1122</post-id>
		<media:content medium="image" url="https://1.gravatar.com/avatar/77f160555483d2616292d321fcb4db8e530328a7ac14ff6ec66ed77e3fb92af1?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">hamzeen</media:title>
		</media:content>
	<dc:creator>Lonely Coder</dc:creator></item>
		<item>
		<title>JS Utils</title>
		<link>https://hamzeen.wordpress.com/2018/09/12/date-diff/</link>
		
		
		<pubDate>Wed, 12 Sep 2018 15:08:36 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">http://hamzeen.wordpress.com/?p=1061</guid>

					<description><![CDATA[Palindrome JS JWT Token Intereptor to Refresh Token Ex1: https://medium.com/@alexandrubereghici/angular-tutorial-implement-refresh-token-with-httpinterceptor-bfa27b966f57 Ex2: https://codeforgeek.com/2018/03/refresh-token-jwt-nodejs-authentication/ Ex3: https://gist.github.com/Toilal/8849bd63d53bd2df2dd4df92d3b12f26 Minimalist Example: Ex1: http://jasonwatmore.com/post/2018/05/23/angular-6-jwt-authentication-example-tutorial Prevent SQL Injection RegEx Playground: https://regex101.com/ 2 int followed by 4 caps: ^[A-Z]{2}[0-9]{4}$ Example2: ^[A-Za-z ][A-Za-z0-9!@#$%^&#38;*&#8217; ]{1,20}$ str.replace(/]*&#62;/g, &#8221;) Sort array of objects by ID Date Diff  ]]></description>
										<content:encoded><![CDATA[<h3>Palindrome JS</h3>
<pre class="brush: plain; title: ; notranslate">
const isPalindrome = (str) =&gt; 
  str.toLowerCase().split('').reverse().join('') === str.toLowerCase();
console.log(isPalindrome('lEveL'));
</pre>
<h3>JWT Token</h3>
<p>Intereptor to Refresh Token<br />
Ex1: <a href="https://medium.com/@alexandrubereghici/angular-tutorial-implement-refresh-token-with-httpinterceptor-bfa27b966f57" rel="nofollow">https://medium.com/@alexandrubereghici/angular-tutorial-implement-refresh-token-with-httpinterceptor-bfa27b966f57</a></p>
<p>Ex2: https://codeforgeek.com/2018/03/refresh-token-jwt-nodejs-authentication/<br />
Ex3: <a href="https://gist.github.com/Toilal/8849bd63d53bd2df2dd4df92d3b12f26" rel="nofollow">https://gist.github.com/Toilal/8849bd63d53bd2df2dd4df92d3b12f26</a></p>
<p>Minimalist Example:<br />
Ex1: <a href="http://jasonwatmore.com/post/2018/05/23/angular-6-jwt-authentication-example-tutorial" rel="nofollow">http://jasonwatmore.com/post/2018/05/23/angular-6-jwt-authentication-example-tutorial</a></p>
<h3>Prevent SQL Injection</h3>
<p><strong>RegEx Playground</strong>: <a href="https://regex101.com/" rel="nofollow">https://regex101.com/</a></p>
<ul>
<li>2 int followed by 4 caps: ^[A-Z]{2}[0-9]{4}$</li>
<li>Example2: ^[A-Za-z ][A-Za-z0-9!@#$%^&amp;*&#8217; ]{1,20}$</li>
</ul>
<div class="embed-codepen"><iframe title="Regex" id="cp_embed_gdjmLR" src="https://codepen.io/hamzeen/embed/preview/gdjmLR?default-tabs=html%2Cresult&amp;height=300&amp;host=https%3A%2F%2Fcodepen.io&amp;slug-hash=gdjmLR" scrolling="no" frameborder="0" height="300" allowtransparency="true" class="cp_embed_iframe" style="width: 100%; overflow: hidden;"></iframe></div>
<p>str.replace(/]*&gt;/g, &#8221;)</p>
<pre class="brush: plain; title: ; notranslate">
var str = &#039;
&lt;h2&gt;Hello&lt;/h2&gt;
&#039;;
str.replace(/]*&amp;gt;/g, &#039;&#039;);
</pre>
<h3>Sort array of objects by ID</h3>
<pre class="brush: plain; title: ; notranslate">
var data = [1, 2, 3, 4, 5]
  .map(el =&gt; {
    return {
      id: el,
      name: 'alpha',
      title: 'Mr.',
      description: 'laziest objects',
      age: (el * 10)
    };
  });
data.sort(function(a, b){return b.id - a.year});
</pre>
<h3>Date Diff</h3>
<pre class="brush: plain; title: ; notranslate">
d2 = new Date(2019, 3, 18);
d1 = new Date(2018, 9, 18);

Date.diffInMonths = function(d1, d2) {
  return Math.round((d2 - d1) / (60 * 30 * 60 * 24 * 1000));
}

Date.DateDiff = {

    inDays: function(d1, d2) {
        var t2 = d2.getTime();
        var t1 = d1.getTime();

        return parseInt((t2-t1)/(24*3600*1000));
    },

    inWeeks: function(d1, d2) {
        var t2 = d2.getTime();
        var t1 = d1.getTime();

        return parseInt((t2-t1)/(24*3600*1000*7));
    },

    inMonths: function(d1, d2) {
        var d1Y = d1.getFullYear();
        var d2Y = d2.getFullYear();
        var d1M = d1.getMonth();
        var d2M = d2.getMonth();

        return (d2M+12*d2Y)-(d1M+12*d1Y);
    },

    inYears: function(d1, d2) {
        return d2.getFullYear()-d1.getFullYear();
    }
}

Date.DateDiff.inDays(d1,d2);
</pre>
<p> </p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1061</post-id>
		<media:content medium="image" url="https://1.gravatar.com/avatar/77f160555483d2616292d321fcb4db8e530328a7ac14ff6ec66ed77e3fb92af1?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">hamzeen</media:title>
		</media:content>
	<dc:creator>Lonely Coder</dc:creator></item>
		<item>
		<title>Response Mapping</title>
		<link>https://hamzeen.wordpress.com/2018/07/17/response-mapping/</link>
		
		
		<pubDate>Tue, 17 Jul 2018 12:28:19 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">http://hamzeen.wordpress.com/?p=1057</guid>

					<description><![CDATA[REST API http://jsonplaceholder.typicode.com/users/]]></description>
										<content:encoded><![CDATA[<p>REST API<br />
<a href="http://jsonplaceholder.typicode.com/users/" rel="nofollow">http://jsonplaceholder.typicode.com/users/</a></p>
<pre class="brush: plain; title: ; notranslate">
export class MyApp {
  private users = [];

  constructor(http: Http) {
    http.get('http://jsonplaceholder.typicode.com/users/')
        .flatMap((response) =&gt; response.json())
        .filter((person) =&gt; person.id &gt; 5)
        .map((person) =&gt; "Mr. " + person.name)
        .subscribe((data) =&gt; {
          this.users.push(data);
        });
  }
}


On Console:
var users = [];
[
  {
    "id": 2,
    "name": "Ervin Howell",
    "username": "Antonette",
    "email": "Shanna@melissa.tv",
    "address": {
      "street": "Victor Plains",
      "suite": "Suite 879",
      "city": "Wisokyburgh",
      "zipcode": "90566-7771"
    },
    "phone": "010-692-6593 x09125",
    "website": "anastasia.net"
  },
  {
    "id": 3,
    "name": "Clementine Bauch",
    "username": "Samantha",
    "email": "Nathan@yesenia.net",
    "address": {
      "street": "Douglas Extension",
      "suite": "Suite 847",
      "city": "McKenziehaven",
      "zipcode": "59590-4157"
    },
    "phone": "1-463-123-4447",
    "website": "ramiro.info"
  },
  {
    "id": 5,
    "name": "Chelsey Dietrich",
    "username": "Kamren",
    "email": "Lucio_Hettinger@annie.ca",
    "address": {
      "street": "Skiles Walks",
      "suite": "Suite 351",
      "city": "Roscoeview",
      "zipcode": "33263"
    },
    "phone": "(254)954-1289",
    "website": "demarco.info"
  },
  {
    "id": 6,
    "name": "Mrs. Dennis Schulist",
    "username": "Leopoldo_Corkery",
    "address": {
      "street": "Norberto Crossing",
      "suite": "Apt. 950",
      "city": "South Christy",
      "zipcode": "23505-1337"
    },
    "phone": "1-477-935-8478 x6430",
    "website": "ola.org"
  }
].map((response) =&gt; response)
        .filter((person) =&gt; person.id &gt; 3)
        .map((person) =&gt; { 
          return {
            name: 'Mr.' + person.name,
            company: 'laziest approach to constructing objs',
            id: person.id
          };
        })
        .map((data) =&gt; {
          users.push(data);
        });
</pre>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1057</post-id>
		<media:thumbnail url="https://hamzeen.wordpress.com/wp-content/uploads/2018/02/005.jpg"/>
		<media:content medium="image" url="https://hamzeen.wordpress.com/wp-content/uploads/2018/02/005.jpg">
			<media:title type="html">005</media:title>
		</media:content>

		<media:content medium="image" url="https://1.gravatar.com/avatar/77f160555483d2616292d321fcb4db8e530328a7ac14ff6ec66ed77e3fb92af1?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">hamzeen</media:title>
		</media:content>
	<dc:creator>Lonely Coder</dc:creator><enclosure length="-1" type="application/json; charset=utf-8" url="http://jsonplaceholder.typicode.com/users/"/><itunes:explicit>no</itunes:explicit><itunes:subtitle>REST API http://jsonplaceholder.typicode.com/users/</itunes:subtitle><itunes:author>Lonely Coder</itunes:author><itunes:summary>REST API http://jsonplaceholder.typicode.com/users/</itunes:summary><itunes:keywords>Technology,Open,Source,Java,PHP,SEO</itunes:keywords></item>
		<item>
		<title>G I T</title>
		<link>https://hamzeen.wordpress.com/2018/06/25/g-i-t/</link>
		
		
		<pubDate>Mon, 25 Jun 2018 12:15:55 +0000</pubDate>
				<category><![CDATA[1]]></category>
		<guid isPermaLink="false">http://hamzeen.wordpress.com/?p=1047</guid>

					<description><![CDATA[https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository]]></description>
										<content:encoded><![CDATA[<p><a href="https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository" rel="nofollow">https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository</a></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1047</post-id>
		<media:content medium="image" url="https://1.gravatar.com/avatar/77f160555483d2616292d321fcb4db8e530328a7ac14ff6ec66ed77e3fb92af1?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">hamzeen</media:title>
		</media:content>
	<dc:creator>Lonely Coder</dc:creator></item>
		<item>
		<title>Callbacks</title>
		<link>https://hamzeen.wordpress.com/2018/06/15/callbacks/</link>
		
		
		<pubDate>Fri, 15 Jun 2018 09:01:33 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">http://hamzeen.wordpress.com/?p=1039</guid>

					<description><![CDATA[/&#62; This does nothing Ex2:]]></description>
										<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
function eat(at, callback) {
  setTimeout(function() {
    console.log('3. In 3 secs');
  }, 3000);
  console.log(`1. eat at ${at} &amp; `);
  callback(5);
}

function sleep(at){
  setTimeout(function() {
    console.log(`2. sleep at ${at}`);
  }, 2000);
}

eat(3, sleep);
</pre>
<h3>/&gt; This does nothing</h3>
<pre class="brush: jscript; title: ; notranslate">
function greetWorld() {
  console.log(new Date() + ': Hello, world!');
}
var timerId = setTimeout(greetWorld, 2000);
clearTimeout(timerId);
</pre>
<p>Ex2:</p>
<pre class="brush: jscript; title: ; notranslate">
function sleep(ms) {
  return new Promise(resolve =&gt; setTimeout(resolve, ms));
}
function log() {
  console.log('LG');
}

async function demo() {
  setTimeout("console.log('first');", 5000);
  await sleep(5000);
  console.log('second one');log();
}
demo();

// call books api
this.bookService.getBooks()
  .subscribe(
    response =&gt; {
      this.booksLoaded = true;
      this.books = response;
    },
    err =&gt; {
      console.log(‘books failed to load: ' + JSON.stringify(err));
  });

</pre>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1039</post-id>
		<media:thumbnail url="https://hamzeen.wordpress.com/wp-content/uploads/2017/09/26047138_10215140910455651_6243453363679419571_n-e1515346948810.jpg"/>
		<media:content medium="image" url="https://hamzeen.wordpress.com/wp-content/uploads/2017/09/26047138_10215140910455651_6243453363679419571_n-e1515346948810.jpg">
			<media:title type="html">26047138_10215140910455651_6243453363679419571_n</media:title>
		</media:content>

		<media:content medium="image" url="https://1.gravatar.com/avatar/77f160555483d2616292d321fcb4db8e530328a7ac14ff6ec66ed77e3fb92af1?s=96&amp;d=identicon&amp;r=G">
			<media:title type="html">hamzeen</media:title>
		</media:content>
	<dc:creator>Lonely Coder</dc:creator></item>
	</channel>
</rss>