Skip to content

Instantly share code, notes, and snippets.

@mizchi
mizchi / askrepo.ts
Last active November 13, 2024 13:15
//https://gist.github.com/mizchi/24ac021b8d59755599860c785526f955
import { google } from "npm:@ai-sdk/[email protected]";
import { streamText } from "npm:[email protected]";
import { parseArgs } from "node:util";
import path from "node:path";
import { $ } from "jsr:@david/[email protected]";
async function getFilesContent(basePath: string) {
const filesContent: {
[key: string]: string;
/* # Lighthouse performance testing with n times by deno
$ deno run -A src/lhs.ts https://www.npmjs.com/package/puppeteer --times 3
{
avg: 0.45999999999999996,
times: 3,
scores: {
"first-contentful-paint": 0.03,
"first-meaningful-paint": 0.12,
/**
[[durable_objects.bindings]]
name = "MyDurableObject"
class_name = "MyDurableObject"
[[migrations]]
tag = "v1" # Should be unique for each entry
new_sqlite_classes = ["MyDurableObject"] # Array of new classes
*/
import { DurableObject } from "cloudflare:workers";
/*
事前に unicode-range が判明しているフォントから、unicode-range を抜き出して専用の woff2 を作成するテスト
ブラウザでこれを実行
[...new Set(Array.from(document.body.textContent).map(t => t.codePointAt(0)))].sort()
$ ls
╭───┬─────────────────────────┬──────┬──────────┬────────────────╮
# name type size modified
@mizchi
mizchi / getPrismaClient.ts
Created October 10, 2024 05:53
Get prisma in cf workers
import { PrismaClient } from "@prisma/client";
import { PrismaPg as PrismaPgWorker } from "@prisma/adapter-pg-worker";
import { Pool } from "@prisma/pg-worker";
let _db: PrismaClient | null = null;
export async function getPrismaClient(env: Env): Promise<PrismaClient> {
if (_db) return _db;
if (import.meta.env.DEV) {
const { default: pg } = await import("pg");

playwright を読んだメモ

package.json

    "ctest": "playwright test --config=tests/library/playwright.config.ts --project=chromium-*",
    "ftest": "playwright test --config=tests/library/playwright.config.ts --project=firefox-*",
    "wtest": "playwright test --config=tests/library/playwright.config.ts --project=webkit-*",
    "atest": "playwright test --config=tests/android/playwright.config.ts",
    "etest": "playwright test --config=tests/electron/playwright.config.ts",
@mizchi
mizchi / ai-sdk-claude-tool-deno.ts
Created September 21, 2024 12:29
Vercel's ai sdk (claude-stream+tools) does not work with deno. Not compat?
// It does not work.
/*
$ deno run -A vai-claude-tools.ts
Certainly! I can help you get the current weather information for San Francisco. To do this, I'll use the weather function to retrieve the data. Let me make the call for you.error: Uncaught (in promise) AI_TypeValidationError: Type validation failed: Value: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01S1YL68SUTQiQhfMrF8ENNr","name":"weather","input":{}}}.
Error message: [
{
"received": "tool_use",
"code": "invalid_literal",
"expected": "text",
@mizchi
mizchi / koka-dialog-claude-3-5-sonnet.md
Created September 21, 2024 09:23
koka について claude に質問した内容

前提

  • 動かしてない
  • 概念の雰囲気を理解したい

koka言語について説明して

@mizchi
mizchi / remix-code-reading-memo.md
Last active September 16, 2024 11:26
Remix 本体のコードを読んだメモ

Code Reading のメモ

7dece0e 時点

目標

  • vite dev 起動時のシーケンスを確認
  • react-router になるとはどういうことか

setup

@mizchi
mizchi / vitest.workspace.ts
Created September 4, 2024 08:21
Run unit tests and browser-tests in one config
import { defineWorkspace } from "vitest/config";
export default defineWorkspace([
{
extends: "vite.config.ts",
test: {
name: "unit",
environment: "node",
include: ["src/**/*.test.ts"],
},