Search

Results include substring matches and semantically similar vals. Learn more
ale_annini avatar
images
@ale_annini
An interactive, runnable TypeScript val by ale_annini
Script
import { openaiImages } from "https://esm.town/v/ale_annini/openaiImages";
export const images = openaiImages({ prompt: "a dog", n: 2 });
triptych avatar
hitCounter
@triptych
Create a simple hit counter that you can attach to any website via fetch . I created a web component to use this : export class HitCounter extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.count = 0; this.fetchCount(); } fetchCount() { fetch('https://triptych-hitcounter.web.val.run/') .then(response => response.json()) .then(data => { this.count = data.siteCount; this.render(); }) .catch(error => console.error('Error fetching count:', error)); } render() { const container = document.createElement('div'); container.style.backgroundColor = 'black'; container.style.color = 'white'; container.style.border = '1px solid white'; container.style.padding = '10px'; container.style.display = 'inline-block'; // Add this line container.textContent = `hit count: ${this.count}`; this.shadowRoot.appendChild(container); } } customElements.define('hit-counter', HitCounter);
HTTP (deprecated)
Create a simple hit counter that you can attach to any website via fetch .
I created a web component to use this :
export class HitCounter extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
const KEY = "site_count";
// let hitCount = await blob.getJSON(KEY);
const oldState = await blob.getJSON(KEY) ?? 0;
console.log("Old value", oldState);
fossforlife avatar
lastFmNowPlaying
@fossforlife
An interactive, runnable TypeScript val by fossforlife
Script
import LastFm from "npm:lastfm-node-client";
const lastFm = new LastFm(Deno.env.get("LASTFM_API_KEY"));
const data = await lastFm.userGetRecentTracks({
user: "elias-jackson2",
const mostRecentTrack = data.recenttracks.track[0];
const nowPlaying = mostRecentTrack["@attr"].nowplaying === "true";
console.log(
`${mostRecentTrack.artist["#text"]} - ${mostRecentTrack.name} (Now playing = ${nowPlaying ? "True" : "False"})`,
stevekrouse avatar
png
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export let png = (content) =>
new Response(content, {
headers: {
"Content-Type": "img/png",
boris avatar
quoteResponder
@boris
An interactive, runnable TypeScript val by boris
HTTP (deprecated)
export const quoteResponder = (request) => {
// eventually replace with https://docs.val.town/sqlite
const quotes = [
date: "2023-10-19",
quote:
"Happiness does not come from doing easy work but from the afterglow of satisfaction that comes after the achievement
author: "Theodore Isaac Rubin",
date: "2023-10-20",
quote:
"Just because something doesn't do what you planned it to do doesn't mean it's useless.",
Ryan avatar
getFatCatListings
@Ryan
An interactive, runnable TypeScript val by Ryan
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const getFatCatListings = async () => {
const meResult = await fetch(
"https://api-mainnet.magiceden.dev/v2/collections/degenfatcats/listings?offset=0&limit=20",
headers: { Accept: "application/json" },
if (meResult.status === 200) {
return meResult.json();
throw new Error("Failed to get results");
kora avatar
aiBasicExample
@kora
Using Vercel AI SDK
Script
Using Vercel AI SDK
import { ModelProvider, modelProvider } from "https://esm.town/v/yawnxyz/ai";
// basic text generation
let response = await modelProvider.gen({
prompt: "hello, who am I speaking to?",
provider: "google",
} as any);
console.log("res:", response);
stevekrouse avatar
karma
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const karma = `"Karma"
You're talking shit for the hell of it
Addicted to betrayal, but you're relevant
You're terrified to look down
'Cause if you dare, you'll see the glare
Of everyone you burned just to get there
It's coming back around
And I keep my side of the street clean
You wouldn't know what I mean
'Cause karma is my boyfriend
emarref avatar
HttpHandler
@emarref
Utilities for handling HTTP requests.
Script
Utilities for handling HTTP requests.
export type HttpHandler = (request: Request) => Promise<Response>;
hobbs avatar
dailyDadJoke
@hobbs
Daily Dad Joke How do you make a programmer laugh every morning? A dad joke cron job! Setup Fork this val Click Create fork 🤣🤣🤣🤣 API This val uses the icanhazdadjoke API . You can find more docs here , such as how to filter by type .
Cron
# Daily Dad Joke
How do you make a programmer laugh every morning?
A dad joke cron job!
## Setup
1. [Fork this val](https://www.val.town/v/stevekrouse/dailyDadJoke/fork)
2. Click **Create fork**
export async function dailyDadJoke() {
let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
return email({
text: punchline,
rraval avatar
emailMe
@rraval
An interactive, runnable TypeScript val by rraval
Script
import { welcomeEmail } from "https://esm.town/v/rodrigotello/welcomeEmail?v=142";
export let emailMe = console.email({
html: welcomeEmail,
subject: "Welcome to Val Town",
ejfox avatar
githubcollabgen
@ejfox
GitHub Collaboration Suggester This tool analyzes the recent GitHub activity of two users and suggests potential collaboration opportunities. Features Fetches the last 3 months of GitHub activity for two users Summarizes activity including event counts, repositories, commits, issues, and pull requests Uses AI to generate collaboration suggestions based on the activity summaries Usage To use it, make a GET request with two GitHub usernames as query parameters: https://ejfox-githubcollabgen.web.val.run?user1=<username1>&user2=<username2> Curl Compare two specific users: curl "https://ejfox-githubcollabgen.web.val.run?user1=ejfox&user2=stevekrouse" Response The API returns a plain text response with AI-generated collaboration suggestions, including: Potential collaborative projects Technologies to explore or learn Ways to complement each other's skills Opportunities for knowledge sharing or mentoring Possible open-source contributions
HTTP (deprecated)
# GitHub Collaboration Suggester
This tool analyzes the recent GitHub activity of two users and suggests potential collaboration opportunities.
## Features
- Fetches the last 3 months of GitHub activity for two users
- Summarizes activity including event counts, repositories, commits, issues, and pull requests
- Uses AI to generate collaboration suggestions based on the activity summaries
const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
export default async function main(req: Request): Promise<Response> {
const url = new URL(req.url);
const user1 = url.searchParams.get("user1") || "ejfox";
darcy avatar
following
@darcy
An interactive, runnable TypeScript val by darcy
Script
export let following = ["wesbos", "stevekrouse", "darcy"];
janpaul123 avatar
valle_tmp_642242117750307901497006663363
@janpaul123
* This approach will create a simple HTML page with embedded CSS for the wild styling and a bit of JavaScript to handle the game logic of Wordle. * We'll use vanilla JavaScript and HTML for simplicity, no external libraries or frameworks are necessary. * The CSS will include bold color gradients, vibrant fonts, and other "crazy" styles.
HTTP (deprecated)
* This approach will create a simple HTML page with embedded CSS for the wild styling and a bit of JavaScript to handle the
* We'll use vanilla JavaScript and HTML for simplicity, no external libraries or frameworks are necessary.
* The CSS will include bold color gradients, vibrant fonts, and other "crazy" styles.
export default async function main(req: Request): Response {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
willkbl avatar
emailRandomJoke
@willkbl
// Fetches a random joke.
Cron
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
return response.json();
const randomJoke = await fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
// Sends an email with the joke.
export const emailRandomJoke = email({