dailyDadJokemain.tsx1 match
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6return email({
prism_feature_notificationsmain.tsx3 matches
5const confidenceThreshold = 0.8;
67function randomlyPickFeature(featuresAboveConfidenceThreshold) {
8return featuresAboveConfidenceThreshold[Math.floor(Math.random() * featuresAboveConfidenceThreshold.length)];
9}
1011function getFeatureLink(feature) {
12const { index } = feature;
13return `https://thesephist--prism-start-app.modal.run/f/${modelName}/${index}?layout=2`;
14}
1516export default async function(interval: Interval) {
17const response = await fetch(dictionaryUrl);
18const { features } = await response.json();
jwkToDidKey_testsmain.tsx1 match
218if (jwk.y) console.assert(jwk.y === resolvedJwk.y);
219220async function resolveDid(did: string) {
221const data = await ky.get(`https://dev.uniresolver.io/1.0/identifiers/${did}`).json();
222return data.verificationMethod.at(0).publicKeyJwk;
jwkToDidKeymain.tsx2 matches
17};
1819export function jwkToMultibase(jwk: JWK) {
20if (jwk.kty === "OKP") {
21const bytes = base64url.baseDecode(jwk.x);
32}
3334export function jwkToDidKey(jwk: JWK) {
35const keyMultibase = jwkToMultibase(jwk);
36return `did:key:${keyMultibase}`;
5import { secp256k1 } from "npm:@noble/curves/secp256k1";
67export function decompressPoint(bytes: Uint8Array, curve: string) {
8if (curve === "P-256") {
9const point = p256.ProjectivePoint.fromHex(bytes);
17}
1819function pointToBytes<T>(point: ProjPointType<T>, Fp: IField<T>) {
20const x = Fp.toBytes(point.x);
21const y = Fp.toBytes(point.y);
2425// @see: https://stackoverflow.com/questions/17171542/algorithm-for-elliptic-curve-point-compression
26export function compressPoint({ x, y }: { x: Uint8Array; y: Uint8Array }) {
27const compressed = new Uint8Array(x.length + 1);
28compressed[0] = 2 + (y.at(-1) & 1);
counterscaleWeeklyReportmain.tsx2 matches
56// borrowed from: https://github.com/benvinegar/counterscale/blob/main/app/analytics/query.ts#L24
7function accumulateCountsFromRowResult(
8counts,
9row: {
22}
2324export default async function(interval: Interval) {
25// you need to declare these two environment variables:
26
roseDragonmain.tsx1 match
1import { fetch } from "https://esm.town/v/std/fetch";
23export async function uploadTo0x0(data, name) {
4const blob = new Blob([data]);
5const formData = new FormData();
11};
1213export async function prompt(
14text,
15{ mode = "text", model = "opus", max_tokens = 1024, messages = [] } = {},
viewSourcemain.tsx1 match
3import { escape } from "npm:html-sloppy-escaper";
45export default async function viewSource(req: Request) {
6const pathname = new URL(req.url).pathname;
7const html = await fetchText(
218];
219220async function migrate() {
221await std_sqlite.execute(`
222create table if not exists tracing_schema (
369}
370371export async function init(
372url: string | URL,
373): Promise<void> {
394}
395396export function tracer(): Tracer {
397return otelTrace.getTracer("val.town");
398}
399400export function attribute(name: string, value: string): void {
401otelTrace.getActiveSpan()?.setAttribute(name, value);
402}
403404export function event(name: string, attrs: Record<string, string>): void {
405otelTrace.getActiveSpan()?.addEvent(name, attrs);
406}
407408export function trace<
409// deno-lint-ignore no-explicit-any
410F extends (...args: any[]) => any,
428}
429430export async function traceAsync<
431// deno-lint-ignore no-explicit-any
432F extends (...args: any[]) => any,
454}
455456export function traced<
457// deno-lint-ignore no-explicit-any
458F extends (...args: any[]) => any,
459>(name: string, f: F) {
460return async function (
461...args: Parameters<F>
462): Promise<Awaited<ReturnType<F>>> {
470* be tied together.
471*/
472export async function fetch(
473input: string | URL,
474init?: RequestInit,
511}
512513async function tracedExecute(statement: InStatement): Promise<ResultSet> {
514return await tracer().startActiveSpan(
515`sqlite:execute`,
544}
545546async function tracedBatch(
547statements: InStatement[],
548mode?: TransactionMode,
603* Takes an http handler and returns a new handler that
604* traces the request.
605* @returns {Function} A new handler that traces the request.
606*/
607export function tracedHandler(
608handler: (req: Request) => Promise<Response>,
609): (req: Request) => Promise<Response> {
610async function _tracedHandler(req: Request): Promise<Response> {
611let active_context = null;
612const prop_header = req.headers.get("b3");
930931const render_spans: SelectSpan[] = [];
932function push_span(span_id: string) {
933const span = spans_by_id.get(span_id)!;
934render_spans.push(span);
10691070const render_spans: SelectSpan[] = [];
1071function push_span(span_id: string) {
1072const span = spans_by_id.get(span_id)!;
1073render_spans.push(span);
1246});
12471248export async function traceViewer(req: Request): Promise<Response> {
1249await migrate();
1250return await app.fetch(req);