Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
valle_tmp_1232975987134350426195802232196885
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
// Set these to your own
const username = "janpaul123";
const tempValsParentFolderId = "4bb7b010-4443-11ef-8642-de64eea55b61";
const valTownToken = Deno.env.get("valtown");
const vt = new ValTown({ bearerToken: valTownToken });
const app = new Hono();
const jsxResponse = (jsx) => {
return new Response(renderToString(jsx), { headers: { "Content-Type": "text/html" } });
const systemprompt = `The conversation below is your recent interaction with the user.
jesusgollonet avatar
socialMetaTest
@jesusgollonet
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
export default async function(req: Request) {
const description = "social meta test";
const title = "JGB Test";
const image = "https://jesusgollonet.com/images/social/back-to-blocked.png";
return new Response(
renderToString(
<html>
<head>
<meta charSet="UTF-8" />
roadlabs avatar
valleGetValsContextWindow
@roadlabs
An interactive, runnable TypeScript val by roadlabs
Script
const cacheBlobKey = "getValsContextWindowCache3";
export default async function getValsContextWindow(model: any) {
const fullCacheBlobKey = `${cacheBlobKey}-${model}`;
const cached = await blob.getJSON(fullCacheBlobKey);
if (cached) {
return cached;
const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
const API_URL = "https://api.val.town";
const sections = [
name: "Imports",
whatrocks avatar
testing_secrets
@whatrocks
An interactive, runnable TypeScript val by whatrocks
Script
import process from "node:process";
export const testing_secrets = (async () => {
let testy = process.env.my_secret;
console.log("12345");
stevekrouse avatar
umbrellaReminder
@stevekrouse
☔️ Umbrella reminder if there's rain today Setup Fork this val 👉 https://val.town/v/stevekrouse.umbrellaReminder/fork Customize the location (line 8). You can supply any free-form description of a location. ⚠️ Only works for US-based locations (where weather.gov covers). How it works Geocodes an free-form description of a location to latitude and longitude – @stevekrouse.nominatimSearch Converts a latitude and longitude to weather.gov grid – @stevekrouse.weatherGovGrid Gets the hourly forecast for that grid Filters the forecast for periods that are today and >30% chance of rain If there are any, it formats them appropriately, and sends me an email
Cron
# ☔️ Umbrella reminder if there's rain today
![Screenshot 2023-09-14 at 12.31.32.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/d82916ca-f8d9-4b49-88c6-420ab67a770
## Setup
1. Fork this val 👉 https://val.town/v/stevekrouse.umbrellaReminder/fork
2. Customize the `location` (line 8). You can supply any free-form description of a location.
⚠️ Only works for US-based locations (where weather.gov covers).
export const umbrellaReminder = async (arg) => {
if (arg.method) return Response.json("");
let location = "prospect heights, brooklyn"; // <---- customize this line
let [{ lat, lon }] = await nominatimSearch({
pomdtr avatar
extractImports
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
export function extractImports(code: string): string[] {
const sourceFile = ts.createSourceFile(
"val.ts",
code,
ts.ScriptTarget.Latest,
const imports = [];
function visitNode(node: ts.Node) {
if (ts.isImportDeclaration(node)) {
const importClause = node.importClause;
if (importClause) {
tempguy avatar
amberPig
@tempguy
An interactive, runnable TypeScript val by tempguy
Script
const nanoid = customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10);
const baseUrl = "https://d000d.com";
export async function doodstream(ctx: Context) {
let url = ctx.url;
if (ctx.url.includes("primewire")) {
const request = await fetch(ctx.url);
const id = url.split("/d/")[1] || url.split("/e/")[1];
const doodDataReq = await fetch(
`https://structural-sidonia-supergalaxy-4284f8da.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=`
+ encodeURIComponent(`${baseUrl}/e/${id}`),
stevekrouse avatar
TodoApp
@stevekrouse
SSR React Mini & SQLite Todo App This Todo App is server rendered and client-hydrated React. This architecture is a lightweight alternative to NextJS, RemixJS, or other React metaframeworks with no compile or build step. The data is saved server-side in Val Town SQLite . SSR React Mini Framework This "framework" is currently 44 lines of code, so it's obviously not a true replacement for NextJS or Remix. The trick is client-side importing the React component that you're server rendering . Val Town is uniquely suited for this trick because it both runs your code server-side and exposes vals as modules importable by the browser. The tricky part is making sure that server-only code doesn't run on the client and vice-versa. For example, because this val colocates the server-side loader and action with the React component we have to be careful to do all server-only imports (ie sqlite) dynamically inside the loader and action , so they only run server-side.
HTTP (deprecated)
# SSR React Mini & SQLite Todo App
This Todo App is server rendered *and* client-hydrated React. This architecture is a lightweight alternative to NextJS, Remix
![demo](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/3bbc3a39-9017-4a95-797b-2f205aa57f00/public)
## SSR React Mini Framework
This ["framework"](https://www.val.town/v/stevekrouse/ssr_react_mini) is currently 44 lines of code, so it's obviously not a
The trick is [client-side importing](https://www.val.town/v/stevekrouse/ssr_react_mini?v=53#L30) the React component that you
/** @jsxImportSource https://esm.sh/react */
export async function loader(req: Request) {
const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
const [, { columns, rows }] = await sqlite.batch([
effector avatar
patronum
@effector
An interactive, runnable TypeScript val by effector
Script
export async function patronum() {
const patronum = await import("https://esm.sh/patronum@1.19.1");
return patronum;
nbbaier avatar
gptTag
@nbbaier
// a test comment for vt-backup
Script
// a test comment for vt-backup
// another test comment for vt-backup
async function getOpenAI() {
// if you don't have a key, use our std library version
if (Deno.env.get("OPENAI_API_KEY") === undefined) {
const { OpenAI } = await import("https://esm.town/v/std/openai");
return new OpenAI();
} else {
const { OpenAI } = await import("npm:openai");
return new OpenAI();
todimech avatar
sqliteExplorerApp
@todimech
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 (v81) 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 (deprecated)
# SQLite Explorer
View and interact with your Val Town SQLite data. It's based off Steve's excellent [SQLite Admin](https://www.val.town/v/stev
![image.webp](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/c8e102fd-39ca-4bfb-372a-8d36daf43900/public)
## Install
Install the latest stable version (v81) by forking this val:
[![Install Stable Release (v81)](https://stevekrouse-button.express.val.run/Install%20Stable%20Release%20(v81))](https://www.
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
EditorSection,
MockTable,
Separator,
mmrech avatar
coffeeMongoose
@mmrech
An interactive, runnable TypeScript val by mmrech
HTTP (deprecated)
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
}<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//www.opencpu.org/js/archive/opencpu-0.4.js"></script>
stevekrouse avatar
switchbot_party
@stevekrouse
Switchbot Party We hosted a party in the Val Town office and I texted a link to this site to all guests: You can see a demo here: https://x.com/stevekrouse/status/1819018859099132128 After the party was over, I commented out the lines that open the door so folks can't use it anymore.
HTTP (deprecated)
# Switchbot Party
We hosted a party in the Val Town office and I texted a link to this site to all guests:
![Screenshot 2024-08-05 at 12.30.16@2x.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/120a1c41-bedb-4bda-568d-2c0913d4
You can see a demo here: https://x.com/stevekrouse/status/1819018859099132128
After the party was over, I commented out the lines that open the door so folks can't use it anymore.
/** @jsxImportSource npm:hono/jsx */
const app = new Hono();
const ValTownGroundFloorDeviceId = "D2353438164D";
const ValTownOfficeDeviceId = "CD6F3A810848";
async function switchbotRequest(path, args) {
horatiothomas avatar
dot_com
@horatiothomas
stevekrouse.com - my personal website This val hosts my personal website. The view data is stored in Val Town SQLite - @std/sqlite. It used to live on Github Pages, which is why I proxy over requests to certain blog posts over to the Github Pages site still. Todos [ ] Speed up page load by loading sqlite data later like in @healeycodes/steve_web [ ] Store more (legally storable) analytics data, and maybe make a sparkline! [ ] Add some sort of way to contact me [ ] Move over all my blog posts from Github Pages (maybe into @std/blob as a CMS?)
HTTP (deprecated)
# stevekrouse.com - my personal website
This val hosts my personal website. The view data is stored in Val Town SQLite - @std/sqlite.
It used to live on Github Pages, which is why I proxy over requests to certain blog posts over to the Github Pages site still
## Todos
- [ ] Speed up page load by loading sqlite data later like in @healeycodes/steve_web
- [ ] Store more (legally storable) analytics data, and maybe make a sparkline!
/** @jsxImportSource https://esm.sh/react */
const linkClass = "text-blue-500 hover:underline";
const Link = (
{ children, href }: {
janpaul123 avatar
valle_tmp_7848874273078958552804771654705
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP (deprecated)
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_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: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),