Avatar

rawwerks

Joined December 15, 2024
Likes
13
stevekrouse avatar
stevekrouse
getShowcaseVals
Script
Get vals that were created in the last month, augmented with all sorts of AI and screenshots, and shoved in a sqlite database for @stevekrouse/showcase.
1
jxnblk avatar
jxnblk
gitHubSync
HTTP
GitHub Sync Sync vals from Val Town to GitHub and back What it does Using a fork of this val, you can specify a list of your own vals to export to a GitHub repo. Log in to the web app rendered by this val to manually click the Export button, which will read the contents of your vals and commit those vals as files to your GitHub repo. If you set up your repo to use the webhook in this val, any changes pushed to the GitHub repo will be synced back to the vals in your list. How to use Fork this val Create a new repo on GitHub for syncing your vals to (it can be public or private as long as you use the appropriate token scope) Add a webhook to your repo that points to your val's /webhook route, e.g. https://jxnblk-githubsync.web.val.run/webhook Create a Secret for your webhook In your Val Town Settings , add that same secret as GHSYNC_WEBHOOK_SECRET On GitHub, create a new GitHub OAuth app Use your val's web URL for the Homepage URL Set your val's /auth route as the Authorization callback URL , e.g. https://jxnblk-githubsync.web.val.run/auth Copy your new OAuth app's Client ID and add that as the GHSYNC_CLIENT_ID env var in Val Town Create and copy a Client Secret and add that as the GHSYNC_CLIENT_SECRET env var in Val Town On GitHub, create a new personal access token Ensure the token has read access to Contents for your repo Copy the access token and add that as the GHSYNC_GITHUB_TOKEN env var in Val Town In your val, edit the config in the val to point to your repo's owner and repo Edit the valNames list to include the name of the vals you'd like to sync to the repo In your val's Settings , ensure that under Permissions , Vals has Read & Write access Open your val's web URL in a new tab and click Log in with GitHub You should see a page listing your vals to be exported and the GitHub repo to sync to (if not, see below ) Click the Export button to sync your vals to the GitHub repo. This can take a moment and you'll need to wait for the browser request to complete. Once your vals are in the GitHub repo, edit them on GitHub or push changes to ensure that the webhook is working. You can check the Requests and Logs tabs for your val to debug any errors Demo This val is synced to GitHub: gitHubSyncDemoVal This is the GitHub repo: jxnblk/valtown-github-sync Troubleshooting If after logging in, you see a How to use GitHub Sync page, ensure that the config.owner in your val matches your GitHub username If the webhook doesn't work, ensure you have the webhook properly configured in the GitHub repo and that the GHSYNC_WEBHOOK_SECRET env var in Val Town matches the value in your GitHub repo. Additional Features The following list are ideas for how to improve this val. Feel free to implement some of these ideas. I would consider accepting pull requests for these features. [ ] Check timestamps on Val Town and GitHub to prevent syncing when an older version would overwrite a newer one [ ] Add an authenticated webhook to sync from Val Town to GitHub (e.g. a Cron val could trigger export to keep vals synced) [ ] A "No-UI" version of this will only webhooks (authentication would need to be considered)
6
stevekrouse avatar
stevekrouse
exa
Script
Forked from yawnxyz/exa
1
stevekrouse avatar
stevekrouse
cerebras_coder
HTTP
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
42
yawnxyz avatar
yawnxyz
hnCloneOAuth
Script
An interactive, runnable TypeScript val by yawnxyz
2
iamseeley avatar
iamseeley
multirouteSvelte
HTTP
๐ŸŒ Multi-Route Website with Svelte
1
pomdtr avatar
pomdtr
lastloginExample
HTTP
An interactive, runnable TypeScript val by pomdtr
2
pomdtr avatar
pomdtr
lastlogin
Script
Lastlogin Authentication for val.town Looking for an hono integration ? See @pomdtr/lastloginHono Support login in trough: Email Link QR Code Google Oauth Github Oauth Gitlab Oauth Facebook Oauth Demo You can try a demo at https://pomdtr-lastloginhonoexample.web.val.run (see @pomdtr/lastLoginHonoExample for code) Usage Wrap your http handlers in a lastlogin middleware (sessions will be persisted in the lastlogin_session table on your sqlite account). If you want to be the only one able to access your val, you can use @pomdtr/verifyUserEmail. import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { // check that the user email match your val town email verifyEmail: verifyUserEmail }); If you want to customize how is allowed to signup, you can set the verifyEmail option: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { verifyEmail: (email) => { email == "steve@valtown" } }); You can allow anyone to signup by returning a boolean from the verifyEmail function: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { verifyEmail: (_email) => true }); Public Routes import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail"; export default lastlogin(() => { return new Response("Hi!"); }, { verifyEmail: verifyUserEmail, public_routes: ["/", "/public/*"], }); See the URLPattern API for reference. Logout Just redirect the user to /auth/logout
10
pomdtr avatar
pomdtr
extractValInfo
Script
Extract vals infos (author, name, version) from a val url (either from esm.town or val.town ). Example usage: const {author, name} = extractValInfo(import.meta.url) Also returns a unique slug for the val: <author>/<name>
15
stevekrouse avatar
stevekrouse
cors_example
HTTP
CORS issues are the bane of frontend engineers. In Val Town, if you don't customize any CORS headers, we add these defaults: Access-Control-Allow-Origin: "*" Access-Control-Allow-Methods: "GET,HEAD,PUT,PATCH,POST,DELETE" You can override them if you wish to disallow CORS. This val is a client-side-rendered React app that makes requests to @stevekrouse/cors_example_backend. The backend is in a different val because CORS applies to requests on different domains. The backend has examples of the default permissive CORS behavior and disabled CORS.
1
stevekrouse avatar
stevekrouse
twitterAlert
Cron
Twitter/๐• keyword alerts Custom notifications for when you, your company, or anything you care about is mentioned on Twitter. If you believe in Twitter/๐•-driven development, you want to get notified when anyone is talking about your tech, even if they're not tagging you. To get this Twitter Alert bot running for you, fork this val and modify the query and where the notification gets delivered. 1. Query Change the keywords for what you want to get notified for and the excludes for what you don't want to get notified for. You can use Twitter's search operators to customize your query, for some collection of keywords, filtering out others, and much more! 2. Notification Below I'm sending these mentions to a public channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever. Twitter Data & Limitations The Twitter API has become unusable. This val gets Twitter data via SocialData , an affordable Twitter scraping API. In order to make this val easy for you to fork & use without signing up for another API, I am proxying SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy 100 times per day, so be sure not to set this cron to run more than once every 15 min. If you want to run it more, get your own SocialData API token and pay for it directly.
4
Next