Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_LrzLvmI3RJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
juansebsol avatar
solanaPayDemo
@juansebsol
Solana Pay Demo A fork of solana-pay-qrcode-generator
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function Home() {
const [storeName, setStoreName] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<Home />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
syncretizm avatar
singleformulaEndpoint
@syncretizm
An interactive, runnable TypeScript val by syncretizm
HTTP
const functionMap = {
return new Response("Invalid arguments for datebetween function");
console.log(`if function called with a: ${a}, b: ${b}, c: ${c}`);
console.log(`if function result: ${result}`);
function tokenize(formula) {
const functionsRegex = new RegExp(`\\b(${Object.keys(functionMap).join("|")})\\b`, "g");
+ `${functionsRegex.source}|`
function parse(tokens) {
function peek() {
function consume() {
pomdtr avatar
val_town_by_example_parse
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
text: string;
code: string;
export function extractSnippets(content: string): ExampleSnippet[] {
// Separate the code into snippets.
const snippets: ExampleSnippet[] = [];
snippets.push({ text, code });
return snippets;
export async function parseExample(author: string, name: string): Promise<Example> {
let { code } = await api<{ code: string }>(`/v1/alias/${author}/${name}`);
// Substitute $std/ with the full import url
dhvanil avatar
val_ZiSgmpYhg6
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() { let a = 0, b = 1; while (b < 1000) { let temp = b; b = a + b; a = temp; } return b;
fibonacci();
return Response.json({ success: true, result });
toowired avatar
alluringSapphireStoat
@toowired
// Test starting a new goal
Script
return { success: false, error: error.message };
// Export for Val Town
export async function test(args) {
return await runTests();
pomdtr avatar
sunbeam
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
fi
exec sunbeam -d "@-" -X POST ${shlex.quote(webEndpoint)}
export default function(req: Request) {
const [, author, name] = new URL(req.url).pathname.split("/");
if (!author || !name) {
steveb1313 avatar
LoginPeloton
@steveb1313
An interactive, runnable TypeScript val by steveb1313
Script
import { fetch } from "https://esm.town/v/std/fetch";
import process from "node:process";
export async function LoginPeloton(
req: express.Request,
res: express.Response,
iamseeley avatar
valTownUser
@iamseeley
👤 valTownUser The valTownUser object provides a convenient interface to interact with Val Town's API and access user-specific information and functionalities. User Information getUserInfo() Fetches and caches the user's information. Use case: Retrieving all user details at once. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getUserInfo = () => valTownUser.getUserInfo(); // Example usage: const userInfo = await getUserInfo(); console.log('User Information:', userInfo); // You can also destructure specific properties you need: const { username, id, email, tier } = await getUserInfo(); console.log(`Username: ${username}`); console.log(`User ID: ${id}`); console.log(`Email: ${email}`); console.log(`Account Tier: ${tier}`); getUsername() Retrieves the user's username. Use case: Displaying the current user's name in a val. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getUsername = () => valTownUser.getUsername(); // Example usage: const username = await getUsername(); console.log(`Current user: ${username}`); getId() Retrieves the user's ID. Use case: Using the user ID for database queries or API calls. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getId = () => valTownUser.getId(); // Example usage: const userId = await getId(); console.log(`User ID: ${userId}`); getBio() Retrieves the user's biography. Use case: Displaying the user's bio on a profile page. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getBio = () => valTownUser.getBio(); // Example usage: const bio = await getBio(); console.log(`User bio: ${bio || 'Not set'}`); getProfileImageUrl() Retrieves the URL of the user's profile image. Use case: Showing the user's avatar in a val. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getProfileImageUrl = () => valTownUser.getProfileImageUrl(); // Example usage: const profileImageUrl = await getProfileImageUrl(); console.log(`Profile image URL: ${profileImageUrl || 'Not set'}`); getEmail() Retrieves the user's email address. Use case: Sending notifications or verifications. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getEmail = () => valTownUser.getEmail(); // Example usage: const email = await getEmail(); console.log(`User email: ${email}`); getTier() Retrieves the user's account tier. Use case: Implementing tier-specific features. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getTier = () => valTownUser.getTier(); // Example usage: const tier = await getTier(); console.log(`User tier: ${tier}`); URL Generation getEndpointUrl(valName) Generates the endpoint URL for a specified val. Use case: Creating links to val endpoints in your application. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getEndpointUrl = (valName: string) => valTownUser.getEndpointUrl(valName); // Example usage: const endpointUrl = await getEndpointUrl('mySitesServer'); console.log(`Endpoint URL: ${endpointUrl}`); getValUrl(valName) Generates the Val Town URL for a specified val. Use case: Creating links to val pages in Val Town. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getValUrl = (valName: string) => valTownUser.getValUrl(valName); // Example usage: const valUrl = await getValUrl('myVal'); console.log(`Val URL: ${valUrl}`); User Activity getLikedVals(options) Retrieves the vals liked by the user. Use case: Displaying a list of the user's favorite vals. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getLikedVals = (options = {}) => valTownUser.getLikedVals(options); // Example usage: const likedVals = await getLikedVals({ limit: 5 }); console.log('Liked vals:', likedVals.data); getComments(options) Retrieves comments related to the user. Use case: Showing a user's comment history. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getComments = (options = {}) => valTownUser.getComments(options); // Example usage: const comments = await getComments({ limit: 10, relationship: 'given' }); console.log('User comments:', comments.data); getReferences(options) Retrieves references to the user's vals. Use case: Tracking how often a user's vals are used by others. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getReferences = (options = {}) => valTownUser.getReferences(options); // Example usage: const references = await getReferences({ limit: 5 }); console.log('Val references:', references.data); Blob Management listBlobs(prefix) Lists the user's blobs. Use case: Displaying a file manager for the user's stored data. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const listBlobs = (prefix?: string) => valTownUser.listBlobs(prefix); // Example usage: const blobs = await listBlobs(); console.log('User blobs:', blobs); storeBlob(key, data) Stores a new blob or updates an existing one. Use case: Uploading user files or storing large datasets. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const storeBlob = (key: string, data: any) => valTownUser.storeBlob(key, data); // Example usage: await storeBlob('myFile.txt', 'Hello, World!'); console.log('Blob stored successfully'); getBlob(key) Retrieves a specific blob. Use case: Downloading a user's stored file. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const getBlob = async (key: string) => { const blobData = await valTownUser.getBlob(key); return new TextDecoder().decode(new Uint8Array(blobData)); }; // Example usage: const blobContent = await getBlob('myFile.txt'); console.log('Blob content:', blobContent); deleteBlob(key) Deletes a specific blob. Use case: Removing old or unnecessary files. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const deleteBlob = (key: string) => valTownUser.deleteBlob(key); // Example usage: await deleteBlob('myFile.txt'); console.log('Blob deleted successfully'); Val Management listVals(options) Lists the user's vals. Use case: Displaying a dashboard of the user's created vals. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const listVals = (options = {}) => valTownUser.listVals(options); // Example usage: const userVals = await listVals({ limit: 5 }); console.log('User vals:', userVals.data); createVal(valInfo) Creates a new val. Use case: Programmatically creating vals based on user input. import { valTownUser } from "https://esm.town/v/iamseeley/valTownUser"; export const createVal = (valInfo: any) => valTownUser.createVal(valInfo); // Example usage: const newVal = await createVal({ name: 'myNewVal', code: 'console.log("Hello, World!");' }); console.log('Created val:', newVal); updateVal(valId, updates) Updates an existing val. Use case: Implementing an "edit val" feature in your application. deleteVal(valId) Deletes a specific val. Use case: Allowing users to remove their vals through your interface. SQLite Database Operations executeSqlite(statement) Executes a SQLite statement. Use case: Running custom queries on the user's database. listTables() Lists all tables in the user's SQLite database. Use case: Displaying the structure of a user's database. getTableSchema(tableName) Retrieves the schema of a specific table. Use case: Showing the structure of a particular table. getTableContent(tableName, limit) Retrieves the content of a specific table. Use case: Displaying the data stored in a user's table.
Script
**👤 valTownUser**
ce to interact with Val Town's API and access user-specific information and functionalities.
## User Information
janpaul123 avatar
valle_tmp_0233014610531885327677280675261011
@janpaul123
// This val responds with "Hello, World!"
HTTP
// This val responds with "Hello, World!"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, World!", {
headers: {
cjlm avatar
sqliteExplorerApp
@cjlm
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
- [x] make result tables scrollable
- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteE
- [x] add listener for cmd+enter to submit query
stef avatar
sqliteExplorerApp
@stef
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
- [x] make result tables scrollable
- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteE
- [x] add listener for cmd+enter to submit query
rhi avatar
myApi
@rhi
An interactive, runnable TypeScript val by rhi
Script
export function myApi(name) {
return "hi " + name;
stevedylandev avatar
twemoji
@stevedylandev
* modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
Script
const UFE0Fg = /\uFE0F/g;
export function getIconCode (char: string) {
return toCodePoint(!char.includes(U200D) ? char.replace(UFE0Fg, "") : char);
function toCodePoint (unicodeSurrogates: string) {
const r = [];
const emojiCache: Record<string, Promise<string>> = {};
export async function loadEmoji (type: keyof typeof apis, code: string) {
const key = `${type}:${code}`;
const api = apis[type];
if (typeof api === "function") {
return (emojiCache[key] = fetch(api(code)).then(async r => r.text()));
inlustra avatar
myApi
@inlustra
An interactive, runnable TypeScript val by inlustra
Script
export function myApi(name) {
return "hi " + name;