git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
| import { FunctionComponent } from 'react' | |
| const combineProviders = (providers: FunctionComponent[]) => providers.reduce((Combined, [Provider, props = {}]) => ({ children }) => ( | |
| <Combined> | |
| <Provider {...props}>{children}</Provider> | |
| </Combined> | |
| )) | |
| const App = () => { |
| function fib(n) { | |
| const A = (1 + Math.sqrt(5)) / 2; | |
| const B = (1 - Math.sqrt(5)) / 2; | |
| fib = (Math.pow(A, n) + Math.pow(B, n)) / Math.sqrt(5); | |
| return Math.ceil(fib) | |
| } |
| export default function debounce<F extends (...args: any[]) => any>( | |
| duration: number, | |
| fn: F, | |
| ) { | |
| let timeout: number | null; | |
| return function(this: any, ...args: Parameters<F>) { | |
| if (timeout) { | |
| window.clearTimeout(timeout); | |
| } | |
| timeout = window.setTimeout(() => { |
| import styled from 'styled-components'; | |
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| const ErrorStyles = styled.div` | |
| padding: 2rem; | |
| background: white; | |
| margin: 2rem 0; | |
| border: 1px solid rgba(0, 0, 0, 0.05); |
| handleChange = (e) => { | |
| const {name, type, value} = e.target; | |
| const val = type === 'number' ? parseFloat(value) : value; | |
| this.setState({[name]: val}) | |
| }; |
| uploadFile = async e => { | |
| const files = e.target.files; | |
| const data = new FormData(); | |
| data.append('file', files[0]); | |
| data.append('upload_preset', 'sick-fits'); | |
| const res = await fetch('https://api.cloudinary.com/v1_1/${YOUR_API_URL}/image/upload', { | |
| method: 'post', | |
| body: data |
| export default function(amount) { | |
| const options = { | |
| style: 'currency', | |
| currency: 'IDR', | |
| minimumFractionDigits: 0, | |
| }; | |
| // if its a whole, dollar amount, leave off the .00 | |
| if (amount % 100 === 0) options.minimumFractionDigits = 0; | |
| // Better performance | |
| function palindrome(str) { | |
| // 1. make all letters lowercase and remove non-alphanumeric characters | |
| str = str.toLowerCase().replace(/[\W_]/g, ""); | |
| // 2. check if the length of the string is 0 then it is a palindrome | |
| if (str.length === 0){ | |
| return true; | |
| } | |
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream