Public vals
46
sudoku_solver_human_search
saolsen
sudoku_solver_human_search
// This is another brute force with backtracking approach.
Script
sudoku
saolsen
sudoku
An interactive, runnable TypeScript val by saolsen
Script
sudoku_solver_exact_cover
saolsen
sudoku_solver_exact_cover
Exact Cover sudoku Solver Solves Sudoku puzzles via dancing-links. Pass in a 9x9 Sudoku puzzle array (of arrays) with 0's for empty slots. Returns a solved puzzle or null if the puzzle can't be solved. Example example_val
Script
sudoku_solver_brute_force
saolsen
sudoku_solver_brute_force
Brute Force Sudoku Solver Solves Sudoku puzzles via backtracking search. Pass in a 9x9 Sudoku puzzle array (of arrays) with 0's for empty slots. Returns a solved puzzle or null if the puzzle can't be solved. Example example_val
Script
prune_val
saolsen
prune_val
Prune a val's versions. Useful if you want to delete a bunch of versions. All versions before keep_since that aren't in keep_versions will be deleted !!! You can run it without passing commit to see a preview of what will happen. Example await prune_val("abcdefg", [3,6,8], 12, true); Could output Val: untitled_peachTakin, Current Version: 15 Deleting Versions: [ 1, 2, 4, 5, 7, 8, 9, 10, 11 ] Deleting Version 1 Deleted Deleting Version 2 Deleted Deleting Version 4 Deleted Deleting Version 5 Deleted Deleting Version 6 Deleted Deleting Version 7 Version already deleted, skipping Deleting Version 8 Deleted Deleting Version 9 Deleted Deleting Version 10 Deleted Deleting Version 11 Deleted
Script
htmx_hono_layout
saolsen
htmx_hono_layout
See what a minimal example of a hono + canvas game could look like.
HTTP
sqlite
saolsen
sqlite
This is a wrapper of the val town std sqlite library that adds tracing via https://www.val.town/v/saolsen/tracing.
Script
qstash
saolsen
qstash
Upstash qstash client for vals. Lets you publish and receive qstash messages in vals. To use, set up qstash on Upstash and set the environment variables. QSTASH_TOKEN QSTASH_CURRENT_SIGNING_KEY QSTASH_NEXT_SIGNING_KEY Calls are also traced via https://www.val.town/v/saolsen/tracing so if you use that library you will see linked spans between the publish call and the receive call. For an example of how to use it see https://www.val.town/v/saolsen/try_qstash_publish and https://www.val.town/v/saolsen/try_qstash_receive.
Script
redis
saolsen
redis
Upstash redis client for vals. Creates a global redis instance and exposes functions to use it. To use, create a redis database on Upstash and set the environment variables. UPSTASH_REDIS_REST_URL UPSTASH_REDIS_REST_TOKEN Val.town runs in ohio so the best region to pick for the redis instance is probably us-east-1 . Calls are also traced via https://www.val.town/v/saolsen/tracing so if you use that library you will see timed spans for any redis calls. For an example of how to use it see https://www.val.town/v/saolsen/try_redis
Script
git_sync
saolsen
git_sync
Sync vals to a git repo This will not run on val town! You need to run it locally with deno. Install Deno: https://docs.deno.com/runtime/manual/getting_started/installation Set your val.town api key as an environment variable. https://www.val.town/settings/api export valtown="abcdefgh-ijkl-mnop-qrst-uvwxyz123456" Create a git repo to sync to. mkdir ./valtown && pushd ./valtown && git init && popd Copy down this script and run it, passing the path to your git directory. deno run -A ./git_sync.ts ./valtown There is currently no incremental syncing or recovering. You can only use this script against a fresh git repo. If you want to sync to an existing repo, you should create a new repo, run the script and then force push to your existing repo. This will sync all your vals, including private ones so be careful where you push your git repo if you want those to remain private.
Script
p5
saolsen
p5
P5 sketch Easily turn a p5.js sketch into a val. See https://www.val.town/v/saolsen/p5_sketch for an example. Usage Make a p5 sketch, you can import the p5 types to make it easier. import type * as p5 from "npm:@types/p5"; Export any "global" p5 functions. These are functions like setup and draw that p5 will call. Set the val type to http and default export the result of sketch , passing in import.meta.url . A full example looks like this. import type * as p5 from "npm:@types/p5"; export function setup() { createCanvas(400, 400); } export function draw() { if (mouseIsPressed) { fill(0); } else { fill(255); } ellipse(mouseX, mouseY, 80, 80); } import { sketch } from "https://esm.town/v/saolsen/p5"; export default sketch(import.meta.url); How it works The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default sketch export) so you can't call any Deno functions, environment variables, or other server side apis.
Script
p5_sketch
saolsen
p5_sketch
Example p5 sketch Shows a simple example of how to use https://www.val.town/v/saolsen/p5
HTTP
wabt_import
saolsen
wabt_import
An interactive, runnable TypeScript val by saolsen
Script
plausible
saolsen
plausible
Plausible analytics Call track with the domain you set up in plausible and the request. I've been using saolsen.val-name . Note that there is no auth for the plausible events API, so if somebody forks the val it'll still work but track all their val page loads in your dashboard which is kinda weird but also kinda cool, idk. See https://www.val.town/v/saolsen/plausible_example for how to use.
Script
changes
saolsen
changes
View val changes as a diff. Go to /v/username/valname/version to see a diff between that version and the previous one. For example https://saolsen-changes.web.val.run/v/saolsen/tracing/108
HTTP
example_rust_http_val
saolsen
example_rust_http_val
Built from https://gist.github.com/saolsen/294683088bae9a8f9a8cf93e2b392729 See https://gist.github.com/saolsen/d273bb1baba5e912e4dc2b187511affa for how to build a rust val. See https://www.val.town/v/saolsen/use_example_rust_http_val for how to use this.
Script