Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
dateme_home_react
@stevekrouse
@jsxImportSource https://esm.sh/react@18.2.0
Script
import { useEffect, useState } from "https://esm.sh/react@18.2.0";
async function getCurrentPosition(opts): Promise<GeolocationPosition> {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject, opts);
async function reverseGeocodeNominat(lat, lng) {
const url = `https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}&zoom=13`;
return json;
export default function Home() {
const [locationName, setLocationName] = useState("");
saolsen avatar
connect4_site
@saolsen
Play connect4. Write agents that play connect4. Battle your agents against other agents. It's fun.
HTTP
function matchid(): MatchId {
async function get_match(id: MatchId): Promise<Match | null> {
async function save_match_record(match: Match): Promise<void> {
async function save_match_status(match: Match): Promise<void> {
async function save_match(match: Match): Promise<void> {
async function list_matches(): Promise<MatchStatus[]> {
function new_match(blue_player: Player, red_player: Player): Match {
function take_turn(match: Match, action: connect4.Action): Turn | TurnError {
function error_turn(match: Match, player: number, error: Error): Turn {
function create_match_form(create_match: CreateMatch) {
stevekrouse avatar
cooperativeBronzeWildcat
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP
import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
function App() {
const [prompt, setPrompt] = useState("hello llamapalooza");
>(null);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
</div>
function client() {
createRoot(document.getElementById("root")!).render(<App />);
client();
function extractCodeFromFence(text: string): string {
const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
return htmlMatch ? htmlMatch[1].trim() : text;
export default async function server(req: Request): Promise<Response> {
if (req.method === "POST") {
dhvanil avatar
val_FTRpMzznMJ
@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;
let lowestThreeDigit;
gwoods22 avatar
scraper_template
@gwoods22
Website Scraper Template A basic website scraper template that can be ran on an interval to check for changes. It uses blob storage to save whatever data you'd like to compare the website to. Uses my sendNotification val to alert yourself of the change. Steps to use Add the scrapeURL you would like to scrape and pick a name for your blob storage blobKey . Change the "selector" value to fit your needs. cheerio is used to find the part of the page you'd like to check. Adjust the if statement to detect changes and update your blob Craft a message to be sent with sendNotification() function
Script
3. Adjust the if statement to detect changes and update your blob
4. Craft a message to be sent with `sendNotification()` function
erosai avatar
aqi
@erosai
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI";
export async function aqi(interval: Interval) {
const location = "prishtina"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
JamesAndrew avatar
codecommenter
@JamesAndrew
Code Commenter Code Commenter is a web application that automatically adds concise and useful comments to your code using OpenAI's language model. It supports JavaScript, TypeScript, and C# languages. Features Two-panel interface: Input code on the left, view commented code on the right Language selection: Choose between JavaScript, TypeScript, and C# Syntax highlighting: Commented code is displayed with proper syntax highlighting Loading indicator: A spinner animation shows when the AI is processing your code Responsive design: The app adjusts to fit various screen sizes How It Works The user pastes their code into the left panel The user selects the appropriate language from the dropdown menu When the "Add Comments" button is clicked, the code is sent to the server The server uses OpenAI's API to generate comments for the code The commented code is returned and displayed in the right panel with syntax highlighting Technology Stack Frontend: React: For building the user interface Prism.js: For syntax highlighting Backend: Deno: Runtime environment Val Town: Hosting platform OpenAI API: For generating code comments Usage Open the application in your web browser Paste your code into the left panel Select the appropriate language from the dropdown menu Click the "Add Comments" button Wait for the AI to process your code (a spinner will indicate that it's working) View the commented code in the right panel Limitations The maximum length of code that can be processed is limited by the OpenAI API's token limit The quality of comments may vary depending on the complexity of the code and the AI model's capabilities Internet connection is required to use the application Privacy Considerations Please note that the code you submit is sent to OpenAI's servers for processing. Do not submit sensitive or proprietary code that you don't want to be processed by a third-party service. Future Improvements Add support for more programming languages Implement user authentication for personalized experiences Add the ability to save and share commented code snippets Improve error handling and user feedback Feedback and Contributions This project is hosted on Val Town. If you have any suggestions, bug reports, or want to contribute to the project, please contact the Val Town team or the val's creator.
HTTP
ation that automatically adds concise and useful comments to your code using OpenAI's language model. It supports JavaScript,
4. The server uses OpenAI's API to generate comments for the code
- OpenAI API: For generating code comments
- The maximum length of code that can be processed is limited by the OpenAI API's token limit
Please note that the code you submit is sent to OpenAI's servers for processing. Do not submit sensitive or proprietary code
function App() {
export default async function server(request: Request): Promise<Response> {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
healeycodes avatar
measureValTownE2e
@healeycodes
// E.g. from a user's perspective (not the real execution time!)
Script
userFuncTimes.push(Date.now() - start);
console.log(
`average e2e user function time: ${(
userFuncTimes.reduce((a, b) => a + b, 0) / count
).toFixed(0)}ms (fastest was ${userFuncTimes
stevekrouse avatar
jsPython
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { jsPython } from "npm:jspython-interpreter";
const script = `
def mapFunction(r, i):
v = r * i
return v
x = [1, 2, 3, 4]
x
.map(mapFunction)
.filter(r => r * r)
.join(",")
all avatar
townGen
@all
townGen [[https://www.val.town/v/all/promptGen]] [[https://www.val.town/v/stevekrouse/valwriter]] Note : It looks like openai enhancement was dropped at some point when adding all the gizmos;
HTTP
- _Note_: It looks like openai enhancement was dropped at some point when adding all the gizmos;
* When submitted, it now iterates step by step in a tree structure on features for main functionality.
* Sub-functionalities are now listed under the main functionality to help describe it better.
"azure-functions",
function App() {
const subFunctionalities = generateSubFunctionalities(idea);
1. Main functionality: ${idea}
Sub-functionalities:
${subFunctionalities.map(sub => ` - ${sub}`).join("\n")}
"Implement main functionality logic",
const generateSubFunctionalities = (mainIdea: string) => {
zerovox avatar
readwiseHighlights
@zerovox
https://readwise.io/api_deets Not sure how to convert from a reader ID (string) to a readwise ID (number)
Script
export async function readwiseHighlights(token: string, ids?: number[]) {
let fullData = [];
let nextPageCursor = null;
maemoon avatar
labLogin
@maemoon
An interactive, runnable TypeScript val by maemoon
HTTP
import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts";
import { sqlite } from "https://esm.town/v/std/sqlite";
export default async function(req: Request): Promise<Response> {
const body = await req.json();
let { username, password } = body;
stevekrouse avatar
opengraphImageCreator
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP
angle?: number;
function App() {
const [backgroundImage, setBackgroundImage] = useState<string | null>(null);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
janpaul123 avatar
valle_tmp_228422435641258538528486008331893
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_realistic_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
turbo1912 avatar
supir
@turbo1912
@jsxImportSource https://esm.sh/react
Cron
import fal from "npm:@fal-ai/serverless-client";
import { renderToString } from "npm:react-dom/server";
export default async function(interval: Interval) {
const result = await fal.subscribe("fal-ai/supir", {
input: {
โ€ฆ
139
โ€ฆ
Next