Search

Results include substring matches and semantically similar vals. Learn more
petermillspaugh avatar
january2024
@petermillspaugh
petemillspaugh.com clippings: #1 – January 2024 Process for sending out a newsletter: Publish newsletter on the Web Fork this val and update subject, webUrl, targetSendDate Uncomment call to insertIntoNewslettersTable Add to @petermillspaugh/newsletters list Val
Script
/** @jsxImportSource https://esm.sh/preact */
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
export function getJanuary2024Newsletter() {
<a href="https://petemillspaugh.com/silly-tlds">
<strong>Silly TLDs</strong>
</a>. This is a short, fun one. It’s the thing I’ve written that friends outside of tech seem most interested
in / leads to the most fun conversations
</li>
Prada avatar
supabaseSDKSelectMyFirstTable
@Prada
Selecting from a Supabase table using the SDK. Part of the Supabase guide on docs.val.town .
Script
import process from "node:process";
export const supabaseSDKSelectMyFirstTable = (async () => {
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
const supabase = createClient(
process.env.supabaseURL,
process.env.supabaseKey,
eidam avatar
ratelimit_example
@eidam
// initialise rlimit.com client with your namespace ID and default settings
Script
import { RateLimit } from "https://esm.town/v/rlimit/http";
// initialise rlimit.com client with your namespace ID and default settings
const ratelimit = new RateLimit({ maximum: 5, interval: "20s" });
// increase count & check result for given identifier
petermillspaugh avatar
sendTestEmailNewsletter
@petermillspaugh
Val Town email subscriptions: send test email Cousin Val to @petermillspaugh/emailSubscription — see docs there. When you're writing up an email to send to subscribers, it's helpful to send it to yourself ahead of time to proofread and see how it looks in different email clients etc.
Cron
Cousin Val to [@petermillspaugh/emailSubscription](https://www.val.town/v/petermillspaugh/emailSubscription) — see docs there
yourself ahead of time to proofread and see how it looks in different email clients etc.
/** @jsxImportSource https://esm.sh/preact */
import { generateNewsletterJsx } from "https://esm.town/v/petermillspaugh/generateNewsletterJsx";
import { email as sendEmail } from "https://esm.town/v/std/email?v=11";
import { render } from "npm:preact-render-to-string";
export function sendTestEmailNewsletter(interval: Interval) {
robsimmons avatar
aoc_2023_10_1
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
7-F7-
saolsen avatar
redis
@saolsen
Upstash redis client for vals. Creates a global redis instance and exposes functions to use it. To use, create a redis database on Upstash and set the environment variables. UPSTASH_REDIS_REST_URL UPSTASH_REDIS_REST_TOKEN Val.town runs in ohio so the best region to pick for the redis instance is probably us-east-1 . Calls are also traced via https://www.val.town/v/saolsen/tracing so if you use that library you will see timed spans for any redis calls. For an example of how to use it see https://www.val.town/v/saolsen/try_redis
Script
# Upstash redis client for vals.
Creates a global redis instance and exposes functions to use it.
janpaul123 avatar
compareEmbeddings
@janpaul123
An interactive, runnable TypeScript val by janpaul123
Script
import { decode as base64Decode, encode as base64Encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
import { createClient } from "https://esm.sh/@libsql/client@0.6.0/web";
import { sqlToJSON } from "https://esm.town/v/nbbaier/sqliteExportHelpers?v=22";
import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
cingozilyas avatar
BuyukInsan
@cingozilyas
@jsxImportSource npm:react
HTTP (deprecated)
/** @jsxImportSource npm:react **/
import { renderToString } from "npm:react-dom@18/server";
// Albüm verisi
const albumData = {
vtdocs avatar
downloadTextFromS3
@vtdocs
Part of the Upload and download from AWS S3 guide on docs.val.town
Script
export const downloadTextFromS3 = (async () => {
const { S3Client } = await import(
"https://deno.land/x/s3_lite_client@0.6.1/mod.ts"
const s3client = new S3Client({
endPoint: "s3.amazonaws.com",
secretKey: process.env.awsS3Secret,
const res = await s3client.getObject("filename.txt");
return await res.text();
vtdocs avatar
supaBaseQuery
@vtdocs
A helper for writing parameterized Postgres queries for Supabase. Part of the Supabase guide on docs.val.town .
Script
args: any[] = [],
const { Client } = await import(
"https://deno.land/x/postgres@v0.17.0/mod.ts"
const client = new Client(connectionString);
await client.connect();
const result = await client.queryArray(query, args);
await client.end();
return result;
robsimmons avatar
aoc_2023_15_1
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.11/lib/client.js";
const INPUT = `
rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7
onurpolattimur avatar
emeraldPig
@onurpolattimur
An interactive, runnable TypeScript val by onurpolattimur
Script
import Craftgate from "npm:@craftgate/craftgate";
const craftgate = new Craftgate.Client({
apiKey: "sandbox-YEhueLgomBjqsnvBlWVVuFsVhlvJlMHE",
secretKey: "sandbox-tBdcdKVGmGupzfaWcULcwDLMoglZZvTz",
jacoblee93 avatar
runAgent
@jacoblee93
An interactive, runnable TypeScript val by jacoblee93
Script
gl: "us",
const agent = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "chat-conversational-react-description",
const result = await agent.call({
input: `Generate a Twitter thread announcing a new LangChain release.
neverstew avatar
githubRestClient
@neverstew
githubRestClient Does what it says! Defaults to using GITHUB_TOKEN env var if none is passed to the function.
Script
# githubRestClient
Does what it says! Defaults to using `GITHUB_TOKEN` env var if none is passed to the function.
import { Octokit } from "npm:@octokit/rest";
export async function githubRestClient(ghToken: string | undefined) {
return new Octokit({ auth: ghToken || Deno.env.get("GITHUB_TOKEN") }).rest;
nbbaier avatar
readmeGPT
@nbbaier
Val Town AI Readme Writer This val provides a class ReadmeWriter for generating readmes for vals with OpenAI. It can both draft readmes and update them directly PRs welcome! See Todos below for some ideas I have. Usage To draft a readme for a given code, use the draftReadme method: import { ReadmeWriter } from "https://esm.town/v/nbbaier/readmeGPT"; const readmeWriter = new ReadmeWriter({}); const val = "https://www.val.town/v/:username/:valname"; const generatedReadme = await readmeWriter.draftReadme(val); To write and update a readme for a given code, use the writeReadme method: import { ReadmeWriter } from "https://esm.town/v/nbbaier/readmeGPT"; const readmeWriter = new ReadmeWriter({}); const val = "https://www.val.town/v/:username/:valname"; const successMessage = await readmeWriter.writeReadme(val); API Reference Class: ReadmeWriter The ReadmeWriter class represents a utility for generating and updating README files. Constructor Creates an instance of the ReadmeWriter class. Parameters: model (optional): The model to be used for generating the readme. Defaults to "gpt-3.5-turbo". apiKey (optional): An OpenAI API key. Defaults to Deno.env.get("OPENAI_API_KEY") . Methods draftReadme(val: string): Promise<string> : Generates a readme for the given val. Parameters: val : URL of the code repository. Returns: A promise that resolves to the generated readme. writeReadme(val: string): Promise<string> : Generates and updates a readme for the given val. Parameters: val : URL of the code repository. Returns: A promise that resolves to a success message if the update is successful. Todos [ ] Additional options to pass to the OpenAI model [ ] Ability to pass more instructions to the prompt to modify how the readme is constructed
Script
import { type WriterOptions } from "https://esm.town/v/nbbaier/WriterOptions";
import { fetch } from "https://esm.town/v/std/fetch?v=4";
import OpenAI, { type ClientOptions } from "npm:openai";
export class ReadmeWriter {
model: string;