Search

Results include substring matches and semantically similar vals. Learn more
robsimmons avatar
aoc_2023_15_2
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.11/lib/client.js";
const INPUT = `
rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7
easrng avatar
denoMediaTypes
@easrng
/// Definition files don't have separate content types and so we have to "guess"
Script
if (!match) return base_type;
const [file_stem, file_name, file_ext] = match;
// .ts files that contain .d. in the file name are always considered a typescript declaration file.
// See: https://github.com/microsoft/TypeScript/issues/53319#issuecomment-1474174018
if (
robsimmons avatar
aoc_2023_14_feasible
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
O....#....
robsimmons avatar
fieryPlumLeopon
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa, termToString } from 'https://unpkg.com/dusa@0.1.5/lib/client.js';
const dusa = new Dusa('fact is { mortal socrates, man socrates }.');
console.log(termToString(dusa.solution.get('fact')));
nbbaier avatar
valToGH
@nbbaier
valToGH A utility function for programmatically updating a GitHub repository with code retrieved from a Val. NOTE : This function currently does not change the contents of a file if it is already present. I will however be adding that functionality. Usage import { valToGH } from 'https://esm.town/v/nbbaier/valToGH'; const repo = "yourGitHubUser/yourRepo"; const val = "valUser/valName"; // or vals = ["valUser/valName1","valUser/valName2", ...] const ghToken = Deno.env.get("yourGitHubToken"); const result = await valToGH(repo, val, ghToken); console.log(result); Parameters repo : The GitHub repository in the format {user}/{repo} . val : A single repository in the format {user}/{val} . ghToken : Your GitHub token for authentication (must have write permission to the target repo) Options branch : Optional target branch. Default is main . prefix : Optional directory path prefix for each file. message : Optional commit message. Default is the current date and time in the format yyyy-MM-dd T HH:mm:ss UTC . ts : Optional flag to use a .ts extension for the committed file instead of the default .tsx .
Script
async function getLatestCommit(ghUser: string, ghRepo: string, branch: string, client: Octokit)
const { data: refData } = await client.rest.git.getRef({
client: Octokit,
} = await client.rest.git.createTree({
client: Octokit,
} = await client.rest.git.createCommit({
client: Octokit,
const result = await client.rest.git.updateRef({
const client = new Octokit({ auth: ghToken });
const commitSHA = await getLatestCommit(ghUser, ghRepo, branch, client);
robsimmons avatar
dusa_lookup_one_arg
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.12/lib/client.js";
const dusa = new Dusa(`
edge 1 2.
tr3ntg avatar
makeCallOnEmail
@tr3ntg
Make Phone Call with Twilio Upon Email Receipt Backstory I bought a Bluetooth temperature monitor to monitor the temp in one of my rooms. I made sure to purchase one that sends alerts for temperatures that are out of a given range. Unfortunately, those notifications can’t be set to override Focus modes or when your phone is on Silent. But the app does allow you to add any email address for an alert. So, a Val Town Email handler + Twilio, and I’ve got myself an unmissable alert for if that room ever gets too hot or cold. 🔥🧊 How to Use Fork this Val, fill in your environment tokens (including phone number) and watch a call come through when you email the Val! Caveats This will call you on EVERY email. This works for my use case as the email is only registered with my temperature monitoring device. (You'll need to keep your emailing Val private, or add on some sort of verification to prevent errant emails and calls.)
Email
let twilioAccountSID = Deno.env.get("_twilio_AccountSid");
let twilioAuthToken = Deno.env.get("_twilio_AuthToken");
// Instantiation of the Twilio client itself fails, so we make use of the models only, and
// call the endpoint manually with `fetch`.
const VoiceResponse = Twilio.twiml.VoiceResponse;
pomdtr avatar
example_article
@pomdtr
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/
HTTP
2. **Use of `--json` flag in `curl`:** Recent versions of `curl` support the `--json` flag, which automatically sets the corr
ethod in `curl`:** Explicitly setting the HTTP method (e.g., `-X POST`) is considered bad practice when using data, form, and
4. **Use of `jo` for JSON payload creation:** While `jq` can be used to create a JSON payload, it's more common and cleaner t
pdebie avatar
publishYoutubeToLemmy
@pdebie
Publish a Youtube feed to Lemmy This allows you to automatically publish a Youtube channel to to a Lemmy community. Example usage: async function publishMyFeed() { try { return @pdebie.publishYoutubeToLemmy({ instance: "lemm.ee", auth: @me.secrets.lemmee, communityId: 23316, youtubeChannelId: "UChZgikssAJkmiQOv_sO-ngQ", lastSyncTime: @pdebie.spacexLemmyDb.lastSync, }); } finally { @pdebie.spacexLemmyDb.lastSync = new Date().toISOString(); } } Get a Youtube channel ID here . Make sure to set your lastSync properly, since otherwise you'll keep publishing new posts!
Script
filter?: (title: string) => boolean;
const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
let client = new LemmyHttp(`https://${instance}`, {
fetchFunction: fetch,
return;
const ret = await client.createPost({
community_id: communityId,
xkonti avatar
memoryApiPolicy
@xkonti
Returns a simple privacy policy for the GPT Memory API. Examples of input: apiName : Memory API contactEmail : some@email.com lastUpdated : 2023-11-28
Script
${apiName} allows users to store, retrieve, list, and delete data. The data stored can be of any type as inputted by the user
## 3. User Restrictions
e} does not impose age or user restrictions. However, users are advised to consider the sensitivity of the information they s
## 4. Global Use
Our API is accessible globally. Users from all regions can store and access data on ${apiName}.
domingo1987 avatar
problemPython
@domingo1987
// Privacy policy template in Markdown
HTTP
La API de Intercambio de Problemas de Python permite a los usuarios almacenar, recuperar, listar y eliminar datos. Los datos
## 3. Restricciones de Usuario
da para el uso de niños menores de 13 años. Se aconseja a los usuarios que consideren la sensibilidad de la información que c
## 4. Uso Global
Nuestra API es accesible a nivel mundial. Los usuarios de todas las regiones pueden almacenar y acceder a los datos en la API
El código de la API y los datos son alojados por val.town. Ellos actúan como proveedores de servicios externos para la API de
## 8. Restricciones de Uso
enido que envían. Los problemas y soluciones enviados por el usuario serán considerados de dominio público.
## 9. Descargo de Responsabilidad
La API se proporciona tal cual, sin ninguna garantía.
dthyresson avatar
ideas
@dthyresson
Ideas Movie Mashup with AI - done! Bedtime Story genertator - done! Drum machine pattern from PDF maker Movie emoji plots: "Sure, here's a summarized plot of "Pretty in Pink" using only emoji, along with their explanations, including iconic scenes:" Sure, here's a summarized plot of "Pretty in Pink" using only emoji, along with their explanations, including iconic scenes: 👩‍🎤🏫👗💔👦👨‍👧📚👠💃🎸❤️🎩🎸🚗🎨👫 1. **👩‍🎤 (Girl with Punk Hair)** - Andie, the main character, who has a unique and alternative style. 2. **🏫 (School)** - The high school setting where the story takes place. 3. **👗 (Dress)** - The pink prom dress that Andie makes for herself, representing her individuality. 4. **💔 (Broken Heart)** - The heartbreaks and romantic tensions throughout the movie. 5. **👦 (Boy)** - Blane, the rich boy Andie falls for. 6. **👨‍👧 (Father and Daughter)** - Andie's relationship with her supportive, but struggling father. 7. **📚 (Books)** - The academic environment and high school dynamics. 8. **👠 (High-Heeled Shoe)** - The social divide between the rich "preppies" and the less affluent students. 9. **💃 (Dancer)** - The iconic prom scene. 10. **🎸 (Guitar)** - The music and band scenes, especially featuring Duckie. 11. **❤️ (Heart)** - The romantic plot and relationships. 12. **🎩 (Top Hat)** - Duckie's unique style and his memorable entrance at the prom. 13. **🚗 (Car)** - Andie's car, which she often uses to get around. 14. **🎨 (Palette)** - Andie's creative and artistic side, including her job at the record store. 15. **👫 (Couple)** - The final pairing and resolution of romantic relationships.
Script
13. **🚗 (Car)** - Andie's car, which she often uses to get around.
14. **🎨 (Palette)** - Andie's creative and artistic side, including her job at the record store.
15. **👫 (Couple)** - The final pairing and resolution of romantic relationships.
robsimmons avatar
aoc_2023_14_infeasible
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
O....#....
stevekrouse avatar
notionGetDatabase
@stevekrouse
Get all the pages in a notion database Usage Find your databaseId : https://developers.notion.com/reference/retrieve-a-database Get auth by setting up an internal integration: https://developers.notion.com/docs/authorization#internal-integration-auth-flow-set-up Example usage: @stevekrouse.dateMeNotionDatabase deno-notion-sdk docs: https://github.com/cloudydeno/deno-notion_sdk
Script
auth: string;
filter?: any;
const { Client, collectPaginatedAPI } = await import(
"https://deno.land/x/notion_sdk/src/mod.ts"
const notion = new Client({ auth });
return collectPaginatedAPI(notion.databases.query, {
database_id: databaseId,
andrew avatar
percentLiftGasNeededSTP
@andrew
An interactive, runnable TypeScript val by andrew
Script
if (liftFraction < 0 || liftFraction > 1) {
console.error(
"Error: The calculated hydrogen fraction is outside the valid range. It's not possible to achieve the desired lift forc
return null;
console.log(