Skip to content

Instantly share code, notes, and snippets.

Avatar

Kannan Kannndev

View GitHub Profile
View Empty route
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,
View 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 Aug 28, 2020
Nginx Conf with base route aws fix
View Nginx Conf with base route
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 Aug 28, 2020
Okta Custom Implicit Callback workaround for infinite loop if all routes are secured
View CustomImplicitCallback.js
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(() => {
View Multi select changes
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 Oct 4, 2020
Medium - Promise.all Examples
View Promise-all.js
// 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 Oct 4, 2020
Medium Promise.race Examples
View Promise-race.js
// 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 Oct 4, 2020
Medium Promise-any examples
View Promis-any.js
// 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 Oct 4, 2020
Medium Promise.allSettled examples
View Promis-allSettled.js
// 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 Oct 4, 2020
Medium Promise-Bonus tip example
View Promise-bonus.js
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!!');