この資料は以下のイベントの登壇用の殴り書きです
https://hack-at-delta.connpass.com/event/350588/
今までの資料を引用して話すので、この資料はアウトラインです。
/** | |
~/sandbox/cfhandson via 🦕 v2.2.8 | |
$ deno run -A x.ts | |
v1.2.2 | |
[ { "$a": "duck", "$b": 42, "$c": [ 10, 11, 12 ] } | |
**/ | |
import duckdb, { INTEGER, LIST, listValue, VARCHAR } from "@duckdb/node-api"; | |
import { DuckDBInstance } from "@duckdb/node-api"; |
この資料は以下のイベントの登壇用の殴り書きです
https://hack-at-delta.connpass.com/event/350588/
今までの資料を引用して話すので、この資料はアウトラインです。
// vite.config.ts | |
// src/sw.ts => /sw.js build on dev | |
// add to index.html: <script vite-ignore type="module">navigator.serviceWorker.register("/sw.js")</script> | |
import { defineConfig, Plugin } from "vite"; | |
import path from "node:path"; | |
import { fileURLToPath } from "node:url"; | |
const dirname = path.dirname(fileURLToPath(import.meta.url)); | |
function sw({ |
addEventListener("install", (event) => { | |
event.waitUntil(skipWaiting()); | |
console.log("Service worker install"); | |
}); | |
addEventListener("activate", (event) => { | |
event.waitUntil(self.clients.claim()); | |
console.log("Service worker activate"); | |
}); |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE DeriveGeneric #-} -- FromJSON と Show の自動導出に必要 | |
module Main (main) where | |
import qualified Network.HTTP.Req as Req | |
import qualified Data.Aeson as Aeson | |
import Control.Monad.IO.Class (liftIO) | |
import GHC.Generics (Generic) -- DeriveGeneric に必要 |
/** | |
* Usage | |
* $ deno run imagen.ts --prompt "Santa Claus driving a Cadillac" | |
* $ deno run imagen.ts --file prompt.txt | |
* $ deno run imagen.ts --file prompt.txt --out out.png | |
*/ | |
import { experimental_generateImage as generateImage, generateText } from "ai"; | |
import { openai } from "@ai-sdk/openai"; | |
import { printImageFromBase64 } from "@mizchi/imgcat"; | |
import { parseArgs } from "node:util"; |
// https://orm.drizzle.team/docs/guides/vector-similarity-search | |
import { PGlite } from "npm:@electric-sql/pglite"; | |
import { vector as pgVector } from "@electric-sql/pglite/vector"; | |
import { index, integer, pgTable, vector, text } from "drizzle-orm/pg-core"; | |
import { drizzle, type PgliteDatabase } from "drizzle-orm/pglite"; | |
import { openai } from "@ai-sdk/openai"; | |
import { embed } from "ai"; | |
import { cosineDistance, sql, desc, gt } from "drizzle-orm"; | |
// openai embedding |
/** | |
* $ npx tsx asset-cov.ts https://www.cnn.co.jp/fringe/35230901.html https://www.cnn.co.jp --filter '.css' | |
--- Final Coverage Report --- | |
--- CSS Files --- | |
File: https://www.cnn.co.jp/static/css/atlanta/responsive.css | |
Total size: 13000 bytes | |
Estimated used size (across pages): 3943 bytes |
const iterations = 1000000; // 試行回数 | |
const urlString = "https://example.com/path/to/resource?query=param#fragment"; | |
const domainToCheck = "https://example.com"; | |
console.log(`Benchmarking with ${iterations} iterations...\n`); | |
// --- new URL() benchmark --- | |
console.log(`1. Parsing URL with new URL("${urlString}")`); | |
const startNewUrl = performance.now(); | |
for (let i = 0; i < iterations; i++) { |
import { drizzle } from "npm:@mizchi/drizzle-orm/dist/node-sqlite/index.js"; | |
import { | |
integer, | |
sqliteTable, | |
text, | |
} from "npm:@mizchi/drizzle-orm/dist/sqlite-core/index.js"; | |
import { eq } from "npm:@mizchi/drizzle-orm/dist/index.js"; | |
// Define the schema | |
const users = sqliteTable("users", { |