///|
extern "js" fn ffi_request_animation_frame(f : () -> Unit) -> Unit =
#|(f) => {
#| if (globalThis.requestAnimationFrame) {
#| requestAnimationFrame(f)
#| } else {
#| setTimeout(f, 0) // fallback
#| }
#|}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// original https://github.com/moonbit-community/jmop/blob/main/promise.mbt | |
| ///| | |
| extern "js" fn ffi_promise_resolve(x : Value) -> Value = "(x) => Promise.resolve(x)" | |
| ///| | |
| extern "js" fn ffi_promise_reject(e : Error) -> Value = "(x) => Promise.reject(x)" | |
| ///| | |
| extern "js" fn ffi_promise_then( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```mbt | |
| async fn[T, U] map_async(arr: Array[T], f: async (T) -> U raise?) -> Array[U] raise? { | |
| let res: Array[U] = [] | |
| for item in arr { | |
| res.push(f(item)) | |
| } | |
| res | |
| } | |
| async test { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///| | |
| fnalias @svg.node as svg_node | |
| ///| | |
| fn[M] common_svg_node( | |
| tag_name : String, | |
| new_attrs : Array[@svg.Attribute[M]], | |
| style~ : Array[String]?, | |
| class~ : String?, | |
| id~ : String?, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const OPENAI_API_KEY_PATH = "%_%=k"; | |
| const TEMP_PKCE_VERIFIER = "%_%=pk"; | |
| function base64UrlEncode(array: Uint8Array): string { | |
| const base64 = btoa(String.fromCharCode(...array)); | |
| return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); | |
| } | |
| type LoginState = | |
| | { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Discord Auth for Cloudflare Access | |
| based on https://github.com/Erisa/discord-oidc-worker | |
| # Create discord application | |
| - Get client id and secret | |
| - Set redirect URL to `https://<cloudflare-name>.cloudflareaccess.com/cdn-cgi/access/callback` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///| | |
| test "String to Bytes conversion" { | |
| fn find_index(url : Bytes) -> Int? { | |
| url.find("://") | |
| } | |
| let url = "https://www.example.ocom" | |
| let url_bytes : Bytes = "https://example.com" | |
| inspect(url.find("://"), content="Some(5)") | |
| inspect(find_index("https://example.com"), content="Some(5)") |
andromeda のコードを読んで、Claude Code にあってる?って確認させたもの
https://github.com/tryandromeda/andromeda
Parser に oxc, Runtime に Nova をベースにした、JS処理系。
位置づけとしては Node/Deno/Bun のようなもの。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * mbts - Moonbit JS Backend Project generator | |
| * Install on deno and usages | |
| * deno install -Afg mbts.ts | |
| * | |
| * # generate boilerplate | |
| * $ mbts new mylib | |
| * $ mbts new mylib --name mizchi/newpkg | |
| * $ mbts new mylib --lib | |
| * $ mbts new mylib --deno |
gpt-oss:20b に「SF小説を書いて」という曖昧な指示を出したもの。 論理的試行やSFとして面白いかどうかはあまり判断していない。文体や技巧を評価している。
- 生成
- 読者としてレビューして、それを反映
- 星雲賞の評価員として受賞に足るかをレビューして、それを反映
という過程を踏んだ
NewerOlder