Skip to content

Instantly share code, notes, and snippets.

@jyotendra
jyotendra / intro.md
Last active Nov 28, 2018
Azure Identity Service - Notes
View intro.md

Can Azure AD be used for social login ?

Came to understand that for user authentication via social login - Azure AD is not appropriate. Its more for organizing employees in premises and to provide them access to apps. It also provides SSO capabilities for employees under organization structure.

Azure AD can be used for customer facing websites but then they will be restricted to sign-in by using work-mail or at the very best by using microsoft account (outlook, live etc).

Azure AD does not provide social login feature. However, Azure AD B2C address this exact scenario.

Azure AD B2C uses OpenId Connect protocol

@jyotendra
jyotendra / ReadMe.md
Last active Sep 8, 2018
Implementing throttling on button click
View ReadMe.md

Why throttling is important ?

Throttling enables you to disable input from an stream for a certain period of time, after first event. Example: You might want to call a submit button once - even after multiple clicks by a user. Or you might only want to call an api once after several keystrokes by user - as is case with "type as you search". Limiting API call on every user interaction saves you server side resources and also enhance user experience.

What you can do ?

You can either disable the button or field from taking in more user inputs. But that's not elegant.

Much elegant way .....

@jyotendra
jyotendra / client.js
Last active Aug 17, 2018
socket connection with middleware in node and angular
View client.js
constructor() {
this.chats = [];
this.socket = io.connect(
baseUrl,
{
path: "/chat",
query: { "access-token": "---=====" },
reconnection: false
}
);
@jyotendra
jyotendra / chained.js
Last active Aug 14, 2018
Method chaining in classes in javascript
View chained.js
class BotResponseFormatter {
formattedResponse;
constructor(botInterpretation) {
this.formattedResponse = botInterpretation;
}
/**
*
* @param {string} replyType possible options are 'text', 'option'
*/
@jyotendra
jyotendra / countries.json
Created Jul 23, 2018
This gist shows how to import json asynchronously in nodejs
View countries.json
[
[1, "Afghanistan", "AF", 93, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[2, "Albania", "AL", 355, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[3, "Algeria", "DZ", 213, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[4, "American Samoa", "AS", 1684, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[5, "Andorra", "AD", 376, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[6, "Angola", "AO", 244, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[7, "Anguilla", "AI", 1264, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[8, "Antarctica", "AQ", 0, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
[9, "Antigua And Barbuda", "AG", 1268, "0000-00-00 00:00:00", "0000-00-00 00:00:00"],
@jyotendra
jyotendra / sorter.sql
Created Jul 14, 2018
Usage of case statement to flag user_type and sort datasets
View sorter.sql
SELECT
*
FROM
(
SELECT
USER.id AS fetched_id,
USER.country_code,
USER.mobile,
USER.email,
user_profile.name,
@jyotendra
jyotendra / Program.cs
Created Jun 28, 2018
Super simple delegate and event
View Program.cs
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Yo Buddy");
Subscriber myEventSubscriber = new Subscriber();
@jyotendra
jyotendra / app.tsx
Created Jun 27, 2018
Using observables in react app
View app.tsx
import * as React from "react";
import { httpGet } from "./service";
import "./App.css";
import logo from "./logo.svg";
class App extends React.Component {
constructor({}) {
super({}, null);
httpGet("http://abc.com/api/location/country").subscribe({
@jyotendra
jyotendra / tslint.json
Created Jun 27, 2018
tslint for react with unnecessary rules overridden
View tslint.json
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts"
]
},
"rules": {
"arrow-return-shorthand": true,
@jyotendra
jyotendra / apiHandler.ts
Created Jun 21, 2018
This function can be used to get files from angular observable
View apiHandler.ts
import { HttpClient, HttpHeaders, HttpParams } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { TokenManager } from "@app/shared/services/token-manager.service";
@Injectable()
export class ApiHandler {
constructor(private http: HttpClient) {}
apiGet(url, params?, extras?: Extras) {
let options = this.renderHeaders(extras);