This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useMemo, useReducer } from "react"; | |
import { | |
setItemInLocalStorage, | |
getUserDetailsFromStorage, | |
clearLocalStorage, | |
} from "../../helpers"; | |
import { USER_TOKEN } from "../../constants"; | |
import { AuthContext, initialAuthState } from "./AuthContext"; | |
import { useActivityContext } from "../activity/ActivityContext"; | |
import { userReducer } from "../../reducers"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useContext } from "react"; | |
export const initialAuthState = { | |
isLoggedIn: false, | |
}; | |
export const AuthContext = createContext({ | |
user: initialAuthState, | |
updateUserContext: () => {}, | |
clearUserContext: () => {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ProtectedRoutes from "../routes/ProtectedRoutes"; | |
function MyApp({ Component, pageProps,router }) { | |
return ( | |
<ProtectedRoutes router={router}> | |
<Component {...pageProps} /> | |
</ProtectedRoutes> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ProtectedRoute = ({ router, children }) => { | |
return children; | |
}; | |
export default ProtectedRoute; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { appRoutes } from "../constants"; | |
import { useAuthContext } from "../contexts"; | |
const ProtectedRoute = ({ router, children }) => { | |
//Identify authenticated user | |
const { user } = useAuthContext(); | |
const isAuthenticated = user.isLoggedIn; | |
let unprotectedRoutes = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { appRoutes } from "../constants"; | |
import { useAuthContext } from "../contexts"; | |
//check if you are on the client (browser) or server | |
const isBrowser = () => typeof window !== "undefined"; | |
const ProtectedRoute = ({ router, children }) => { | |
//Identify authenticated user | |
const { user } = useAuthContext(); | |
const isAuthenticated = user.isLoggedIn; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# to read just one sheet to dataframe: | |
A = pd.read_excel(file_name, sheetname="sheet1") | |
B = pd.read_excel(file_name, sheetname="sheet2") | |
print(A.columns) | |
print(B.columns) | |
Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import java.util.ArrayList; | |
import java.util.List; | |
class RegexExample | |
{ | |
public static void main(String args[]) | |
{ | |
//An array list to create a list of emails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal (){ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"numberOfLegs":"four", | |
"numberOfEyes": 2, | |
"locationOfEyes": "front of the head" | |
"colour":"brown", | |
"body": "fur", | |
"sound":"meow meaow", | |
} |
NewerOlder