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 addMenu() { | |
DocumentApp.getUi().createMenu('Headings Tools') | |
.addItem('Auto Number Headings', 'numberHeadingsAdd') | |
.addItem('Clear Heading Numbers', 'numberHeadingsClear') | |
.addToUi(); | |
} | |
function numberHeadingsAdd(){ | |
numberHeadings(true); | |
} |
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
// document body dimensions (exluding scrollbars) | |
export function getBodyDimensions() { | |
return { | |
width: document.body.clientWidth, | |
height: document.body.clientHeight | |
}; | |
} | |
// client offset (typically non-existent) | |
export function getClientOffset() { |
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, useRef } from "react"; | |
export const useAnimateNumber = ({ | |
start = 0, | |
end, | |
delay = 0, | |
duration = 0.5, | |
easing = (t) => t * (2 - t), // ease out quad | |
}: { | |
start?: number; |
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
class Timer { | |
start: number; | |
constructor() { | |
this.start = performance.now(); | |
} | |
elapsed() { | |
return performance.now() - this.start; | |
} | |
} |
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 path from "path"; | |
export const joinUrl = (base: string, ...paths: string[]) => { | |
return path.posix | |
.join(base, ...paths.map((p) => p.toString())) | |
.replace(":/", "://"); | |
}; |
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 Spinner: React.FC<{ size: 4 | 8 | 12 | 16; stroke?: number }> = ({ | |
size, | |
stroke = 1, | |
}) => { | |
return ( | |
<svg | |
className={`text-green-700 animate-spin w-${size}`} | |
xmlns="http://www.w3.org/2000/svg" | |
fill="none" | |
viewBox="-2 -2 28 28" |
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 isEquivalent<T>(received: T, expected: T) { | |
return received && expected && typeof received === "object" | |
? isValueEquivalent(received, expected) | |
: received === expected; | |
} | |
function isValueEquivalent(a: Record<string, any>, b: Record<string, any>) { | |
const aPropertyNames = Object.getOwnPropertyNames(a); | |
const bPropertyNames = Object.getOwnPropertyNames(b); |
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 enum OS { | |
Android = "Android", | |
iOS = "iOS", | |
Linux = "Linux", | |
Mac = "Mac", | |
Unix = "Unix", | |
Windows = "Windows", | |
Other = "Other", | |
} |
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 swap = (arr, i, j) => { | |
const temp = arr[i] | |
arr[i] = arr[j] | |
arr[j] = temp; | |
} | |
const partition = (arr, start, end) => { | |
let pivot = arr[end]; | |
let low = start; | |
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 express from "express"; | |
import fs from "fs"; | |
import helmet from "helmet"; | |
import https from "https"; | |
import path from "path"; | |
const app = express(); | |
// avoid having to manually tweak CSP, HSTS, X-Powered-By, MIME-sniffing, etc.; set the strictest CSP possible | |
app.use(helmet({ contentSecurityPolicy: { directives: { defaultSrc: "'self'" } } })); | |
app.use(express.json()); |
OlderNewer