Skip to content

Instantly share code, notes, and snippets.

View gabrielpetersson's full-sized avatar
Focusing

Gabriel Petersson gabrielpetersson

Focusing
View GitHub Profile
use skia_safe::{
gpu::gl::FramebufferInfo,
gpu::BackendRenderTarget,
gpu::DirectContext,
Color,
Paint,
PaintStyle,
Surface,
Rect,
Point,
type EnumInputProps =
| {
isMultiSelect: true;
options: EnumOption[];
selected: EnumOption[];
onChange: (value: string[]) => void;
}
| {
isMultiSelect: false;
options: EnumOption[];
export const fetchRetry = async (
fetch: () => Promise<Response>,
maxTries: number = 4
): Promise<Response | "error"> => {
for (let tries = 0; tries < maxTries; tries++) {
if (tries !== 0) {
await wait(Math.pow(2, tries + 1) * 1000);
}
try {
const response = await fetch();
import { FC, useState } from "react";
import styled from "styled-components";
import { useAppSelector } from "../../state";
import { selectActiveTab } from "../../state/selectors";
import { colors } from "../../styles";
import { assertNever } from "../../util";
import { ConnectedModulesPage } from "../modules/ModulesPage";
import styles from "./MainView.module.scss";
import { TablesPage } from "./TablesPage";
const rows: any = [];
for (let i = 0; i < 14; i++) {
const [key, ordinal] = await Promise.all([
extra.keyGenerator.nextKey(),
extra.ordinalGenerator.nextOrdinal(),
]);
rows.push({
key,
values: [{ kind: "string", value: ordinal }],
const getIsRangeAlreadyCorrect = () => {
const ranges = gridApi.getCellRanges();
if (ranges == null || ranges.length !== 1) {
return false;
}
const range = ranges[0]!;
if (range.columns.length !== 1) {
return false;
}
if (isSearchBarClosing) {
(async () => {
await wait(300);
if (gridApi == null) {
return;
}
const ranges = gridApi.getCellRanges();
if (ranges?.length !== 1) {
import { log } from "../logging";
import { usePrevious } from "./usePrevious";
// NOTE(gab): Put dependencies in an object & see which deps makes
// components rerender
export const useDependencyDebugger = (
dependencies: Record<string, unknown>
): void => {
const dependencyValues = Object.values(dependencies);
const dependencyNames = Object.keys(dependencies);
import Tippy from "@tippyjs/react/headless";
import { FC, ReactElement, ReactNode } from "react";
import styled from "styled-components";
import { Spacer } from "../../../components/Spacer";
import { Txt } from "../../../components/Txt";
import { colors } from "../../../styles";
import { ColumnDisplayType } from "../../../util/column-display-config";
const TooltipContainer = styled.div`
display: flex;