Skip to content

Instantly share code, notes, and snippets.

View azeezat's full-sized avatar

Azeezat Raheem azeezat

View GitHub Profile
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";
import { createContext, useContext } from "react";
export const initialAuthState = {
isLoggedIn: false,
};
export const AuthContext = createContext({
user: initialAuthState,
updateUserContext: () => {},
clearUserContext: () => {},
import ProtectedRoutes from "../routes/ProtectedRoutes";
function MyApp({ Component, pageProps,router }) {
return (
<ProtectedRoutes router={router}>
<Component {...pageProps} />
</ProtectedRoutes>
)
}
const ProtectedRoute = ({ router, children }) => {
return children;
};
export default ProtectedRoute;
import { appRoutes } from "../constants";
import { useAuthContext } from "../contexts";
const ProtectedRoute = ({ router, children }) => {
//Identify authenticated user
const { user } = useAuthContext();
const isAuthenticated = user.isLoggedIn;
let unprotectedRoutes = [
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;
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:
@azeezat
azeezat / Regex.java
Last active March 20, 2020 13:29
Regex in Java
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
class Animal (){
}
@azeezat
azeezat / description-of-an-item.json
Last active July 29, 2023 06:35
Object description
{
"numberOfLegs":"four",
"numberOfEyes": 2,
"locationOfEyes": "front of the head"
"colour":"brown",
"body": "fur",
"sound":"meow meaow",
}