Search

Results include substring matches and semantically similar vals. Learn more
andreterron avatar
twitter
@andreterron
Login with ~~Twitter~~ 𝕏 Use this val to login with 𝕏 and save your token into a twitter_token val Usage Fork this val Change the 🔒 privacy to "Unlisted" Navigate to https://developer.twitter.com/en/portal/dashboard to create an OAuth app and save your client id and secret to your secrets page Navigate to https://{your_username}-twitter.web.val.run to authenticate with 𝕏 And then you'll have your tokens saved to a twitter_token val! Other ~~Twitter~~ 𝕏 helper vals Refresh your tokens: https://www.val.town/v/andreterron/refreshTwitterToken Fetch user by id: https://www.val.town/v/andreterron/fetchTwitterUser Search posts: https://www.val.town/v/andreterron/searchTweets Write an X post: https://www.val.town/v/andreterron/postTweet
Script
2. Change the 🔒 privacy to "Unlisted"
veloper.twitter.com/en/portal/dashboard to create an OAuth app and save your client id and secret to your [secrets page](http
5. Navigate to https://{your_username}-twitter.web.val.run to authenticate with 𝕏
const { res, token, storage } = await twitterAuthHandler(req, {
client_id: process.env.twitter_client_id,
client_secret: process.env.twitter_client_secret,
redirect_uri: `https://${username}-twitter.web.val.run/callback`,
stevekrouse avatar
spotifyAuthorizeURL
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { spotifyRedirectURI } from "https://esm.town/v/stevekrouse/spotifyRedirectURI";
import { spotifyScopes } from "https://esm.town/v/stevekrouse/spotifyScopes";
import { spotifyClientId } from "https://esm.town/v/stevekrouse/spotifyClientId";
export let spotifyAuthorizeURL = async (params = {
response_type: 'code',
client_id: spotifyClientId,
scope: spotifyScopes.join(","),
redirect_uri: spotifyRedirectURI,
augustohp avatar
BalanceCapMonster
@augustohp
An interactive, runnable TypeScript val by augustohp
Script
method: "POST",
body: JSON.stringify({
clientKey: token,
if (result.errorId != 0) {
throw new Error("Could not fetch balance.");
dthyresson avatar
getSpotifyAccessToken
@dthyresson
getSpotifyAccess Token Request an access token for use with the Spotify Web API. Requires environment variables from your Spotify Developers account. SPOTIFY_CLIENT_ID SPOTIFY_CLIENT_SECRET Uses Blob storage to cache the spotify_accessToken based on when the expires_in value in the Spotify Access Token response. Example import { getSpotifyAccessToken } from "https://esm.town/v/dthyresson/getSpotifyAccessToken"; const accessToken = await getSpotifyAccessToken(); console.debug(accessToken)
Script
Requires environment variables from your Spotify Developers account.
* `SPOTIFY_CLIENT_ID`
* `SPOTIFY_CLIENT_SECRET`
Uses Blob storage to cache the `spotify_accessToken` based on when the `expires_in` value in the Spotify Access Token respons
const KEY = "spotify_accessToken";
const clientId = Deno.env.get("SPOTIFY_CLIENT_ID");
const clientSecret = Deno.env.get("SPOTIFY_CLIENT_SECRET");
if (!clientId || !clientSecret) {
throw Error("A SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET is required.");
let spotifyAccessToken = await blob.getJSON(KEY) as SpotifyAccessToken;
"Content-Type": "application/x-www-form-urlencoded",
body: `grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}`,
if (response.status === 200) {
robsimmons avatar
aoc_2023_11_impractical
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
.trim()
pomdtr avatar
awesome
@pomdtr
Awesome Val Town An curated list of useful community vals. Feel free to create your own awesome list! Apps @pomdtr/blob_editor @nbbaier/sqliteExplorerApp View and interact with your Val Town SQLite data. @pomdtr/http_client Attach a postman-like http client to your vals VS Code Extension vt Chrome Extension Tooling Authentication @pomdtr/basicAuth @pomdtr/email_auth @pomdtr/password_auth Sqlite @sqlite/db @pomdtr/sql @pomdtr/kv @postpostscript/sqliteUniverse Blob @stevekrouse/blobAdmin @pomdtr/lowdb Middleware @andreterron/codeOnValTown Testing @pomdtr/test_explorer Api @pomdtr/api @pomdtr/trpc Other @vladimyr/valshot @pomdtr/mdx @pomdtr/serve_readme OpenAI @pomdtr/ask_ai Web Components Val Town Playground CodeMirror
HTTP (deprecated)
- @nbbaier/sqliteExplorerApp View and interact with your Val Town SQLite data.
- @pomdtr/http_client Attach a postman-like http client to your vals
- [VS Code Extension](https://github.com/pomdtr/val-town-vscode)
dandivelbiss avatar
pushNote
@dandivelbiss
Notehub A set of helper functions for interacting with the Notehub API Requires NOTEHUB_CLIENT_ID and NOTEHUB_CLIENT_SECRET environment variables to be configured.
Script
A set of helper functions for interacting with the Notehub API
Requires `NOTEHUB_CLIENT_ID` and `NOTEHUB_CLIENT_SECRET` [environment variables](https://www.val.town/settings/environment-va
// Login into the Notehub API with a programmatic access client ID and client secret
// Returns the api token to be used for subsequent requests
const body = new URLSearchParams();
body.append("grant_type", "client_credentials");
body.append("client_id", Deno.env.get("NOTEHUB_CLIENT_ID"));
body.append("client_secret", Deno.env.get("NOTEHUB_CLIENT_SECRET"));
const res = await fetch("https://notehub.io/oauth2/token", {
junhoca avatar
add_to_notion_w_ai
@junhoca
Uses instructor and open ai (with gpt-4-turbo) to process any content into a notion database entry. Use addToNotion with any database id and content. await addToNotion( "DB_ID_GOES_HERE", "CONTENT_GOES HERE"//"for example: $43.28 ordered malai kofta and kadhi (doordash) [me and mom] jan 3 2024" ); Prompts are created based on your database name, database description, property name, property type, property description, and if applicable, property options (and their descriptions). Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email Uses NOTION_API_KEY , OPENAI_API_KEY stored in env variables and uses Valtown blob storage to store information about the database. Use get_notion_db_info to use the stored blob if exists or create one, use get_and_save_notion_db_info to create a new blob (and replace an existing one if exists).
Script
import Instructor from "npm:@instructor-ai/instructor";
import { Client } from "npm:@notionhq/client";
import OpenAI from "npm:openai";
const NOTION_API_KEY = process.env.NOTION_API_KEY;
const notion = new Client({
auth: NOTION_API_KEY,
apiKey: process.env.OPENAI_API_KEY ?? undefined,
const client = Instructor({
client: oai,
mode: "TOOLS",
const db_info = await get_notion_db_info(dbid);
const processed_message = await client.chat.completions.create({
messages: [{ role: "system", content: db_info["system_message"] }, { role: "user", content: text }],
adisbanda avatar
githubWebhookApproveSmallPRs
@adisbanda
An interactive, runnable TypeScript val by adisbanda
HTTP (deprecated)
// if true: do all the checks but don't approve PRs (status code 200 instead of 201)
const dryRun = false;
// only PRs created by these authors will be considered
const allowedAuthors = ["ferrucc-io", "vinayak-mehta"];
// the secret shared with the webhook
robsimmons avatar
aoc_2023_12_sat
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
???.### 1,1,3
tmcw avatar
jsYAMLExample
@tmcw
js-yaml YAML is a popular format for data which is an alternative to JSON . In contrast to JSON, YAML can look more user-friendly: you can write text without worrying about quoting strings You can write comments in YAML But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and predictable. js-yaml is the most popular YAML parser for JavaScript.
Script
- You can write comments in YAML
- But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and pre
[js-yaml](https://www.npmjs.com/package/js-yaml) is the most popular YAML parser for JavaScript.
stevekrouse avatar
sqliteTableExportUtils
@stevekrouse
SQLite Table Export Utils This allows for a val.town-hosted SQLite table to be exported as: JSON ( Record<string, unknown>[] ) Arrow IPC ( Uint8Array ) TODO: Others? This can then be used by a HTTP endpoint, like so: import { exportSQLiteTable, SQLiteTableExportFormat } from "https://esm.town/v/rlesser/sqliteTableExportUtils"; export default async function(req: Request): Promise<Response> { const tableName = new URL(req.url).searchParams.get("table"); if (!tableName) { return new Response("Table name is required", { status: 400 }); } const format = (new URL(req.url).searchParams.get("format") || "arrowIPC") as SQLiteTableExportFormat; const data = await exportSQLiteTable(tableName, format); if (data instanceof Uint8Array) { return new Response(data, { headers: { "Content-Type": "application/octet-stream" }, }); } else { return Response.json(data); } } TODO Specify limit and offset of export, for pagination Smart assessment of if the export is going to be over the val.town limit of 10MB, adjust to paginated of so. Support other export formats. PRs welcome!
Script
import { sqlite } from "https://esm.town/v/std/sqlite";
import { type ResultSet } from "npm:@libsql/client";
import { DataType, Float64, Int32, Table, tableToIPC, Utf8, vectorFromArray } from "npm:apache-arrow";
// Function to map SQLite data types to Apache Arrow data types
julbrs avatar
zohoDeskApi
@julbrs
Zoho Desk API A set of method to easily grab information on Zoho Desk! Official API Documentation is here . Notes It's needed to create a Self Client Application as described here to use this val. You also need to find your org id (under Setup > API > Zoho Service Communication (ZSC) Key > OrgId). Methods As of today here is the methods in this val: refreshAccessToken to generate a valid Access Token based on client id, client secret and a refresh token. Follow the step here to register a client and generate a refresh token. notAssignedTickets to extract the currently not assigned tickets in a specified department
Script
## Notes
It's needed to create a Self Client Application as described [here](https://desk.zoho.com/DeskAPIDocument#OauthTokens#Registe
## Methods
As of today here is the methods in this val:
- `refreshAccessToken` to generate a valid Access Token based on client id, client secret and a refresh token. Follow the ste
- `notAssignedTickets` to extract the currently not assigned tickets in a specified department
export const refreshAccessToken = async (
clientId: string,
clientSecret: string,
refreshToken: string,
params: {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refreshToken,
joey avatar
sendDiscordMessage
@joey
// add the bot to your server before calling:
Script
import { discordAPI } from "https://esm.town/v/joey/discordAPI";
// add the bot to your server before calling:
// https://discord.com/oauth2/authorize?client_id=1099070848968691895&permissions=2048&scope=bot
// Usage:
// await @joey.sendDiscordMessage('some-channel-id', 'hello world!');
janpaul123 avatar
indexValsNeon
@janpaul123
Part of Val Town Semantic Search . Generates OpenAI embeddings for all public vals, and stores them in Neon , using the pg_vector extension. Create the vals_embeddings table in Neon if it doesn't already exist. Get all val names from the database of public vals , made by Achille Lacoin . Get all val names from the vals_embeddings table and compute the difference (which ones are missing). Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the result in Neon. Can now be searched using janpaul123/semanticSearchNeon .
Cron
import { decode as base64Decode, encode as base64Encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
import { Client } from "https://deno.land/x/postgres/mod.ts";
import getValCode from "https://esm.town/v/janpaul123/getValCode";
const dimensions = 1536;
const client = new Client(Deno.env.get("NEON_URL_VALSEMBEDDINGS"));
await client.connect();
const allVals = await sqlToJSON(
const existingEmbeddingsIds = new Set(
(await client.queryObject`SELECT id FROM vals_embeddings`).rows.map(row => row.id),
function idForVal(val: any): string {
const embeddedBinaryString = `[${embeddingBinary.join(",")}]`;
const result = await client
.queryObject`INSERT INTO vals_embeddings (id, embedding) VALUES (${id}, ${embeddedBinaryString})`;