Skip to content

Instantly share code, notes, and snippets.

/**
* mizchi/pbt - A simple property-based testing library by generator style
* Inspired by fast-check
* Example
* ```ts
* import { generate, integer, string } from "@mizchi/pbt";
*
* const g = generate(integer({ min: 1, max: 10 }));
* for (const n of g(10000)) {
* if (n < 1 || n > 10) {

Playwright Test を GitHub Actions で Sharding する

https://playwright.dev/docs/test-sharding

ローカルで試す。

npx playwright test --shard=1/2 のようにすると、テスト上から(おそらくFS依存のls列挙順で) shard 数で割って分配してくれる。

$ npx playwright test --shard=1/2
import puppeteer, {
ActiveSession,
Browser,
BrowserWorker,
Page,
} from "@cloudflare/puppeteer";
import { DurableObject } from "cloudflare:workers";
export class BrowserObject extends DurableObject<Env> {
env: Env;
javascript:(function() {
let url = window.location.href;
let match = url.match(/arxiv\.org\/abs\/(\d+\.\d+)/);
if (match && match[1]) {
let paperId = match[1];
let ar5ivUrl = `https://ar5iv.labs.arxiv.org/html/${paperId}`;
window.location.href = ar5ivUrl;
} else {
alert("This doesn't appear to be an arXiv paper page. Please use this bookmarklet on an arXiv paper page (e.g., https://arxiv.org/abs/2402.09171)");
}
///| Raw JavaScript Fetch API wrapper
extern "js" fn js_fetch(url : String, init : @js.Value) -> @js.Promise =
#| (url, init) => {
#| console.log("fetching", url, init);
#| return fetch(url, init)
#| }
///| JavaScript Fetch API wrapper
/// Usage:
/// ```

Investigating bugs related to prisma + opennext + auth-js

This is an investigation log written with the assumption that it will be translated in order to report it as an issue on GitHub.

Basically, I am responsible for trying to use prisma's experimental query-compiler, but the interfaces of opennext, prisma, and @auth/adapter-prisma all did not mesh, and the only solution to avoid the problem was to directly patch @auth/adapter-prisma.

What happened with @auth/adapter-prisma is a typical example, and there are two issues: how prisma itself will design its interface in the future, and how opennext should handle cjs.

Code where the problem occurred

// src/app/dash/AuthButtons.tsx
"use client";
import { signIn, signOut } from "next-auth/react";
export function SignInButton() {
return (
<div>
<button
type="button"
@mizchi
mizchi / plan-text-win.md
Created May 2, 2025 07:59
プレーンテキストは常に勝つ

草稿。あとで書く

Markdown の表現力は十分である

Markdown は(リッチテキストに比べると)表現が貧弱だとよく言われれる。自分もそこは同意する。 しかし、それがデメリットではない。Markdown の貧弱さは、意思伝達上の明確なメリットであると考える。Markdown の枠組みの中でテキストを組み立てることが、書き手・読み手に低負荷なまま意思伝達を可能にする。

制約は力である

markdown は元々はメール文面の慣習的なテキスト装飾が元になって発展した記法だ。プレーンテキストでも読める、という点に最も大きな価値があり、プログラミングエディタによる装飾や、GitHub上で閲覧するときの HTML 変換は補助ツールでしかない。

import {
startTransition,
Suspense,
use,
useActionState,
useEffect,
} from "react";
import { render, screen, fireEvent, act } from "@testing-library/react";
import { describe, it, expect } from "vitest";
import Counter from "./Counter";
/* wrangler dev main.ts --remote */
import { parse } from "cache-control-parser";
async function handleSwrTime(
request: Request,
env: Env,
ctx: ExecutionContext
) {
// mock response
const createNewResponse = () => {