Skip to content

Instantly share code, notes, and snippets.

@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"],
},
@mizchi
mizchi / あなたのパフォーマンスを倍にする Frontend Ops はいかがですか.md
Last active October 11, 2024 12:41
あなたのパフォーマンスを倍にする Frontend Ops の傭兵はいかがですか

あなたのプロジェクトに Frontend Ops を。

2024/09/12: 好評につき、直近のタスクが埋まっています。現時点で受け付けしたものは、最低でも10月後半以降の開始となります。

[経営者の方へ] ウェブサイトが遅くなっていませんか?機能追加が遅くなっていませんか?

私 @mizchi は Node.js とフロントエンドのエキスパートです。もし私を知らなければ、御社のフロントエンド担当に mizchi とは誰か聞いてみてください。それが一番早いと思います。

Frontend Ops の専門家として御社のプロダクトの改善にご協力します。

import { type PlatformProxy } from "wrangler";
import { type AppLoadContext } from "@remix-run/cloudflare";
// pg
/// https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-cloudflare#postgresql-traditional
import { PrismaClient } from "@prisma/client";
import { PrismaPg as PrismaPgWorker } from "@prisma/adapter-pg-worker";
import { Pool } from "@prisma/pg-worker";
type Cloudflare = Omit<PlatformProxy<Env>, "dispose">;
/*
USAGE: deno run -A git-aware-cp.ts [srcs...] dest
EXAMPLE: deno run -A git-aware-cp.ts *.ts lib.ts examples /tmp/out
backupper (main)🔥 🦕
$ tree ./examples
./examples
├── ignored-dir
@mizchi
mizchi / wasm-cloud-platform.md
Created August 14, 2024 16:26
Trying out spin and wasmCloud as wasm platforms

It is English version of https://zenn.dev/mizchi/articles/wasm-platform (Japanese)

With wasi-http, wasm can now set up a web server standalone without relying on the host language.

Among recent developments, spin and wasmcloud are wasm hosting services. We'll try out these two while comparing them.


spin