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 default () => ({ | |
name: "deno_read", | |
setup(build) { | |
build.onLoad( | |
{ filter: /.*\.(t|j)s(x|)/, namespace: "file" }, | |
async ({ path }) => ({ | |
contents: await Deno.readTextFile(path), | |
loader: "tsx", | |
}) | |
); |
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
type EventTargetWithAddListener = EventTarget & { | |
listeners: Map<string, any>; | |
addEventListener( | |
type: string, | |
listeners: Map<string, (event: Event) => any>, | |
options?: boolean | AddEventListenerOptions | |
): void; | |
}; | |
export const handleEventEmitter = ( |
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 ReadableStream = window.ReadableStream && window.ReadableStream.prototype[Symbol.asyncIterator] ? | |
window.ReadableStream : (() => { | |
function ReadableStream (...args) { | |
let readers = [] | |
let obj = args[0] | |
let stream = new window.ReadableStream(...args) | |
// patch cancel to release lock | |
let _cancel = stream.cancel |
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 time | |
from typing import List | |
import numpy as np | |
import pysbd | |
import torch | |
from TTS.config import load_config | |
from TTS.tts.models import setup_model as setup_tts_model |
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 { h } from "preact"; | |
import { createContext, ComponentChildren } from "preact"; | |
import { useContext, useRef } from "preact/hooks"; | |
import { Signal, signal, useSignalEffect } from "@preact/signals"; | |
interface ComboboxProps { | |
children: ComponentChildren; | |
value: Signal<string>; | |
onChange: (value: string | null) => void; | |
nullable?: boolean; |
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 { runHttpQuery } from 'https://deno.land/x/gql@1.1.2/common.ts' | |
import type { GQLRequest, GQLOptions, GraphQLParams } from 'https://deno.land/x/gql@1.1.2/types.ts' | |
import { renderPlaygroundPage } from 'https://deno.land/x/gql@1.1.2/graphiql/render.ts'; | |
/** | |
* Create a new GraphQL HTTP middleware with schema, context etc | |
* @param {GQLOptions} options | |
* | |
* @example | |
* ```ts |
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 default (fn, ms = 1000) => { | |
const connections = new Map(); | |
let id: number | undefined; | |
const poll = async () => { | |
if (connections.size > 0) | |
await fn().then((results) => | |
connections.forEach((conn) => conn(results)) | |
); | |
if (connections.size > 0) id = setTimeout(poll, ms); | |
}; |
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 { runHttpQuery } from 'https://deno.land/x/gql@1.1.2/common.ts' | |
import type { GQLRequest, GQLOptions, GraphQLParams } from 'https://deno.land/x/gql@1.1.2/types.ts' | |
import { renderPlaygroundPage } from 'https://deno.land/x/gql@1.1.2/graphiql/render.ts'; | |
/** | |
* Create a new GraphQL HTTP middleware with schema, context etc | |
* @param {GQLOptions} options | |
* | |
* @example | |
* ```ts |
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 range = (N) => [...Array(N).keys()]; | |
const outer = ([v1, v2]) => v1.map((x) => v2.map((y) => `${x}_${y}`)); | |
const tile = (N, fn) => | |
range(N).map((i, _, arr) => arr.slice(0, i).map(fn).join("+") || 0); | |
const layout = (N) => | |
outer([tile(N, (k) => `w${k * N}`), tile(N, (k) => `h${k}`)]) | |
.flat() | |
.join("|"); |
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 queue = (id, concurrency = 1) => { | |
const d = { running: 0, queue: [] }; | |
const c = (globalThis._RQ ?? {})[id] ?? d; | |
globalThis._RQ = { ...(globalThis._RQ ?? {}), [id]: c }; | |
const inc = (fn) => (c.running++, fn()); | |
return (task) => | |
(c.running < concurrency | |
? Promise.resolve(inc(task)) | |
: new Promise((res) => c.queue.push(() => res(inc(task)))) | |
).finally( |