Search
cerebras_coder
@jft51
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
HTTP
This is an AI code assistant powered by [Cerebras](https://cerebras.ai/inference), running llama3.3-70b.
Inspired by Hassan's [Llama Coder](https://llamacoder.together.ai/).
# Setup
1. Sign up for [Cerebras](https://cloud.cerebras.ai/)
2. Get a Cerebras API Key
3. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
export const STARTER_PROMPTS = [
prompt: "todo list app persisted in local storage, pretty",
title: "Todo App",
code:
valle_tmp_666337142910866227920627432385037
@janpaul123
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
HTTP
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
export default async function(req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const htmlResponse = `
<style>
body { font-family: Arial, sans-serif; text-align: center; background-color: #f0f0f0; }
form { margin: 20px auto; padding: 10px; border: 1px solid #ccc; border-radius: 5px; background-color: #fff; width: 300px; }
input[type="text"] { width: 200px; padding: 5px; margin: 5px 0; }
valle_tmp_37032806114103356497303187371446
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
qdrant
@dglazkov
Since Qdrant Cloud has a fairly strict CORS policy, here's a simple val that proxies calls to Qdrant Cloud API and makes them accessible from Web apps. To set up: fork this val add your QDRANT_API_KEY to your environment variables. This would limit usage of your proxy to your API key only. start using val as a proxy Use it as a 1:1 replacement for Qdrant API, except for one additional query string parameter: cluster_id -- the part of the Qdrant API endpoint before cloud.qdrant.io .
HTTP
Since [Qdrant Cloud](https://qdrant.tech/cloud/) has a fairly strict CORS policy, here's a simple val that proxies calls to Qdrant Cloud API and makes them accessible from Web apps.
To set up:
- fork this val
- add your `QDRANT_API_KEY` to your environment variables. This would limit usage of your proxy to your API key only.
- start using val as a proxy
Use it as a 1:1 replacement for Qdrant API, except for one additional query string parameter:
const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"Access-Control-Allow-Headers":
expressHTMLExample2
@henrik
// View at https://api.val.town/express/@stevekrouse.expressHTMLExample?name=Steve
Script
import { mails } from "https://esm.town/v/henrik/mails";
// View at https://api.val.town/express/@stevekrouse.expressHTMLExample?name=Steve
export async function expressHTMLExample2(
req: express.Request,
res: express.Response
mails.push(req.body);
return res.send(`<h1>Hi ${req.body.name}!</h1>`);
// Forked from @stevekrouse.expressHTMLExample2
fav
@yieldray
An https://fav.farm alternative built on val.town Fork this val to host your own!
HTTP
An <https://fav.farm> alternative built on val.town
Fork this val to host your own!
if (import.meta.main) {
Deno.serve(fav);
export function fav(request: Request) {
const url = new URL(request.url);
if (url.pathname === "/")
return new Response(
String.raw`
<!DOCTYPE html>
htmlDemo
@ije
An interactive, runnable TypeScript val by ije
HTTP
/** @jsx h */
import { h, html } from "https://esm.town/v/ije/html";
export default () => {
return html(
<div class="flex items-center justify-center w-screen h-screen">
<p class="text-5xl font-bold text-green-600">Hello World!</p>
</div>,
githubactivity
@ejfox
// This approach uses the GitHub API without authentication, which is subject to rate limiting.
HTTP
// This approach uses the GitHub API without authentication, which is subject to rate limiting.
// We'll fetch and process the GitHub activity data, and render it as a nicely designed website
// using Vue for templating and Tailwind for styling.
// Tradeoff: May hit rate limits, but doesn't require setting up a personal access token.
const GITHUB_USERNAME = "ejfox";
async function fetchGitHubEvents(username: string) {
const response = await fetch(`https://api.github.com/users/${username}/events/public`, {
headers: {
"User-Agent": "Val-Town-Script",
if (!response.ok) {
valle_tmp_99498691417249546719413191646675
@janpaul123
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
HTTP
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
export default async function(req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const htmlResponse = `
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
val_Jb9ea0ARji
@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;
valle_tmp_3281791973083323415470267124650072
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
administrativePlumSnipe
@raykooyenga
// import * as http from "npm:http";
Script
// import * as http from "npm:http";
var http = require("node:http");
// var http = require('http');
http.createServer(function(request, response) {
response.writeHead(200);
response.write(JSON.stringify(request.headers));
response.end();
}).listen(8080);
val_DxjKDGJFD8
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_DxjKDGJFD8(req) {
try {
// Create a function from the provided code and execute it
const userCode = async () => {
return const findPrimes = (n) => {
const primes = [];
for (let i = 2; i < n; i++) {
let isPrime = true;
for (let j = 2; j <= Math.sqrt(i); j++) {
if (i % j === 0) {
errorHandler
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
window.addEventListener("error", e => {
window.parent.postMessage(e, "val.town")
window.parent.postMessage(e, "*")
short
@kiven
// Forked from @tmcw.short
Express (deprecated)
export let short = async (req, res) => {
const param = req.path.substring(1);
const { default: Hashids } = await import("npm:hashids");
const H = new Hashids(short_storage.salt);
if (!param) {
const { default: htm } = await import("npm:htm");
const { default: vhtml } = await import("npm:vhtml");
const html = htm.bind(vhtml);
if (req.method === "GET") {
return res.send(html`<html><head><title>URL Shortener</title>