Avatar

maxm

🕳️
Joined January 12, 2023
Public vals
104
maxm avatar
maxm
exaltedAmberKiwi
HTTP
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
hnhiringStats
Script
Scrapes hnhiring.com for the total count of job postings in every Who's Hiring post on Hacker News: 194 jobs, january 2025 337 jobs, december 2024 325 jobs, november 2024 342 jobs, october 2024 311 jobs, september 2024 328 jobs, august 2024 384 jobs, july 2024 351 jobs, june 2024 418 jobs, may 2024 306 jobs, april 2024 313 jobs, march 2024 356 jobs, february 2024 294 jobs, january 2024 337 jobs, december 2023 388 jobs, november 2023 353 jobs, october 2023 318 jobs, september 2023 367 jobs, august 2023 342 jobs, july 2023 358 jobs, june 2023 423 jobs, may 2023 380 jobs, april 2023 434 jobs, march 2023 465 jobs, february 2023 386 jobs, january 2023 505 jobs, december 2022 544 jobs, november 2022 481 jobs, october 2022 529 jobs, september 2022 664 jobs, august 2022 556 jobs, july 2022 753 jobs, june 2022 792 jobs, may 2022 771 jobs, april 2022 829 jobs, march 2022 841 jobs, february 2022 686 jobs, january 2022 788 jobs, december 2021 993 jobs, november 2021 816 jobs, october 2021 958 jobs, september 2021 882 jobs, august 2021 921 jobs, july 2021 1022 jobs, june 2021 888 jobs, may 2021 918 jobs, april 2021 945 jobs, march 2021 979 jobs, february 2021
0
maxm avatar
maxm
visibleYellowPike
Script
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
discordSignatureVerifyExample
HTTP
// Your public key can be found on your application in the Developer Portal
1
maxm avatar
maxm
wideLib
Script
// const rows = parseRows([
0
maxm avatar
maxm
wide
HTTP
WIDE Store any unstructured JSON data. Retrieve it with an expressive and efficient query system. WIDE is a library and service hosted on Val Town. Authenticate and use it with your Val Town credentials, or fork it and connect it to your own Clickhouse Instance. import { ValSession } from 'https://esm.town/v/maxm/valSession'; import { Wide } from 'https://esm.town/v/maxm/wide'; // Use your Val Town API Token to create a session const wide = new Wide(await ValSession.new(Deno.env.get("valtown"))) // Write any data. await wide.write([ { user: {id: 1, name: 'Alice', email: 'alice@example.com' }}, { user: {id: 2, name: 'Bob', email: 'bob@example.com' }}, { user: {id: 3, name: 'Charlie', email: 'charlie@example.com' }}, ]); await wide.fields("user.") // => [ // { fieldName: "user.email", fieldType: "string", count: 3 }, // { fieldName: "user.id", fieldType: "number", count: 3 }, // { fieldName: "user.name", fieldType: "string", count: 3 } // ] await wide.values("user.email") // [ // { value: "bob@example.com", count: 1 }, // { value: "charlie@example.com", count: 1 }, // { value: "alice@example.com", count: 1 } // ] await wide.search({ start: new Date(Date.now() - 1000 * 60 * 10), end: new Date(), filters: [{ fieldName: "user.name", operator: "equals", value: "Alice" }], }) // [{ user: { name: "Alice", email: "alice@example.com", id: 1 } }];
4
maxm avatar
maxm
valSession
HTTP
Val Session import { ValSession } from "https://esm.town/v/maxm/valSession"; // Generate a token from your valtown api key. const token = await ValSession.newSession(Deno.env.get("valtown")); // Other services can use it to authenticate const user = await ValSession.validate(token); Fork it, provide your own VT_SESSION_PRIVATE_KEY, and update the hardcoded public key. You can generate your own keys like so: import { crypto } from "https://deno.land/std@0.198.0/crypto/mod.ts"; // Generate a key pair for JWT signing and verification const { privateKey, publicKey } = await crypto.subtle.generateKey( { name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256", }, true, ["sign", "verify"], ); function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string { const lines = b64.match(/.{1,64}/g) || []; return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`; } const privateKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPrivateKey))), "PRIVATE KEY", ); const publicKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPublicKey))), "PUBLIC KEY", ); console.log(privateKeyPem, publicKeyPem);
3
maxm avatar
maxm
wideApi
HTTP
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
simpleWikipediaInstantSearch
HTTP
Simple Wikipedia Instant Search A quick demo of getting fuzzy matching and instant search working on Val Town
2
maxm avatar
maxm
evaltownWorker
Script
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
reqEvaltown
HTTP
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
ingeniousSapphireWildebeest
Script
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
pretendingToBeRun
HTTP
An interactive, runnable TypeScript val by maxm
0
maxm avatar
maxm
transformEvalCode
Script
See: https://www.val.town/v/maxm/eval
0
maxm avatar
maxm
eval
Script
Eval web demo Security Caveats This code runs in a Worker with { permissions: { write: false, read: false, net: false } } . This is likely very safe, but if you enable network access keep in mind that users might generate junk network traffic or attempt to make infinite loops. If sandboxed code knows the name of one of your private vals it will be able to import the code with import "https://esm.town/v/maxm/private" . If you enabled write: true in the Worker, the unix socket that Deno uses to communicate with the host can be deleted and intercepted. This might mean that evaluated code can steal the socket and read the next request. You should not use this to evaluate code that should not be read by a previous evaluation. All code is running on the same process and you are not protected from exotic attacks like speculative execution. Overview You can use this library to evaluate code: import { evalCode } from "https://esm.town/maxm/eval" console.log(await evalCode("export const foo = 1")) // => 1 You can use this library with https://www.val.town/v/maxm/transformEvalCode to return the last value without needing to export it. This is how the /eval api endpoint used to work and makes the library preform similarly to a repl. import { evalCode } from "https://esm.town/maxm/eval" import { transform } from "https://esm.town/maxm/transformEvalCode" console.log(await evalCode(transform("1+1"))) // => 2 Here's an example UI application that demonstrates how you can string this all together: https://maxm-evalui.web.val.run/ (source: https://www.val.town/v/maxm/evalUI) Security Model Code is evaluated using a dynamic import within a Worker. await import(`data:text/tsx,${encodeURIComponent(e.data)}`); Running the code withing a Worker prevents access to GlobalThis and window from leaking between evals. Similarly, access to Deno.env is prevented and evaluations will see errors when trying to access any environment variables. TODO: what else?
4
maxm avatar
maxm
evalUI
HTTP
An interactive, runnable TypeScript val by maxm
2