Skip to content

Instantly share code, notes, and snippets.

View InputNeuron's full-sized avatar

Kevin Burton InputNeuron

View GitHub Profile
import createPersistedState from "use-persisted-state";
import {MUIThemeTypeContext, ThemeType} from "./context/MUIThemeTypeContext";
import {createMuiTheme, MuiThemeProvider} from "@material-ui/core/styles";
import CssBaseline from "@material-ui/core/CssBaseline";
import {GlobalCss} from "./css/GlobalCss";
import * as React from "react";
import {GlobalCssSummernote} from "./css/GlobalCssSummernote";
import {GlobalCSSBootstrap} from "./css/GlobalCSSBootstrap";
import {FirestoreProvider} from "../../../apps/repository/js/FirestoreProvider";
import {GlobalCssMobile} from "./css/GlobalCssMobile";
import React from 'react';
import {useLocation} from 'react-router-dom';
import {HashURLs} from "polar-shared/src/util/HashURLs";
import {IDStr} from "polar-shared/src/util/Strings";
interface IProps {
readonly children: React.ForwardRefRenderFunction<HTMLDivElement, any>;
// readonly children: React.ReactNode;
}
import * as functions from "firebase-functions";
import {Fetches} from "polar-shared/src/util/Fetch";
import {PassThrough, Writable} from 'stream';
/**
* Perform an HTTP request on behalf of the user. For the web application we
* have to proxy requests to download objects or else they they don't
*
import {ILTRect} from './rects/ILTRect';
import {Preconditions} from '../Preconditions';
import {DataURL, DataURLs} from './DataURLs';
import {IDimensions} from "./IDimensions";
import {ImageType} from "./ImageType";
const DEFAULT_IMAGE_TYPE = 'image/png';
const DEFAULT_IMAGE_QUALITY = 1.0;
type FetchResponseError = {
readonly code: 'fetch-response-error';
readonly message: string;
readonly status: number;
readonly statusText: string;
};
type FetchError = {
readonly code: 'fetch-error',
readonly message: string;
@InputNeuron
InputNeuron / useLocalStorageState.ts
Last active June 14, 2021 17:20
useLocalStorageState
export function useLocalStorageState() {
}
@InputNeuron
InputNeuron / useLocalStorageState.ts
Last active July 9, 2021 13:03
useLocalStorageState.ts
import React from 'react';
/**
* Implement a replacement for useState which keeps values in the localStorage.
*
* The idea here is that all calls to use useState can be replaced with
* useLocalStorageState(key, initialValue) and implement the same behavior.
*
* The first time useLocalStorageState is called the value will be initialValue
* because nothing is stored in localStorage.
@InputNeuron
InputNeuron / RingBuffer.ts
Last active July 8, 2021 16:07
ring buffer...
import {assert} from 'chai';
/**
* Implement a class named ring buffer with fixed capacity such that
*
* constructor: takes the capacity for the ring buffer
*
* push: adds a value to the ring buffer.
* pop: removes the last value from the ring buffer or undefined if it's empty.
* peek: returns the current value of the most recent value added or undefined if none have been added
import {assert} from 'chai';
export namespace Dictionaries {
/**
* Create a deep copy of a dictionary such that all of the origina keys are maintained
* and copied into a new dictionary.
*
* This is used when we have to create a copy of a dictionary to prevent concurrent mutation
* or when we need to copy it and then make changes to the new dictionary.
{
"name": "projects/polar-32b0f/databases/(default)/documents/block/15ChjnUstZ",
"fields": {
"parent": {
"stringValue": "12QNeyXVZ7"
},
"root": {
"stringValue": "12QNeyXVZ7"
},
"nspace": {