Skip to content

Instantly share code, notes, and snippets.

View burtonator's full-sized avatar

Kevin Burton burtonator

View GitHub Profile
{
"userConfig":{
"user_id":"google-oauth2|110773850460183149003",
"datasource":{
"id":"tlsn-swapi",
"image":"https://swapi.dev/static/favicon.ico",
"label":"swapi",
"link":"https://swapi.dev",
"login_url":"https://swapi.dev",
"name":"Star Wars API",
{
"userConfig":{
"user_id":"google-oauth2|110773850460183149003",
"datasource":{
"id":"tlsn-swapi",
"image":"https://swapi.dev/static/favicon.ico",
"label":"swapi",
"link":"https://swapi.dev",
"login_url":"https://swapi.dev",
"name":"Star Wars API",
{
"common": {
"black": "#000",
"white": "#fff"
},
"type": "dark",
"primary": {
"main": "rgb(103, 84, 214)",
"light": "rgb(133, 118, 222)",
"dark": "rgb(72, 58, 149)",
import firebase from 'firebase/app'
import 'firebase/firestore';
import {Latch} from "polar-shared/src/util/Latch";
import {Tracer} from "polar-shared/src/util/Tracer";
import {Bytes} from "polar-shared/src/util/Bytes";
require('firebase/auth');
async function doTestFirestore() {
const key = {
{
"name": "projects/polar-32b0f/databases/(default)/documents/block/15ChjnUstZ",
"fields": {
"parent": {
"stringValue": "12QNeyXVZ7"
},
"root": {
"stringValue": "12QNeyXVZ7"
},
"nspace": {
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.
@burtonator
burtonator / 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
@burtonator
burtonator / 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.
@burtonator
burtonator / useLocalStorageState.ts
Last active June 14, 2021 17:20
useLocalStorageState
export function useLocalStorageState() {
}
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;