stevekrouse
Inspector to browser json data in HTTP vals
Example: https://val.town/v/stevekrouse/weatherDescription
Thanks @mmcgrana (https://markmcgranaghan.com/) for the idea!
Blob Admin
This is a lightweight Blob Admin interface to view and debug your Blob data.
Use this button to install the val:
It uses basic authentication with your Val Town API Token as the password (leave the username field blank).
TODO
-
/new
- render a page to write a new blob key and value -
/edit/:blob
- render a page to edit a blob (prefilled with the existing content) -
/delete/:blob
- delete a blob and render success - add upload/download buttons
- Use modals for create/upload/edit/view/delete page (htmx ?)
- handle non-textual blobs properly
- use codemirror instead of a textarea for editing text blobs
Clone of @maxm/staticChess but for Wordle. Every letter is a link. The game state is stored in the URL bar.
You could do silly things like playing collaborative Wordle with your friends by trading links back and forth. Or undo any mistakes by clicking the back button. I also make it easy to generate a new game from any of your current game's guesses – to send to a friend.
They key to these static games like this one and @maxm/staticChess is to figure out:
- a representation for your game state (the
Game
type) - how to encode/decode your game state into the URL (base64-encoding JSON)
- how to render your game state into HTML (looping over guesses and making divs)
- placing the links into your HTML in the right spots (on my on-screen keyboard)
- prettify with CSS (for guesses and the keyboard)
Passkeys Demo
Passkeys are pretty neat! I wanted to get a demo working in Val Town so I ported over https://github.com/maximousblk/passkeys-demo.
One challenge was that the original extensively uses DenoKV store with compound keys and values. I created @stevekrouse/DenoSyntheticKV as a replacement for DenoKV. It uses SuperJSON to encode the keys and values.
You can find the client-side script for the main page here: @stevekrouse/passkey_script
Email with GPT-3
Send an email to stevekrouse.emailGPT3@valtown.email, it will forward it to gpt3, and email you back the response.
dlock - free distributed lock as a service
Usage
API
Acquire a lock.
The id path segment is the lock ID - choose your own.
https://dlock.univalent.net/lock/arbitrary-string/acquire?ttl=60
{"lease":1,"deadline":1655572186}
Another attempt to acquire the same lock within its TTL will fail with HTTP status code 409.
https://dlock.univalent.net/lock/01899dc0-2742-44f9-9c7b-01830851b299/acquire?ttl=60
{"error":"lock is acquired by another client","deadline":1655572186}
The previous lock can be renewed with its lease number, like a heartbeat
https://dlock.univalent.net/lock/01899dc0-2742-44f9-9c7b-01830851b299/acquire?ttl=60&lease=1
{"lease":1,"deadline":1655572824}
Release a lock
https://dlock.univalent.net/lock/01899dc0-2742-44f9-9c7b-01830851b299/release?lease=42
Import a val script in the chrome console
Say you're developing a chrome extension or some other little script and you're iterating in the chrome console. Over time you may write larger pieces of code that you want to save as a group. Or maybe you want to use TypeScript, which isn't supported in browsers natively. Val Town can provide a decent workflow here.
- Save your code in a Script val
- Ensure the val is Public or Unlisted
- In the chrome console, import your val's module url. For example, for this val it would look like this:
Create vallet {test} = await import(`https://esm.town/v/stevekrouse/importValInChromeConsole?${Math.random()}`)
I added a random number to the end of the string to prevent your browser from caching the import. So now you can save in Val Town and then re-run your import line in the Chrome console and the script will re-run in the Chrome console.