22
23```js
24function updateFeedback(ref) {
25 let feedback = [...document.getElementsByTagName('a')].find(e => e.innerText == 'Feedback')
26 feedback.setAttribute('href', "https://stevekrouse-docfeedbackform.web.val.run/?ref=" + ref)
30```
31
32Finally, you may be wondering why I queue up feedback in `@stevekrouse.docsFeedback`, a private JSON val, and then process it via [`@stevekrouse.formFeedbackAlert`](https://www.val.town/v/stevekrouse.formFeedbackAlert) instead of sending it along to Discord directly in this val. I [tried that originally](https://www.val.town/v/stevekrouse.docFeedbackForm?v=61) but it felt too slow to wait for the API call to Discord before returning the "Thanks for your feedback" message. This is where the `context.waitUntil` method (that Cloudflare workers and Vercel Edge Functions support) would really come in handy – those allow you to return a Response, and then continue to compute. Currently Val Town requires you to stop all compute with the returning of your Response, so the only way to compute afterwards is to queue it up for another val to take over, and that's what I'm doing here.
33
34
1Migrated from folder: openai_function_calling/counterfeitPrompt
11```typescript
12const myGithubWebhook = (req: Request) => {
13 const {verify} = @karfau.SignatureCheck(); // you have to call it to get the verify function!
14 const body = await req.text();
15 const signature = req.headers.get("X-Hub-Signature-256");
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts
10```
11
12~/.config/fish/functions/fish_greeting.fish to pick a random line on new fish shell; other shell support left to the reader
13```fish
14function fish_greeting
15 set line (random 1 (cat ~/.motd | wc -l))
16 awk "NR==$line" ~/.motd | fold -s -w (tput cols)
1# Get the day of week name
2
3JavaScript's [`Date.prototype.getDay()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay) returns a number that represents the day of the week, `0` for Sunday, `1` for Monday, etc. This function returns the name of the week, ie `"Sunday"`, `"Monday"`, etc.
4
5The function optionally inputs a `Date` object, but will default to the current time if none is provided.
6
7Migrated from folder: Archive/getDayName
2(Ignores any untitled vals, since those are sometimes created as an execution context.)
3
4By passing a function as the first argument you receive all references as arguments, and can pick or transform them, e.g.
5- [@karfau.refToValUrl](https://val.town/v/karfau.refToValUrl)
6
2Deletes a specific val.
3
4Pass your API token as a secret to the function. Read more about [authentication](https://docs.val.town/api/authentication) to understand how to generate a token and save it as a secret.
5
6Migrated from folder: docs/api/deleteValExample
5It is extracted into a val to avoid having all that clutter in the same val as your tests.
6
7Each test is a named function (which can be async), the name is used as the name for the test.
8- the input passed as the first argument is passed to each test, great for importing assertion methods, stubs, fixed values, ... everything that you do not mutate during a test
9- if a function is async (it returns a promise) there is a timeout of 2 seconds before the test is marked as failed.
10- all tests are called in the declared order, but async tests run in parallel afterwards, so don't assume any order
11- if a test starts with `skip` it is not executed
13- if all tests pass it returns the output, so it appears in the grey box and the evaluation/run is marked green.
14
15Note: If you are using the test runner to store the result in that val, as described above, it is considered a "JSON val" and has a run button, but it also means that another of your vals could update the val with just any other (JSON) state. Alternatively you can define a function val that calls the test runner and have a separete val to keep the curretn test results, but it means after updating the tests you need to fest save that val and then reevaluate to val storing the test state.
16
17Migrated from folder: testing/testRunner
1# This Val URL
2
3Returns the URL of the val that calls this function.
4
5See https://www.val.town/v/neverstew.thisValUrlExample
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",