Skip to content

Instantly share code, notes, and snippets.

View kt3k's full-sized avatar

Yoshiya Hinosawa kt3k

View GitHub Profile
let counter = 0;
const registry = new FinalizationRegistry(() => {
console.log(`Array gets garbage collected at ${counter}`);
});
(function allocateMemory() {
// Allocate 50000 functions — a lot of memory!
registry.register(Array.from({ length: 50000 }, () => () => {}));
if (counter > 1000) {
console.log("Main job ends");
abortable
abortableAsyncIterable
abortablePromise
accepts
acceptsEncodings
acceptsLanguages
afterAll
afterEach
aggregateGroups
ascend
@kt3k
kt3k / test.md
Last active August 23, 2023 11:47

$1

$1$

$$1$$

  graph TD;
      A-->B;
 A-->C;
ACL [RFC3744, Section 8.1]
BASELINE-CONTROL [RFC3253, Section 12.6]
BIND [RFC5842, Section 4]
CHECKIN [RFC3253, Section 4.4, Section 9.4]
CHECKOUT [RFC3253, Section 4.3, Section 8.8]
CONNECT [RFC9110, Section 9.3.6]
COPY [RFC4918, Section 9.8]
DELETE [RFC9110, Section 9.3.5]
GET [RFC9110, Section 9.3.1]
HEAD [RFC9110, Section 9.3.2]
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
import {
iterateReader,
readableStreamFromIterable,
} from "https://deno.land/[email protected]/streams/mod.ts";
import { createHash } from "https://deno.land/[email protected]/hash/mod.ts";
const path = "data.txt";
function toHex(digest: ArrayBuffer) {
return [...new Uint8Array(digest)].map(x => x.toString(16).padStart(2, '0')).join('')
@kt3k
kt3k / main.ts
Created September 5, 2022 12:55
import { serve } from "https://raw.githubusercontent.com/denoland/deno_std/main/http/server.ts";
import "https://raw.githubusercontent.com/denoland/deno_std/main/node/module_all.ts";
serve(() => new Reseponse("ok"));
/** @jsx h */
import { bind, h } from "https://deno.land/x/[email protected]/paul.ts";
bind("my-component", ({ on, morph }) => {
let count = 0;
on("click", "button", () => {
count++;
render();
});
/** @jsx h */
import { bind, cl, h } from "https://deno.land/x/[email protected]/paul.ts";
import { Todo, TodoCollection } from "./todo-models";
type Filter = "all" | "completed" | "uncompleted";
type Query = <T = HTMLElement>(q: string) => T | null;
const hashToFilter = {
"#/all": "all",
"#/active": "uncompleted",
"#/completed": "completed",
@kt3k
kt3k / rds.ts
Last active June 27, 2022 05:15
import { ApiFactory } from "https://deno.land/x/[email protected]/client/mod.ts";
import { RDSDataService } from "https://aws-api.deno.dev/v0.3/services/rdsdataservice.ts";
const rds = new ApiFactory({ region: "us-west-2" }).makeNew(RDSDataService);
const resp = await rds.executeStatement({
resourceArn: "arn:aws:rds:<region>:<account number>:<resourcetype>:<name>",
secretArn: "arn:aws:secretsmanager:<region>:<account number>:secret:<name>",
sql: "SELECT * FROM users LIMIT 10",
});
console.log(resp.records);