Skip to content

Instantly share code, notes, and snippets.

@mizchi
mizchi / agent.test.ts
Created March 19, 2024 07:57
軽量 Langchain 的な何か
import { defineAgent, ok, err, runAgent, stepAgent, chain, initAgent } from "./agent.ts";
import { Agent, AgentError, AgentErrorCode } from "./types.ts";
import { expect } from "https://deno.land/std@0.214.0/expect/mod.ts";
Deno.test("stepAgent: simple", async () => {
const simple = defineAgent((_init) => {
return {
async invoke(input, _options) {
return `Hello, ${input}`;
},
// prompt can not catch ctrl-c
const ret = prompt('input>');
console.log(ret); // SIGINT interrupt before this line
// returns null with ctrl-c if signal handler is registerred.
function getInput(message: string): string | null {
const handler = () => {};
Deno.addSignalListener('SIGINT', handler);
const ret = prompt(message);
Deno.removeSignalListener('SIGINT', handler);
@mizchi
mizchi / unitest.mjs
Created February 2, 2024 18:02
universal-test helper
/*
Universal testing library for Deno, Node.js, Vitest and the browser.
// foo.test.{js,mjs,ts}
import { test, eq } from './unitest.mjs';
test('1 === 1', () => {
eq(1, 1);
});
$ deno test foo.test.ts

タロンで3/4/5で勝利した試合の反省。

https://www.op.gg/summoners/jp/mizchi2-JP1

正直対面には負けた試合だったがマクロの判断でいくつか勝って、学びが多い回だった。

うろ覚えで書いているので、動画見ながら読むといくつか齟齬があるかも。


theme marp
gaia
true

Qwik それはフロントエンドの見た夢 Long Version

@mizchi | PWA Night


@mizchi
mizchi / deno-react-testing.tsx
Created January 11, 2024 12:29
deno で react testing library を使う
// deno test --no-check --allow-env counter.tsx
import { useCallback, useState } from "react";
// increment counter by click
export default function Counter() {
const [count, setCount] = useState(0);
const onClick = useCallback(() => setCount(count + 1), [count]);
return <div>
<span data-testid="count">{count}</span>
<button type="button" onClick={onClick} data-testid="increment-button">+</button>
@mizchi
mizchi / lol.md
Last active January 10, 2024 08:53
年末年始で LoL 始めてみた感想

年末年始遊びまくってLv15 から Lv49 になった。その記録。

自分が the k4sen を意識してたわけでは無いが、やってた間に the k4sen が盛り上がって新規流入がめちゃくちゃに増えたらしい。 めちゃくちゃわかりやすいチュートリアルが提供されてるので、はじめどきではある。

https://www.twitch.tv/videos/2015988986?filter=archives&sort=time

自分の遊び方

レーンでファイトしながら CS 狙うのが神経削れてきついと感じたので、 CS とる必要がないジャングルとサポートから始めることにした。ミクロをやりながらマクロを掴んでいきたい、という方向性。

やりたいこと(超訳)

  • d1 を prisma で動かしたい
  • prisma-query-wasm がどれだけ小さくなるか検証
    • query builder 部分だけ取り出せないか
  • PR 出せたらいいね

動機

  • (mizchi の考える)次世代の銀の弾丸
#!/usr/bin/env -S deno run --allow-net --allow-read --allow-env --unstable --ext=ts
// USAGE: $ deno run cfai-text.ts "Hello Cloudflare AI!"
type RequestType = {
messages: {
role: string;
content: string;
}[];
};