Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=1720&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 17289 results for "function"(1679ms)

docFeedbackFormREADME.md2 matches

@stevekrouse•Updated 1 year ago
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

counterfeitPromptREADME.md1 match

@jdan•Updated 1 year ago
1Migrated from folder: openai_function_calling/counterfeitPrompt

SignatureCheckREADME.md1 match

@karfau•Updated 1 year ago
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");

getWeatherREADME.md1 match

@stevekrouse•Updated 1 year ago
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts

harpersREADME.md2 matches

@visnup•Updated 1 year ago
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)

getDayNameREADME.md2 matches

@stevekrouse•Updated 1 year ago
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

mainReferenceREADME.md1 match

@karfau•Updated 1 year ago
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

deleteValExampleREADME.md1 match

@neverstew•Updated 1 year ago
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

testRunnerREADME.md3 matches

@karfau•Updated 1 year ago
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

thisValUrlREADME.md1 match

@neverstew•Updated 1 year ago
1# This Val URL
2
3Returns the URL of the val that calls this function.
4
5See https://www.val.town/v/neverstew.thisValUrlExample

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
lost1991
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": "*",