Skip to content

Instantly share code, notes, and snippets.

Avatar

Dhananjay Kumar debugmodedotnet

View GitHub Profile
View delete.js
let c1 = data.findIndex( t => Object.keys(t)[0] == d.type);
if(c1 > -1){
if(data[c1][d.type].length >1){
const index = data[c1][d.type].indexOf(d.title);
if (index > -1) {
data[c1][d.type].splice(index, 1);
}
}
else{
const index = data[c1][d.type].indexOf(d.title);
View code.js
private filterDataSource: BehaviorSubject<Array<any>> = new BehaviorSubject([]);
public filterData = this.filterDataSource.asObservable();
updateUserData(data) {
this.filterDataSource.next(data);
}
addData(dataObj) {
const currentValue = this.filterDataSource.value;
View a.js
// This service acts performs various actions such with Azure AD B2C
// It use an external library MSAL.JS minumim version 1.4. Check package.json
// Modify environment.ts file to update client id, tenant , policy etc. on changes in Azure portal
// First draft by - Dhananjay Kumar in Sprint 0
// Last modified by - Dhananjay Kumar in Sprint 0
// Unit Test - 0
import { Inject, Injectable } from '@angular/core';
declare var Msal: any;
import { environment } from 'src/environments/environment';
@debugmodedotnet
debugmodedotnet / jspoland2020.js
Created Nov 20, 2020
code from jspoland2020 JavaScript talk
View jspoland2020.js
// // value of 'this' depends on how you are calling the function
var Dog = {
name :'foo',
eat : function(){
console.log(this);
}
}
View paginatior.ts
import { Component, OnInit } from '@angular/core';
import { CourseCatalogService } from '../shared/coursecatalog.service';
import { NavigationExtras, Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-catalog',
templateUrl: './catalog.component.html',
styleUrls: ['./catalog.component.css']
})
View talk.txt
Title: Simplifying Dependency Injection in Angular
Dependency Injection is one of the most famous architecture patterns to create a scalable application that has loosely coupled entities such as classes. Application made using the DI pattern is highly loosely coupled, and any part such as the business logic layer of application can be replaced at the run time without affecting the presentation layer. By design Angular framework supports dependency injection. It enables you to inject dependencies such as services without writing your own DI container or refereeing to any third-party libraries.
You create a service in Angular to share data and operations between components, directives etc. Mainly services are used to achieve separation of concerns and reusability. You keep operations such as API calls, logging, client-side data manipulations, etc. in a service. One of the significant purposes of creating service is to keep component clean that focuses on user interaction and presentations.
So, if you create
View gist:dee70a3e3b13a92b8d216deb4db69fe1
const domino = require('domino');
//const domino = require('@angular/platform-server/node_modules/domino');
const fs = require('fs');
const path = require('path');
const template = fs.readFileSync('dist/active-directory-javascript-singlepageapp-angular/browser/index.html').toString();
const win = domino.createWindow(template);
global['window'] = win;
global['document'] = win.document;
global['DOMTokenList'] = win.DOMTokenList;
global['Node'] = win.Node;
View test1.js
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-learningapproach',
templateUrl: './learningapproach.component.html',
styleUrls: ['./learningapproach.component.scss']
})
export class LearningapproachComponent implements OnInit {
constructor() { }
View unityresolver.cs
public class UnityResolver : IDependencyResolver
{
protected IUnityContainer container;
public UnityResolver(IUnityContainer container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
View c1.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;