This file contains 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 based | |
class MyComponent { | |
renderSwitch(param) { | |
switch(param) { | |
case 'foo': | |
return 'bar'; | |
default: | |
return 'foo'; | |
} | |
} |
This file contains 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 { awaitWrap } from 'await-wrapper'; | |
const fakePromise = () => new Promise(resolve => setTimeout(resolve("hi")), 500); | |
const fakePromiseReject = () => new Promise((__, reject) => setTimeout(reject("no")), 500); | |
const resolveCallback = response => { | |
// do something with response | |
} | |
const rejectCallback = error => { | |
// do something with error |
This file contains 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 { awaitWrap } from 'await-wrapper'; | |
const fakePromise = () => new Promise(resolve => setTimeout(resolve("hi")), 500); | |
const fakePromiseReject = () => new Promise((__, reject) => setTimeout(reject("no")), 500); | |
const fakePromiseHandler = async () => { | |
const { error, data } = await awaitWrap(fakePromise()); // { error: null, data: "hi" }; | |
error ? console.error(error) : console.log(data); | |
} |
This file contains 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 * as AuthSession from 'expo-auth-session'; | |
import jwtDecode from 'jwt-decode'; | |
import { Alert, Platform, StyleSheet, Image } from 'react-native'; | |
// you need to swap out these details with your auth0 credientals | |
const auth0ClientId = ""; | |
const authorizationEndpoint = "https://yourtennant.auth0.com/authorize"; | |
const useProxy = Platform.select({ web: false, default: true }); |
This file contains 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 { Builder, By } = require('selenium-webdriver'); | |
(async function hi() { | |
let driver = await new Builder().forBrowser('chrome').build(); | |
try { | |
await driver.get('https://web.hi.com'); | |
const areaCode = await driver.findElement(By.css('.areaCode')); | |
await areaCode.click(); | |
await driver.sleep(500); | |
const search = await driver.findElement(By.css('.searchs .uni-input-wrapper .uni-input-input')); |
This file contains 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 cache = {}; | |
function changePhonesStatus(phones = {}, unavailable = []) { | |
const key = JSON.stringify(unavailable); | |
// generates a string array e.g. "[1,2,3]" | |
if (cache[key]) { | |
return cache[key]; | |
} | |
// we need to look at each department and update the phones for that department. | |
const updatedPhones = Object.keys(phones.departments).reduce((acc, key) => { |
This file contains 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 subscribeToPHoneData = async () => { | |
// fetch the phones url | |
const phones = await getData(PHONES_URL); | |
const phoneAvailabilityCheck = setInterval(async () => { | |
const { unavailableIds } = await getData(AVAILABILITY_URL); | |
changePhonesStatus(phones, unavailable); | |
// should return an object with the updated phone system | |
/* | |
if(someCondition) { clearInterval(phoneAvailabilityCheck) } | |
*/ |
This file contains 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 from 'react'; | |
import jwtDecode from 'jwt-decode'; | |
import * as AuthSession from 'expo-auth-session'; | |
import { openAuthSessionAsync } from 'expo-web-browser'; | |
import { Alert, Button, Platform, StyleSheet, Text, View } from 'react-native'; | |
const auth0ClientId = ""; | |
const authorizationEndpoint = "https://youraccount.eu.auth0.com/v2/logout"; |
This file contains 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 from 'react'; | |
import { StyleSheet, Text, View, Button, Alert } from 'react-native'; | |
import { AuthSession } from 'expo'; | |
import jwtDecode from 'jwt-decode'; | |
/* | |
You need to swap out the Auth0 client id and domain with | |
the one from your Auth0 client. | |
In your Auth0 client, you need to also add a url to your authorized redirect urls. | |
For this application, I added https://auth.expo.io/@arielweinberger/auth0-example because I am |
This file contains 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 { useState, createContext, useContext, useEffect } from "react"; | |
import "./styles.css"; | |
const AuthContext = createContext({}); | |
const useAuth = () => useContext(AuthContext); | |
const AuthProvider = ({ children }) => { | |
const [username, setUsername] = useState(""); | |
const handleUpdateUsername = ({ target: { value } }) => setUsername(value); |
NewerOlder