<template>
<!--
When isLoading is true, the <div> is in the DOM, the <p> is not.
When isLoading is false, Vue will remove the <div> and add the <p> to the DOM,
at which point <MyComponent> will be created and passed the fetched data.
-->
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 putPatch = (obj: any, p: A.PutPatch) => { | |
const { path, value } = p | |
const tail = path.pop() | |
const local = path.reduce((acc, next) => acc[next], obj) | |
local[tail] = value | |
return obj | |
} | |
const splicePatch = (obj: any, p: A.SpliceTextPatch) => { |
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
// OpenAI function call guide: https://platform.openai.com/docs/guides/gpt/function-calling | |
// JSON Schema reference: https://json-schema.org/understanding-json-schema/ | |
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ | |
validate: true, | |
schemas: [ | |
{ | |
uri: "http://myserver/foo-schema.json", | |
fileMatch: ["*"], | |
schema: { |
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 class Cache<T extends object, K> { | |
items = new WeakMap<T, K>() | |
get<P extends T>(item: P, cb: (item: P) => K) { | |
if (!this.items.has(item)) { | |
this.items.set(item, cb(item)) | |
} | |
return this.items.get(item)! | |
} |
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
window.executeFullscreenEmscriptenCode = () => { | |
var Module = typeof Module !== "undefined" ? Module : {}; | |
Module = self["Module"] || {}; | |
Module["noExitRuntime"] = true; | |
Error["stackTraceLimit"] = 100; | |
Module["onAbort"] = function(what) { | |
ABORT = true; | |
EXITSTATUS = 1; | |
var text = "abort(" + (what && !/^\d+$/.test(what + "") ? JSON.stringify(what) : "") + ")"; | |
console.error(text); |
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
// MIT License | |
// | |
// Copyright (c) 2021 Matthijs Steen | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
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 * as React from "react"; | |
import { useMousePosition } from "~/hooks/useMousePosition"; | |
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */ | |
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) { | |
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {}; | |
const [mouseX, mouseY] = useMousePosition(); | |
const positions = { x, y, h, w, mouseX, mouseY }; | |
return ( | |
<div |
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 * as assert from 'assert'; | |
/** | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt | |
*/ | |
export class Base62 { | |
private readonly base: bigint = BigInt(62); | |
private readonly charset: string[] = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); | |
public encode(integer: string): string { |
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 request = window.indexedDB.open("database", 1); | |
// Create schema | |
request.onupgradeneeded = event => { | |
const db = event.target.result; | |
const invoiceStore = db.createObjectStore("invoices", { keyPath: "invoiceId" }); | |
invoiceStore.createIndex("VendorIndex", "vendor"); | |
const itemStore = db.createObjectStore("invoice-items", { keyPath: ["invoiceId", "row"] }); |
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
{ | |
"💍":"diamond | engagement ring | diamond ring | diamond rings | diamonds | engagement rings", | |
"🆎":"blood type AB", | |
"❣":"heart", | |
"🇱🇨":"Saint Lucia | Saint Lucian flag", | |
"🇮🇪":"Ireland | Irish flag", | |
"🇨🇮":"Côte d’Ivoire | Ivory Coast | Ivorian flag", | |
"💎":"diamond | gem | gemstone | jewel | diamonds | gems | gemstones | jewels", | |
"☠️":"skull and crossbones | poison | poisonous", | |
"👩💻":"technology worker | tech worker | technologist | techie | IT worker | Apple genius | woman in technology | woman tech worker | woman technologist | woman IT worker | woman in IT | woman Apple genius", |
NewerOlder