Let's examine the type for Entity.
export interface Model {};
export type Entity<
TModels extends Model[],
> = {
id?: string,
creatorId?: string,
createTimeMs?: number,| import { calcDist, canReachCorner, getRectIntersections, intersectsCircle, intersectsRect, isPointWithinBounds, solutionsForY, solutionsForX, getCircleIntersections } from "./leet"; | |
| describe('leet', () => { | |
| describe('calcDist', () => { | |
| it('calcs dist', () => { | |
| expect(calcDist([0, 0], [0, 1])).toEqual(1); | |
| }); |
| function compareSemver(a: string, b: string) { | |
| const aSemver = a.split('-')[1].split('.'); | |
| const bSember = b.split('-')[1].split('.'); | |
| for (let i = 0; i < 3; i++) { | |
| const aPart = parseInt(aSemver[i], 10); | |
| const bPart = parseInt(bSember[i], 10); | |
| if (aPart > bPart) { |
| #!/usr/bin/env ts-node | |
| import { spawn } from 'node:child_process'; | |
| import * as fs from "node:fs"; | |
| // This script generates test output | |
| // files for each jest test so | |
| // you can view the diffs in an external | |
| // diff viewer | |
| function sortByKey(obj: any): any { |
| // ==UserScript== | |
| // @name Alt Click Copy | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1.0 | |
| // @description Alt click an HTML element on the page to copy it to your clipboard. | |
| // @author mchpatr | |
| // @match *://*/* | |
| // @icon https://github.com/prmichaelsen/alt-click-copy/releases/download/alt-click-copy/save.icon.png | |
| // @run-at document-start | |
| // ==/UserScript== |
| import { Readable, Writable } from "node:stream"; | |
| import { spawn } from "node:child_process"; | |
| export const execCommand = async (cmd: string) => { | |
| const ps = spawn("sh", { env: process.env }); | |
| const data: string[] = []; | |
| const outputStream = new Writable({ | |
| write(chunk, encoding, callback) { |
| rmrf () { | |
| trash="$HOME/.trash" | |
| mkdir -p $trash | |
| if [ -z "$1" ]; then | |
| echo "Usage: rmrf <dir>"; | |
| return 1 | |
| else | |
| while [ -n "$1" ] | |
| do | |
| dir="$PWD/$1" |
| gitf () | |
| { | |
| prefix="dev/$USER/" | |
| branch=$(git rev-parse --abbrev-ref HEAD) | |
| if [[ "$branch" = $prefix* ]]; then | |
| echo "[INFO]: Force pushing to branch '$branch'..." | |
| git push origin ":$branch" ; git push origin -u "$branch" | |
| else | |
| echo "[INFO]: Cannot push to branch '$branch' because it does not match prefix '$prefix'." | |
| } |
Let's examine the type for Entity.
export interface Model {};
export type Entity<
TModels extends Model[],
> = {
id?: string,
creatorId?: string,
createTimeMs?: number,| import { NonObject } from "./core-types"; | |
| export type DeepComplete<T> = T extends NonObject | |
| ? Exclude<T, undefined> | |
| : T extends Array<infer U> | |
| ? DeepCompleteArray<U> | |
| : T extends Map<infer K, infer V> | |
| ? DeepCompleteMap<K, V> | |
| : DeepCompleteObject<T>; |
| // Within SPA webapp | |
| import { useEffect } from 'react'; | |
| export default function() { | |
| useEffect(() => { | |
| window.addEventListener('keydown', (event) => { | |
| if ((event.ctrlKey || event.metaKey) && event.code === "KeyC") { | |
| document.execCommand("copy"); | |
| } else if ((event.ctrlKey || event.metaKey) && event.code === "KeyX") { | |
| document.execCommand("cut"); |