Search

Results include substring matches and semantically similar vals. Learn more
tempguy avatar
plumOwl
@tempguy
An interactive, runnable TypeScript val by tempguy
HTTP
data: {
link: string;
export default async function(req: Request): Promise<Response> {
const showbox = await Fetch("https://www.showbox.media/index/share_link?id=55137&type=1", {
headers: {
movienerd avatar
clickerGame
@movienerd
* This clicker game allows users to earn virtual money by clicking. * It includes an upgrade system where users can purchase multiple auto-clickers, dime-smithers, quarter-makers, dollar-mills, twoonie-transformers, fiver-factories, ten-trackers, twenty-detectors, fifty-forgers, and hundred-hewers. * Each upgrade adds to the overall effect, increasing earnings per second. * Upgrades are hidden until they are unlocked for the first time. * The game state is stored client-side using localStorage for persistence. * React is used for the UI, and setInterval for the auto-upgrade functionality.
HTTP
* The game state is stored client-side using localStorage for persistence.
* React is used for the UI, and setInterval for the auto-upgrade functionality.
/** @jsxImportSource https://esm.sh/react */
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [money, setMoney] = useState(() => {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
return new Response(`
tiga avatar
json
@tiga
An interactive, runnable TypeScript val by tiga
HTTP
import os from "node:os";
import { v4 as uuidV4 } from "npm:uuid";
export default async function(req: Request): Promise<Response> {
return Response.json({
ok: true,
carter_vargas avatar
welcomingAmethystRaccoon
@carter_vargas
// Fetches a random joke.
Script
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
maxm avatar
robPikeIO
@maxm
robpike.io A re-implementation of https://robpike.io/
HTTP
const msg = new TextEncoder().encode("💩");
const initialDelay = 20;
export default async function(req: Request): Promise<Response> {
let timerId: number | undefined;
const body = new ReadableStream({
start(controller) {
let currentDelay = initialDelay;
function writeToStream() {
currentDelay *= 1.03;
controller.enqueue(msg);
arjunvgithub avatar
jokegenerator
@arjunvgithub
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
willthereader avatar
AlgoliaInstantSearchWebsite
@willthereader
An interactive, runnable TypeScript val by willthereader
HTTP
import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
function validateConfig(): { appId: string; apiKey: string } {
const appId = Deno.env.get("ALGOLIA_APP_ID");
return { appId, apiKey };
function generateHtml(appId: string, apiKey: string): string {
console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
templates: {
item: function(hit) {
console.log('Hit:', hit); // Add this line
</html>
function handleError(error: Error): Response {
console.error("Server error:", error);
return new Response(`Error: ${error.message}`, { status: 500 });
async function handleRequest(request: Request): Promise<Response> {
console.log("Received request:", request.url);
tempdev avatar
anime
@tempdev
@jsxImportSource npm:hono@3/jsx
HTTP
let streams = []
function initPlayer() {
const video = document.querySelector("media-player");
loadServer(streams[0])
function loadServer(val) {
const player = document.querySelector("media-player");
JSON.stringify(results)
};function loadVideo(index){const videoStream=videoData[index].stream[0];const quality=videoStream.qualities.unknown;cons
app.get("/", async (c) => {
stevekrouse avatar
cerebras_searcher
@stevekrouse
Cerebras Searcher a Perplexity clone that uses the SerpAPI to do RAG and summaries with Cerebras ( requires a SerpAPI key ) This val might not be working because we're out of SerpAPI credits, but if you fork it and get your own SerpAPI key, it should work. Comment on this val if you still have trouble, thanks! Setup Fork this val Sign up for Cerebras and get an API key Save it in a Val Town environment variable called CEREBRAS_API_KEY Get a SerpAPI key (free trial available) Set your SerpAPI API key into you Val Town Environment Variables Done!
HTTP
"What's the story of the ai that became a millionaire?",
function App() {
const [query, setQuery] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(req: Request): Promise<Response> {
if (req.method === "POST") {
dbee avatar
fcReady
@dbee
// Initialize the Farcaster SDK and set the frame context
Script
await fcsdk.actions.ready();
console.log("V2 Activated!");
// Define a global function to add a frame
window.addFrame = async () => {
try {
} catch (error) {
console.error("Error adding frame:", error);
// Define a global function to close a frame
window.closeFrame = async () => {
try {
chen avatar
twitterAlert
@chen
Daily Twitter "Important Updates" Digest You like getting important updates from Twitter—new projects or writing or companies to learn about. But you don't like being addicted to the feed constantly. This val lets you get daily updates from specific people you want to follow closely. It uses AI to filter out random shitposts and only get the important updates. 1. Authentication You'll need a Twitter Bearer Token. Follow these instructions to get one. Unfortunately it costs $100 / month to have a Basic Twitter Developer account. If you subscribe to Val Town Pro, you can ask Steve Krouse to borrow his token. Also rate limits seem really severe which limits how useful this is :( Need to figure out workarounds... 2. Query Update the list of usernames to people you care about; change the AI prompt if you want different filtering. 3. Notification Sends a daily email. Todos: this should filter the twitter API call to only tweets since the last run. some kind of caching to avoid rate limiting would be nice to use the user's feed instead of a username list... but not sure how easy that is
Cron
import { email } from "https://esm.town/v/std/email?v=12";
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
// "sliminality",
const openai = new OpenAI();
export async function twitterAlert({ lastRunAt }: Interval) {
let results = [];
await new Promise((resolve) => setTimeout(resolve, 1000));
async function filterTweets(tweets) {
const completion = await openai.chat.completions.create({
messages: [
iamseeley avatar
resumeJSON
@iamseeley
🎉 A handler to serve your JSON Resume.
HTTP
export default async function handler(req: Request): Promise<Response> {
const resumeJSON = {
"basics": {
tristanmagne avatar
renderHTMLWithHono
@tristanmagne
// This val uses Hono, a lightweight web framework, to create a simple HTML page.
HTTP
</body>
</html>
export default async function server(req: Request): Promise<Response> {
return app.fetch(req);
shuyib avatar
pokemonBattleAdvisor
@shuyib
Pokémon Battle Advisor Overview The Pokémon Battle Advisor is a web application designed to help Pokémon trainers strategize their battles by providing detailed and realistic battle recommendations. Users can specify their Pokémon team or randomize a team, and then receive tailored battle strategies based on their team and the opponent's Pokémon. The application leverages the CEREBRAS API to generate these recommendations, ensuring they adhere to official Pokémon game mechanics. Features Specify Your Pokémon Team : Users can enter the names of up to three Pokémon to include in their team. Randomize Pokémon Team : Users can opt to randomize their Pokémon team, fetching three random Pokémon from the PokéAPI. Challenger Pokémon Input : Users can enter the name of the opponent's Pokémon to receive a battle recommendation. Battle Recommendations : The app provides detailed battle strategies, including recommended Pokémon, strategies, and type advantages. Data Validation : Ensures that only valid Pokémon names are accepted, preventing random or incorrect names from being processed. Caching Mechanism : Uses in-memory caching to store fetched Pokémon data, reducing redundant API calls and improving performance. Responsive Design : The app is designed to be responsive, ensuring usability across various devices and screen sizes. Installation Prerequisites Deno : This project is built using Deno, a secure runtime for JavaScript and TypeScript. Install Deno by following the instructions on the official website . Steps Fork the Repository : Set Up Environment Variables : Create a .env file in the root directory and add your Cerebras API key: CEREBRAS_API_KEY=your_cerebras_api_key Note: Ensure that your Cerebras API key is kept secure and not exposed publicly. Run the Application : Execute the following command to start the server: deno run --allow-net --allow-env cerebras_try.ts --allow-net : Grants network access needed for API calls. --allow-env : Grants access to environment variables for the API key. Access the Application : Open your browser and navigate to http://localhost:8000 to view the Pokémon Battle Advisor. Usage Specify Your Pokémon: Enter the names of up to three Pokémon in the input fields provided. Click the "🎯 Load Specified Pokémon" button to fetch and display the specified Pokémon. Randomize Pokémon: Click the "🔀 Randomize Pokémon" button to fetch and display three random Pokémon. Enter Challenger's Pokémon: Enter the name of the opponent's Pokémon in the input field provided. Click the "🤖 Get Battle Recommendation" button to generate a battle strategy. View Battle Recommendation: The app will display a detailed battle recommendation, including recommended Pokémon, strategies, and type advantages. Code Structure cerebras_try.ts : The main TypeScript file that serves both the server and client-side code. Server-Side: Handles HTTP requests. Serves the HTML page containing the React application. Provides an API endpoint ( /api/cerebras-key ) to securely retrieve the Cerebras API key. Client-Side: Built using React. Manages the user interface, state management, and interactions. Fetches Pokémon data from the PokéAPI. Communicates with the OpenAI API but uses the CEREBRAS API to generate battle recommendations. Components & Functions: App Component : The main React component that manages the state and logic for the application. validatePokemonData Function : Validates the structure and types of fetched Pokémon data. loadUserPokemons Function : Fetches and validates user-specified Pokémon. fetchRandomPokemon Function : Fetches and validates random Pokémon. generateBattleRecommendation Function : Generates battle recommendations using the OpenAI API. formatRecommendation Function : Formats the recommendation text into structured sections. Error Handling Invalid Pokémon Names : If a user enters an invalid Pokémon name, an error message is displayed prompting the user to enter a valid name. API Errors : Any network or unexpected errors during API calls are caught, and corresponding error messages are displayed to the user. Missing API Key : The application checks for the presence of the Cerebras API key and notifies the user if it's missing or invalid. Technologies Used Deno : A secure runtime for JavaScript and TypeScript. React : For building the user interface. OpenAI API : For generating battle recommendations. PokéAPI : For fetching Pokémon data. TypeScript : For type safety and improved developer experience. Contributing Contributions are welcome! Please follow these steps to contribute: Relevant when I move it to github. Fork the Repository : Click the "Fork" button at the top right of the repository page to create a copy of the repository under your GitHub account. Clone Your Fork : git clone https://github.com/yourusername/pokemon-battle-advisor.git cd pokemon-battle-advisor Create a New Branch : git checkout -b feature/your-feature-name Make Your Changes : Implement your feature or bug fix. Commit Your Changes : git commit -m "Add your commit message here" Push to Your Fork : git push origin feature/your-feature-name Submit a Pull Request : Go to the original repository on GitHub and create a pull request from your forked repository. License This project is licensed under the MIT License. See the LICENSE file for details. Contact For any questions or feedback, please contact cusp-aloft-brim@duck.com
HTTP
- Communicates with the OpenAI API but uses the CEREBRAS API to generate battle recommendations.
### Components & Functions:
- **validatePokemonData Function**: Validates the structure and types of fetched Pokémon data.
import OpenAI from "https://esm.sh/openai@4.28.4";
// Server-side API key retrieval function
async function getCerebrasKey() {
// Utility function to parse and format recommendation
function formatRecommendation(text: string) {
function App() {
// Data Validation Function
function validatePokemonData(pokemon: any): Pokemon | null {
function handleUserInputChange(index: number, value: string) {
async function loadUserPokemons() {
frontsideair avatar
exchangeRate
@frontsideair
An interactive, runnable TypeScript val by frontsideair
Script
import { email } from "https://esm.town/v/std/email?v=9";
import { fetch } from "https://esm.town/v/std/fetch";
export async function exchangeRate() {
const cheerio = await import("npm:cheerio");
const page = await fetch(