Search

Results include substring matches and semantically similar vals. Learn more
pomdtr avatar
kv
@pomdtr
Usage import { openKv } from "https://esm.town/v/pomdtr/kv" const kv = openKv() await kv.set("test", true) console.log(await kv.get("test"))
Script
import { sqliteStore } from "https://esm.town/v/vladimyr/keyvhqSqlite";
import Keyv from "npm:@keyvhq/core";
export function openKv<T = any>() {
const { slug } = callerRef();
return new Keyv<T>({ store: sqliteStore, namespace: slug });
dinavinter avatar
connect
@dinavinter
An interactive, runnable TypeScript val by dinavinter
Script
} from "https://esm.sh/@hocuspocus/provider@2.15.0?&external=ws&target=esnext&yjs=13.6.20";
import * as Y from "https://esm.sh/yjs@^13.6.20?target=esnext";
export function connectYjs(doc: Y.Doc | string): Y.Doc {
const provider = new HocuspocusProvider({
preserveConnection: true,
britzdm avatar
myApi
@britzdm
An interactive, runnable TypeScript val by britzdm
Script
export function myApi(name) {
return "hi " + name;
jamisonl avatar
lavenderPinniped
@jamisonl
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
HTTP
mmands, you have to run a separate bit of code. This is for modifying their functionality
req.headers.get("X-Signature-Ed25519"),
req.headers.get("X-Signature-Timestamp"),
// Get the user calling this slash command
const userId = await body.member?.user?.id;
if (bank[userId] === undefined) bank[userId] = starting_amount;
abar04 avatar
weatherGPT
@abar04
Cron
import { email } from "https://esm.town/v/std/email?v=11";
import { OpenAI } from "npm:openai";
let location = "Perth WA";
).then(r => r.json());
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [{
console.log(text);
export async function weatherGPT() {
await email({ subject: "Weather Today", text });
stevekrouse avatar
expressHTMLExample
@stevekrouse
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
Express (deprecated)
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
export async function expressHTMLExample(
req: express.Request,
res: express.Response,
jonicas avatar
myApi
@jonicas
An interactive, runnable TypeScript val by jonicas
Script
export function myApi(name) {
return "hi " + name;
ImGqb avatar
testFetch
@ImGqb
An interactive, runnable TypeScript val by ImGqb
Script
export function testFetch(params: any) {
return params;
dhvanil avatar
val_wOeFDx5oZj
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wOeFDx5oZj(req) {
try {
// Execute the code directly and capture its result
iakovos avatar
rateArticleRelevance
@iakovos
An interactive, runnable TypeScript val by iakovos
Script
export const rateArticleRelevance = async (interests: string, article: any) => {
const { default: OpenAI } = await import("npm:openai");
const openai = new OpenAI({ apiKey: process.env.OPENAI_KEY });
try {
Give a score from 0 to 10. Why did you give this score? Respond with the score only.
const response = await openai.chat.completions.create({
messages: [
mpsuesser avatar
myApi
@mpsuesser
An interactive, runnable TypeScript val by mpsuesser
Script
export function myApi(name) {
return "hi " + name;
puf avatar
getFirebaseTweets
@puf
An interactive, runnable TypeScript val by puf
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function getFirebaseTweets() {
const result = await fetch("https://twitter.com/firebase");
console.log(result);
vtdocs avatar
browserlessScrapeExample
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Script
method: "POST",
body: JSON.stringify({
"url": "https://en.wikipedia.org/wiki/OpenAI",
"elements": [{
// The second <p> element on the page
stevekrouse avatar
dude
@stevekrouse
Run squint in val.town!
Script
console.log(theString);
theString = theString.replace(`'squint-cljs/core.js'`, `'npm:squint-cljs/core.js'`);
const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
await new AsyncFunction(theString)();
shaparder avatar
myApi
@shaparder
An interactive, runnable TypeScript val by shaparder
Script
export function myApi(name) {
return "hi " + name;