Avatar

boson

Joined October 16, 2023
Likes
22
kingishb avatar
blackLobster
@kingishb
Cron
Send a weekly email digest of good times to go for a bike ride.
std avatar
blob
@std
Script
Blob Storage - Docs ↗ Val Town comes with blob storage built-in. It allows for storing any data, like text, JSON, or images. You can access it via std/blob . Blob storage is scoped globally to your account. If you set a blob in one val, you can retrieve it by the same key in another val. It's backed by Cloudflare R2. You may find this admin viewer helpful for viewing and editing your blobs. Get JSON import { blob } from "https://esm.town/v/std/blob"; let blobDemo = await blob.getJSON("myKey"); console.log(blobDemo); // returns `undefined` if not found Set JSON import { blob } from "https://esm.town/v/std/blob"; await blob.setJSON("myKey", { hello: "world" }); List keys import { blob } from "https://esm.town/v/std/blob"; let allKeys = await blob.list(); console.log(allKeys); const appKeys = await blob.list("app_"); console.log(appKeys); // all keys that begin with `app_` Delete by key import { blob } from "https://esm.town/v/std/blob"; await blob.delete("myKey"); Examples Counter RSS Notifications (saving the last run time) Picture: Save & Read Error Handling blob.get can throw ValTownBlobNotFoundError Any method can throw ValTownBlobError for unexpected errors. Utilities Our Blob SDK also includes some utility functions to make working with blobs easier. Copy import { blob } from "https://esm.town/v/std/blob"; await blob.copy("myKey", "myKeyCopy"); Move import { blob } from "https://esm.town/v/std/blob"; await blob.move("myKey", "myKeyNew"); Lower-level API We provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level. async get(key: string) : Retrieves a blob for a given key. async set(key: string, value: string | BodyInit) : Sets the blob value for a given key. See BodyInit . Limitations Blob-stored data counts towards your total Val Town storage – 10mb on the free plan and 1gb on pro. Check our pricing page to learn more. Keys for blobs can be up to 512 characters long. 📝 Edit docs
stevekrouse avatar
forwarder
@stevekrouse
Email
Forked from maas/forwarder
stevekrouse avatar
gpt4Example
@stevekrouse
Script
GPT4 Example This uses the brand new gpt-4-1106-preview . To use this, set OPENAI_API_KEY in your Val Town Secrets .
stevekrouse avatar
emojiSearchBot
@stevekrouse
Cron
Forked from andreterron/actuallyItsXBot
stevekrouse avatar
gpt4vDemo
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
mcgrady20150318 avatar
searchArXiV
@mcgrady20150318
HTTP (deprecated)
Forked from aleaf/searchArXiV
hurricanenate avatar
webscrapeBareBonesTiki
@hurricanenate
Cron
Check Bare Bones Tiki to see when their sea light swizzles become available.
yeskunall avatar
hnLatestJobs
@yeskunall
Cron
// Get upto (200) of the latest jobs posted on HN
supersayan avatar
getAllVideosInYoutubePlaylist
@supersayan
Script
Get All Videos in a Youtube Playlist using the Youtube Data API v3 Reference: https://developers.google.com/youtube/v3/docs/playlistItems/list
tmcw avatar
nyChargingStations
@tmcw
HTTP (deprecated)
NYC Charging Stations Data Analysis https://tmcw-nychargingstations.web.val.run/ This analyzes some open data about electric car charging stations in New York State and bakes a website from it. Data is messy!
stevekrouse avatar
umbrellaReminder
@stevekrouse
Cron
☔️ 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
std avatar
turso
@std
Script
Deprecated in favor of std/sqlite (also powered by Turso) std/turso was the initial version of our integration with Turso. It was so popular, we rebuilt it to be faster and easier to use: std/sqlite . Turso is a serverless SQLite platform designed for the edge. It runs libSQL , their open contribution fork of SQLite. Every Val Town user automatically gets their own Turso SQLite database! It's great for >100kb data (ie bigger than a val) or when you need SQL: relations, ACID transactions, etc. Storage used in Turso will count against your Val Town total storage (10mb for free users; 1gb for Pro users). Contact us if you'd need more – it should be no problem! Getting started This val uses our public key auth scheme . Generate your keypair On your publicKey click the lock icon🔒 to change the permissions to Unlisted . Fork this helper function replacing stevekrouse with your own username Try out some queries! Usage This val returns a Turso SDK's Client , which supports execute , batch , and transaction . await @me.turso().execute(`create table blobs( key text unique, value text )`) More example usage Architecture This @std.turso function is the client or SDK to @std.tursoAPI, which acts as a "proxy" to Turso. It handles authentication, creates databases, and forwards on your SQL queries. You can get lower latency (~200ms vs ~800ms), more storage, databases, CLI & API access by having your own Turso account.
stevekrouse avatar
planesAboveMe
@stevekrouse
Script
Planes Above Me Inspired by https://louison.substack.com/p/i-built-a-plane-spotter-for-my-son A little script that grabs that planes above you, just change line 4 to whatever location you want and it'll pull the lat/log for it and query.
stevekrouse avatar
discordChannel
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
tmcw avatar
blocks
@tmcw
Express
Unfancy blocks In the old days, there was a website called bl.ocks.org which re-hosted content on GitHub Gists and displayed visualizations made in those gists. It wasn't shiny but it was well-crafted and for the little community that used it, it was very nice. This is a much worse, but very small, version of the same kind of program. This also shows you stuff from blocks. It displays readmes, with Titus's lovely micromark . It uses Ian's collected search index of bl.ocks.org to show you examples and thumbnails. It uses Alpine to pull together a little interface. And, of course, Val Town to make it all work.