Skip to content

Instantly share code, notes, and snippets.

/**
* Usage
* deno run -A v0.ts https://google.com
*/
import "core-js/proposals/explicit-resource-management.js";
import puppeteer from "puppeteer";
import { tool } from "ai";
import { collectHighlight } from "./inject.ts";
import { z } from "zod";
// optional: show image on terminal
@mizchi
mizchi / webspeed-hackathon-2025-感想.md
Last active March 24, 2025 07:37
WebSpeed Hackathon 2025 参加記録(雑版)
/**
* Usage
* deno run -A v0.ts https://google.com
*/
import "npm:core-js/proposals/explicit-resource-management.js";
import puppeteer from "npm:puppeteer@24.4.0";
import { printImageFromBase64 } from "jsr:@mizchi/imgcat";
function trapCtrlC(fn: () => Promise<void>) {
const handler = async () => {
@mizchi
mizchi / pptr_override_return_value.ts
Created March 7, 2025 09:28
Puppeteerでデバッガーを使ってJavaScriptの関数の戻り値を変更するサンプル
/**
* Puppeteerでデバッガーを使ってJavaScriptの関数の戻り値を変更するサンプル
* Debugger.setReturnValueを使って関数の戻り値を変更する
* 本来なら foo() は "foo" を返すが "foo-modified" に変更されている。
*/
/*
[Debugger.scriptParsed] http://localhost:8778/main.js
[Debugger.paused] {
functionName: "foo",
reason: "other",
#!/usr/bin/env deno run -A
/**
* Lighthouse プラグインを直接実行する実装
* https://github.com/GoogleChrome/lighthouse/blob/main/docs/plugins.md#custom-audits
*/
import lighthouse from "npm:lighthouse";
import { killAll, launch } from "npm:chrome-launcher";
import chromeFinder from "npm:chrome-finder";
@mizchi
mizchi / vite.config.js
Last active February 25, 2025 18:09
vite config with corp/coep header
import fs from "fs";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
{
name: "isolation",
configureServer(server) {
server.middlewares.use((_req, res, next) => {
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
/*
# Usage
$ git add foo.ts
$ git commit -m "add foo.ts"
# push and wait ci
$ deno run -A git-push-with-ci.ts
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
/* @script */
// LSP メッセージの型定義
type JsonRpcMessage = {
jsonrpc: "2.0";
id?: number;
method?: string;
params?: unknown;
result?: unknown;
error?: {
/**
* $ deno run tools/read.ts https://example.com
* $ deno run tools/read.ts https://example.com --summary
*/
import { JSDOM } from "npm:jsdom@26.0.0";
import { Readability } from "npm:@mozilla/readability";
import html2md from "npm:html-to-md";
import { parseArgs } from "node:util";
import { anthropic } from "@ai-sdk/anthropic";
import { streamText } from "npm:ai";