Skip to content

Instantly share code, notes, and snippets.

View Kannndev's full-sized avatar

Kannan Kannndev

View GitHub Profile
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import loader from 'images/hire-loader.gif';
import { Redirect, matchPath } from 'react-router-dom';
import { ROLE_INTERVIEWER } from 'containers/App/constants';
function EmptyRouteComponent({
loggedInUserInfo,
history,
@Kannndev
Kannndev / nginx.conf
Created August 27, 2020 17:45
Nginx Conf
server {
listen 8081;
server_name localhost;
root /usr/local/var/www/ui;
index index.html;
location /ui {
try_files $uri $uri/ /index.html$is_args$args;
}
@Kannndev
Kannndev / Nginx Conf with base route
Last active August 28, 2020 03:32
Nginx Conf with base route aws fix
server {
listen 8081;
server_name localhost;
root /usr/local/var/www;
index /ui/index.html;
location /ui {
try_files $uri $uri/ /ui/index.html$is_args$args;
}
@Kannndev
Kannndev / CustomImplicitCallback.js
Last active August 28, 2020 06:12
Okta Custom Implicit Callback workaround for infinite loop if all routes are secured
import React, { useState, useEffect } from 'react';
import { Redirect } from 'react-router-dom';
import { withOktaAuth } from '@okta/okta-react';
import PropTypes from 'prop-types';
const CustomImplicitCallback = (props) => {
const { authService, authState } = props;
const [authInfo, setAuthInfo] = useState({});
useEffect(() => {
const selectAllValues = (checked) => {
const optionsWithFilterApplied = filteredOptions();
const newOptions = [...value];
optionsWithFilterApplied.filter(({disabled}) => !disabled).forEach((o) => {
const index = newOptions.findIndex(elem => elem.value === o.value);
if (checked) {
if (index === -1) {
newOptions.push(o)
}
} else {
@Kannndev
Kannndev / Promise-all.js
Created October 4, 2020 10:23
Medium - Promise.all Examples
// Example 1:
const dog = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐶'), 1000)
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐈'), 2000)
})
Promise.all([dog, cat]).then((values) => {
// Order of values will be in the same order
@Kannndev
Kannndev / Promise-race.js
Created October 4, 2020 10:26
Medium Promise.race Examples
// Example 1:
const dog = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐶'), 1000)
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐈'), 2000)
})
Promise.race([dog, cat]).then((value) => {
// value will be the resolved value of
@Kannndev
Kannndev / Promis-any.js
Created October 4, 2020 10:28
Medium Promise-any examples
// Example 1:
const dog = new Promise((resolve, reject) => {
setTimeout(() => reject('🐶'), 1000)
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐈'), 2000)
})
Promise.any([dog, cat]).then((value) => {
// value will be the resolved value of
@Kannndev
Kannndev / Promis-allSettled.js
Created October 4, 2020 10:29
Medium Promise.allSettled examples
// Example 1:
const dog = new Promise((resolve, reject) => {
setTimeout(() => resolve('🐶'), 1000)
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => reject('🐈'), 2000)
})
Promise.allSettled([dog, cat]).then((values) => {
console.log(values);
@Kannndev
Kannndev / Promise-bonus.js
Created October 4, 2020 10:31
Medium Promise-Bonus tip example
const dog = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('🐶');
console.log('I am still executing!!');
}, 1000);
})
const cat = new Promise((resolve, reject) => {
setTimeout(() => {
reject('🐈');
console.log('Even I am!!');