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
fetchCsv() { | |
var rawFile = new XMLHttpRequest(); | |
rawFile.open("GET", require("path/to/local/file.txt"), false); | |
rawFile.onreadystatechange = () => { | |
if (rawFile.readyState === 4) { | |
if (rawFile.status === 200 || rawFile.status === 0) { | |
var allText = rawFile.responseText; | |
Papa.parse(allText, { | |
complete: this.setData, // in this case, set the text as react state |
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, { | |
useState, | |
useLayoutEffect | |
} from 'react'; | |
import ReactDOM from 'react-dom'; | |
const BlinkyRender = () => { | |
const [value, setValue] = useState(0); | |
useLayoutEffect(() => { |
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 { useEffect, useState } from 'react'; | |
interface IProps { | |
imagesToLoad: string[], | |
} | |
const useImagesAreLoaded = ({ imagesToLoad }: IProps): boolean => { | |
const [loadedTilesCount, setLoadedTilesCount] = useState(0); | |
useEffect((): void => { |
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, { FC, FunctionComponent } from 'react'; | |
import { LoadingSpinner } from '@components/LoadingSpinner'; | |
interface IProps { | |
isLoading: boolean; | |
} | |
// eslint-disable-next-line @typescript-eslint/ban-types, react/display-name | |
const WithLoadingSpinner = <P extends object>(Component: FunctionComponent<P>): FC<P & IProps> => ({ | |
isLoading, |
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
export const getTopY = (element: HTMLElement, downOffset: number): number => { | |
return element.getBoundingClientRect().top + window.pageYOffset - downOffset; | |
}; |
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 UA = req.headers['user-agent']; | |
const isMobile = Boolean(UA.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i)); |
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
{ | |
"version": 2, | |
"builds": [ | |
{ | |
"src": "src/app.js", | |
"use": "@vercel/node" | |
} | |
], | |
"routes": [ | |
{ |
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 S from '@effect/schema/Schema' | |
import { Context, Effect } from 'effect' | |
export interface IFetcher { | |
fetch: typeof fetch | |
} | |
export const TFetcher = Context.Tag<IFetcher>('IFetcher') | |
class FreshFetcher implements IFetcher { |
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
async function getAccessToken() { | |
return Effect.runPromise( | |
fetchFresh<{ access_token: string }>( | |
null, | |
'https://accounts.spotify.com/api/token', | |
{ | |
method: 'POST', | |
headers: { | |
Authorization: `Basic ${Buffer.from( | |
`${process.env.SPOTIFY_CLIENT_ID}:${process.env.SPOTIFY_CLIENT_SECRET}` |
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 getAccessToken = fetchFresh<{ access_token: string }>( | |
null, | |
'https://accounts.spotify.com/api/token', | |
{ | |
method: 'POST', | |
headers: { | |
Authorization: `Basic ${Buffer.from( | |
`${process.env.SPOTIFY_CLIENT_ID}:${process.env.SPOTIFY_CLIENT_SECRET}` | |
).toString('base64')}`, | |
'Content-Type': 'application/x-www-form-urlencoded', |
OlderNewer