Description |
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
'use strict'; | |
import * as uuid from 'uuid'; | |
import { Client, ClientDao } from '../dao/ClientDao'; | |
import { Token, TokenDao } from '../dao/TokenDao'; | |
import { User, UserDao } from '../dao/UserDao'; | |
export const getAccessToken = async (bearerToken: string) => { | |
const token = await TokenDao.loadByToken(bearerToken); |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>HTML5 Test Page</title> | |
</head> | |
<body> | |
<div id="top" class="page" role="document"> | |
<header role="banner"> |
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 puppeteer from 'puppeteer' | |
import fs from 'fs' | |
async function buildPDF(htmlString) { | |
const browser = await puppeteer.launch({ headless: true }) | |
const page = await browser.newPage(); | |
await page.setContent(htmlString, { waitUntil: 'networkidle0' }) | |
const pdf = await page.pdf({ | |
format: 'A4', | |
displayHeaderFooter: false, |
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 { ApolloError } from 'apollo-boost'; | |
import { print } from 'graphql/language/printer'; | |
import React from 'react'; | |
const queries = new Map(); | |
const getCacheKey = ({ query, ...opts }) => | |
`${print(query)}@@${JSON.stringify(opts)}`; | |
const invalidateCachedQuery = options => |
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
// If the user has been on the page for over 12 hours, the next link | |
// click will do a full page transition to get new code | |
import React from "react"; | |
import { BrowserRouter, useLocation } from "react-router-dom"; | |
let hour = 3600000; | |
export default function StaleAppRouter(props) { | |
let [isStale, setIsStale] = useState(false); |
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 React from 'react'; | |
/** | |
* React.Ref uses the readonly type `React.RefObject` instead of | |
* `React.MutableRefObject`, We pretty much always assume ref objects are | |
* mutable (at least when we create them), so this type is a workaround so some | |
* of the weird mechanics of using refs with TS. | |
*/ | |
export type AssignableRef<ValueType> = | |
| { |
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
function prefetch(getKey, getValue, getInitialValue, propName) { | |
const inFlight = new Set(); | |
const cache = new Map(); | |
return ChildComponent => { | |
return class extends React.Component { | |
state = {value: getInitialValue(this.props)}; | |
componentWillReceiveProps(nextProps) { | |
const key = getKey(nextProps); | |
if (cache.has(key)) { | |
// Use cached value |
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 { useRef, useCallback, useEffect } from 'react' | |
import { useInView } from 'react-intersection-observer' | |
import 'intersection-observer' | |
export default ({ src, caption, ratio }) => { | |
const [inViewRef, inView] = useInView({ | |
threshold: 1, | |
}) | |
const videoRef = useRef() |