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 DatePicker from "react-datepicker"; | |
| import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | |
| import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons"; | |
| import "react-datepicker/dist/react-datepicker.css"; | |
| import styles from "./styles.module.css"; | |
| interface Props<Key> { | |
| id: Key; | |
| value?: Date | null; |
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
| async function createToken(tokenParams: CustomerCreateInput) { | |
| const [month, year] = tokenParams.expiry.split('/'); | |
| const res = await fetch('https://api.conekta.io/tokens', { | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| card: { | |
| number: tokenParams.number.replace(/\s/g, ''), | |
| cvc: tokenParams.cvc, | |
| exp_month: month, | |
| exp_year: year, |
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"; | |
| export interface FormHandlerChildrenProps<T> { | |
| state: FormState<T>; | |
| reload?: () => Promise<void>; | |
| create?: () => Promise<void>; | |
| update?: () => Promise<void>; | |
| remove?: () => void; | |
| onChange: (change: { id: string; value: any }) => void; | |
| setModal: (name: string) => void; |
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 { User } from "@firebase/auth-types"; | |
| import { getAuth } from "./firebase"; | |
| import { isAdmin } from "../services/auth"; | |
| export interface AuthContextState { | |
| status: "loading" | "loaded" | "failure"; | |
| user: User | null; | |
| isAdmin: boolean; | |
| } |
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
| changeProfileImage = async e => { | |
| const metadata = { cacheControl: 'public,max-age=300', gzip: true }; | |
| const uid = this.state.user.uid; | |
| const response = await fetch(e.uri); | |
| const blob = await response.blob(); | |
| const imageRef = this.storage.child(`profileImages/${uid}.png`); | |
| const uploadTaskSnapshot = await imageRef.put(blob, metadata); | |
| const photoURL = await uploadTaskSnapshot.ref.getDownloadURL(); | |
| await this.state.user.updateProfile({ photoURL }); | |
| this.setState({ user: firebase.auth.currentUser }); |
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
| /* Firebase Functions messes with your request and will wreck your day because none of the | |
| * traditional upload handlers with Express will work. | |
| * | |
| * Credit: https://stackoverflow.com/questions/47242340/how-to-perform-an-http-file-upload-using-express-on-cloud-functions-for-firebase | |
| */ | |
| const Busboy = require('busboy'); | |
| const allowedMethods: string[] = ['POST', 'PUT']; | |
| export class FileUpload { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <script src="https://d3js.org/d3-array.v2.min.js"></script> | |
| <script src="https://d3js.org/d3-color.v1.min.js"></script> | |
| <script src="https://d3js.org/d3-format.v1.min.js"></script> |
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> | |
| <head> | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/matter.js"></script> | |
| </head> | |
| <body> | |
| <script> | |
| // module aliases | |
| const Engine = Matter.Engine; | |
| const Render = Matter.Render; | |
| const World = Matter.World; |
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 omit from 'lodash/omit'; | |
| import throttle from 'lodash/throttle'; | |
| import pick from 'lodash/pick'; | |
| export const loadState = () => { | |
| try { | |
| const serialized = localStorage.getItem('store'); | |
| if (!serialized) return undefined; |
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 getBaseNumber = num => parseInt('1'.padEnd(String(num).length, '0')) | |
| const roundNumber = num => Math.ceil(num / getBaseNumber(num)) * getBaseNumber(num) | |
| const getNumberOfTicks = num => roundNumber(num) / getBaseNumber(num) | |
| console.log(getBaseNumber(4500)) | |
| console.log(roundNumber(4800)) | |
| console.log('ticks: ', getNumberOfTicks(4500)) |