Back to APIs list

Github API examples & templates

Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
karfau avatar
karfau
chai
Script
// @deno-types="https://unpkg.com/@types/chai/index.d.ts"
0
wangqiao1234 avatar
wangqiao1234
OpenAI
HTTP
Forked from std/openai
0
maxm avatar
maxm
imageMagickWasmExample
Script
Val Town implementation of the magick-wasm demo: https://github.com/dlemstra/magick-wasm/blob/main/demo/demo.ts Outputs: ImageMagick 7.1.1-30 Q8 x86_64 dd459b01f:20240407 https://imagemagick.org Delegates: freetype heic jng jp2 jpeg jxl lcms lqr openexr png raw tiff webp xml zlib Features: Cipher Quantum: 8 GIF 100x75 8-bit sRGB 2679
0
austinm911 avatar
austinm911
scheduledNotifier
Cron
Forked from pranjaldotdev/poller
0
maxm avatar
maxm
tinygoWasmHelloWorld
HTTP
Tinygo Wasm Example Go Source: package main import ( "fmt" "net/http" gotown "github.com/maxmcd/go-town" ) func main() { gotown.ListenAndServe(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World") })) } Built with: deno run --allow-net --allow-run --allow-read \ "https://esm.town/v/maxm/compileAndUploadTinygoWasm?v=58"
0
pomdtr avatar
pomdtr
example_article
HTTP
Searching valtown via sql, jq, jo In a recent discussion, a useful command line pipeline was shared for querying a database and processing the results. The original command looked like this: echo "SELECT * FROM vals WHERE lower(name) LIKE '%feed%' and lower(name) like '%email%' LIMIT 100" | jq -R '{args: [.]} ' | xargs -0 -I {} curl -X POST "https://sqlite-execute.web.val.run" -H "Content-Type: application/json" -d {} | yq -P This command effectively queries a database for records matching certain criteria and processes the results. However, there are several ways this pipeline can be improved for efficiency and clarity. Recommendations for Improvement Elimination of xargs for stdin input in curl : Instead of using xargs to pass input from stdin, curl supports -d '@-' where @ means file and - means stdin. This simplifies the command. Use of --json flag in curl : Recent versions of curl support the --json flag, which automatically sets the correct HTTP headers for JSON content. This allows for a more straightforward command. Avoid explicit setting of HTTP method in curl : Explicitly setting the HTTP method (e.g., -X POST ) is considered bad practice when using data, form, and/or json flags. This is because it's unnecessary and can lead to unexpected side effects when more than one request is made behind the scenes. Use of jo for JSON payload creation: While jq can be used to create a JSON payload, it's more common and cleaner to use jo for this purpose. jo is specifically designed for creating JSON objects and arrays. Improved Command Examples Using the recommendations above, the command can be rewritten as follows: $ jo args="$(jo -a "SELECT * FROM vals WHERE lower(name) LIKE '%feed%' and lower(name) like '%email%' LIMIT 100")" \ | curl -s --json '@-' 'https://sqlite-execute.web.val.run' This command uses jo to create the JSON payload and then passes it to curl using the --json flag for processing. For keeping the SQL statement as input to the pipeline, the command can be further refined: $ echo "SELECT * FROM vals WHERE lower(name) LIKE '%feed%' and lower(name) like '%email%' LIMIT 100" \ | jo -a '@-' \ | jo args=':-' \ | curl -s --json '@-' 'https://sqlite-execute.web.val.run' In this version, @- means treat stdin as a string, and :- means treat stdin as JSON, allowing for dynamic input directly into the JSON payload. Additional Resources For those looking to deepen their understanding of curl and its capabilities, especially with JSON, it's highly recommended to read through Everything curl . This online book is full of useful tricks and insights that can significantly enhance one's command line data processing skills. References https://discord.com/channels/1020432421243592714/1221021689627017236 https://chatcraft.org/api/share/tarasglek/7B_nXLYazAyEryn4Z9Yz0 https://github.com/neverstew/valtown-search/
0
ianv avatar
ianv
blueskyAlert
Cron
Forked from stevekrouse/blueskyAlert
0
nbbaier avatar
nbbaier
fetchPaginatedData
Script
Forked from stevekrouse/fetchJSON
1
dglazkov avatar
dglazkov
servicefactory
Script
A helper to create an HTTP endpoint that conforms to the Breadboard Service Endpoint (BSE) protocol. See https://www.val.town/v/dglazkov/googlenews for sample usage. For more information, see Breadboard service node .
0
stevekrouse avatar
stevekrouse
autoGPTPrompt
Script
// fork from https://github.com/Torantulino/Auto-GPT/blob/master/scripts/data/prompt.txt
0
pomdtr avatar
pomdtr
add_jsdoc_action
Script
Add JSDoc comment to any val This val is supposed to be used with the val.town chrome extension . Add this field to your config to use it: export default [ { title: "Add JSDoc comments", val: "pomdtr/add_jsdoc_action", patterns: ["https://www.val.town/v/:author/:name"], }, // ... ]
1
ianvph avatar
ianvph
blueskyAlert
Cron
Forked from ianv/blueskyAlert
0
lostme avatar
lostme
httpHelloWorldResponse
Script
An interactive, runnable TypeScript val by lostme
0
pomdtr avatar
pomdtr
freeformServer
HTTP
Freeform Brings a taste of Observable to Val Town. This val was adapted from @tmcw obsidian plugin . Instead of using the display function, this port use export default . https://pomdtr-freeformServer.web.val.run/v/<author>/<name> or https://freeform.pomdtr.me/v/<author>/<name> Examples Bar Chart ( View Source )
1
maxm avatar
maxm
pgliteCounter
HTTP
Forked from samwillis/pglite_http_preview_runtime
0
stevekrouse avatar
stevekrouse
lastlogin
Script
Forked from pomdtr/lastlogin
4