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 { useCallback, useState } from "react"; | |
import { Platform } from "react-native"; | |
import { ImageInfo } from "expo-image-picker"; | |
import * as mime from "mime"; | |
export default function useUploadAvatar() { | |
const [uploading, setUploading] = useState(false); | |
const [error, setError] = useState<Error | null>(null); | |
const [data, setData] = useState(null); | |
const { accessToken } = useAuth(); |
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
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
Cloning into 'my-awesome-proj'... | |
ssh: connect to host github.com port 22: Connection timed out | |
fatal: Could not read from remote repository. | |
$ # This should also timeout | |
$ ssh -T [email protected] | |
ssh: connect to host github.com port 22: Connection timed out | |
$ # but this might work |
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
<html> | |
<body> | |
<form id="form"> | |
<input id="input" required /> | |
</form> | |
<ul id="list"></ul> | |
<button id="clear-all">clear all completed</button> | |
<script> | |
let todos = []; |
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 pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse' 'Lion', 'Dragon']; | |
// Print all pets: NOT DRY | |
console.log(pets[0]); | |
console.log(pets[1]); | |
console.log(pets[2]); | |
console.log(pets[3]); | |
/** | |
* SOLUTION | |
* We use a for loop to eliminate repetition |
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 from 'react'; | |
import { View, Text, Image } from 'react-native'; | |
import emojiRegex from 'emoji-regex'; | |
const avatarColors = [ | |
'red', | |
'blue', | |
'green' | |
]; |
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 HOST = process.env.GEODB_HOST; | |
const KEY = process.env.GEODB_API_KEY; | |
const printableNumber = num => (num < 0 ? "" : "+") + num; | |
const parseLocation = location => { | |
const { lat, lng } = location; | |
return `${printableNumber(lat)}${printableNumber(lng)}` | |
}; |
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 getSectionItemLayout = ({ | |
getItemHeight = () => 0, | |
getSeparatorHeight = () => 0, | |
getSectionHeaderHeight = () => 0, | |
getSectionFooterHeight = () => 0, | |
listHeaderHeight = 0, | |
listFooterHeight = 0, | |
}) => (sections, index) => { | |
let length = 0, offset = 0, currentIndex = 0; |
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 from 'react'; | |
import { | |
GoogleSignin, | |
statusCodes | |
} from 'react-native-google-signin'; | |
import SimpleToast from 'react-native-simple-toast'; | |
import Button from './Button'; | |
export default class Container extends React.Component { | |
state = { |
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 { GoogleSignin } from 'react-native-google-signin'; | |
export default class GoogleOAuth { | |
refreshGoogleToken = () => { | |
return this._refreshGoogleTokenImpl(); | |
} | |
_refreshGoogleTokenImpl = () => { | |
return new Promise(async (res, rej) => { | |
const isSignedIn = await GoogleSignin.isSignedIn(); |
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
/** | |
* @function stripJSON | |
* @desc - This function removes selected object keys | |
* @param {Object} json - JavaScript object to strip | |
* @param {Object[]} keys - array of selected keys (string) | |
* @return {Object} - deep copy of object without keys | |
*/ | |
function stripJSON(json, keys) { | |
if (json === null || json === undefined) return json; | |
let obj = {}, key; |