Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
notion2wallabag
@stevekrouse
Notion2Wallabag Intended to be run with Notion's webhooks. When fired, tries to save a Notion database item with a "Link" property to a Wallabag instance. Cannot be re-used for other workspaces, since it requires various Wallabag secrets and a Notion-specific token. Feel free to fork!
HTTP
import { httpClient } from "https://esm.town/v/pomdtr/http_client";
export default httpClient(handler);
async function handler(request: Request) {
WALLABAG_URL: process.env.WALLABAG_URL,
WALLABAG_CLIENT_ID: process.env.WALLABAG_CLIENT_ID,
WALLABAG_CLIENT_SECRET: process.env.WALLABAG_CLIENT_SECRET,
WALLABAG_USERNAME: process.env.WALLABAG_USERNAME,
grant_type: "password",
client_id: config.WALLABAG_CLIENT_ID,
client_secret: config.WALLABAG_CLIENT_SECRET,
username: config.WALLABAG_USERNAME,
andybak avatar
nearspark
@andybak
An interactive, runnable TypeScript val by andybak
HTTP
} else if (error.message.includes('decode')) {
errorMessage += 'The image could not be decoded. Please ensure the URL points to a valid image file.';
} else if (error.message.includes('client error (Connect)')) {
errorMessage += 'There was a network error while trying to fetch the image. This might be due to network restrictions o
} else {
robsimmons avatar
aoc_2023_12_sat
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
???.### 1,1,3
tmcw avatar
jsYAMLExample
@tmcw
js-yaml YAML is a popular format for data which is an alternative to JSON . In contrast to JSON, YAML can look more user-friendly: you can write text without worrying about quoting strings You can write comments in YAML But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and predictable. js-yaml is the most popular YAML parser for JavaScript.
Script
- You can write comments in YAML
- But, on the other side, it's more possible to write YAML that is parsed in an unexpected way. JSON is more explicit and pre
[js-yaml](https://www.npmjs.com/package/js-yaml) is the most popular YAML parser for JavaScript.
bao avatar
notionDbCalendarFeed
@bao
Publishes a Notion database with a date property to a calendar feed. Create a Notion integration in http://notion.so/profile/integrations Go to the Notion database -> click ••• from top right -> Connections -> Connect to, select the integration from last step Fork this val Set NOTION_API_TOKEN and NOTION_EVENTS_DATABASE_ID in https://www.val.town/settings/environment-variables Update datePropertyName and maxEventAgeInMonths if necessary
HTTP
import { Client } from "https://esm.sh/@notionhq/client";
export default async function server(request: Request): Promise<Response> {
try {
if (!notionApiKey || !databaseId) {
return new Response("Missing Notion API credentials", { status: 500 });
const notion = new Client({ auth: notionApiKey });
// Calculate the date n months ago
const someMonthsAgo = new Date();
stevekrouse avatar
sqliteTableExportUtils
@stevekrouse
SQLite Table Export Utils This allows for a val.town-hosted SQLite table to be exported as: JSON ( Record<string, unknown>[] ) Arrow IPC ( Uint8Array ) TODO: Others? This can then be used by a HTTP endpoint, like so: import { exportSQLiteTable, SQLiteTableExportFormat } from "https://esm.town/v/rlesser/sqliteTableExportUtils"; export default async function(req: Request): Promise<Response> { const tableName = new URL(req.url).searchParams.get("table"); if (!tableName) { return new Response("Table name is required", { status: 400 }); } const format = (new URL(req.url).searchParams.get("format") || "arrowIPC") as SQLiteTableExportFormat; const data = await exportSQLiteTable(tableName, format); if (data instanceof Uint8Array) { return new Response(data, { headers: { "Content-Type": "application/octet-stream" }, }); } else { return Response.json(data); } } TODO Specify limit and offset of export, for pagination Smart assessment of if the export is going to be over the val.town limit of 10MB, adjust to paginated of so. Support other export formats. PRs welcome!
Script
import { sqlite } from "https://esm.town/v/std/sqlite";
import { type ResultSet } from "npm:@libsql/client";
import { DataType, Float64, Int32, Table, tableToIPC, Utf8, vectorFromArray } from "npm:apache-arrow";
// Function to map SQLite data types to Apache Arrow data types
julbrs avatar
zohoDeskApi
@julbrs
Zoho Desk API A set of method to easily grab information on Zoho Desk! Official API Documentation is here . Notes It's needed to create a Self Client Application as described here to use this val. You also need to find your org id (under Setup > API > Zoho Service Communication (ZSC) Key > OrgId). Methods As of today here is the methods in this val: refreshAccessToken to generate a valid Access Token based on client id, client secret and a refresh token. Follow the step here to register a client and generate a refresh token. notAssignedTickets to extract the currently not assigned tickets in a specified department
Script
## Notes
It's needed to create a Self Client Application as described [here](https://desk.zoho.com/DeskAPIDocument#OauthTokens#Registe
## Methods
As of today here is the methods in this val:
- `refreshAccessToken` to generate a valid Access Token based on client id, client secret and a refresh token. Follow the ste
- `notAssignedTickets` to extract the currently not assigned tickets in a specified department
export const refreshAccessToken = async (
clientId: string,
clientSecret: string,
refreshToken: string,
params: {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refreshToken,
joey avatar
sendDiscordMessage
@joey
// add the bot to your server before calling:
Script
import { discordAPI } from "https://esm.town/v/joey/discordAPI";
// add the bot to your server before calling:
// https://discord.com/oauth2/authorize?client_id=1099070848968691895&permissions=2048&scope=bot
// Usage:
// await @joey.sendDiscordMessage('some-channel-id', 'hello world!');
janpaul123 avatar
indexValsNeon
@janpaul123
Part of Val Town Semantic Search . Generates OpenAI embeddings for all public vals, and stores them in Neon , using the pg_vector extension. Create the vals_embeddings table in Neon if it doesn't already exist. Get all val names from the database of public vals , made by Achille Lacoin . Get all val names from the vals_embeddings table and compute the difference (which ones are missing). Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the result in Neon. Can now be searched using janpaul123/semanticSearchNeon .
Cron
import { decode as base64Decode, encode as base64Encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
import { Client } from "https://deno.land/x/postgres/mod.ts";
import getValCode from "https://esm.town/v/janpaul123/getValCode";
const dimensions = 1536;
const client = new Client(Deno.env.get("NEON_URL_VALSEMBEDDINGS"));
await client.connect();
const allVals = await sqlToJSON(
const existingEmbeddingsIds = new Set(
(await client.queryObject`SELECT id FROM vals_embeddings`).rows.map(row => row.id),
function idForVal(val: any): string {
const embeddedBinaryString = `[${embeddingBinary.join(",")}]`;
const result = await client
.queryObject`INSERT INTO vals_embeddings (id, embedding) VALUES (${id}, ${embeddedBinaryString})`;
vtdocs avatar
supaBaseQuery
@vtdocs
A helper for writing parameterized Postgres queries for Supabase. Part of the Supabase guide on docs.val.town .
Script
args: any[] = [],
const { Client } = await import(
"https://deno.land/x/postgres@v0.17.0/mod.ts"
const client = new Client(connectionString);
await client.connect();
const result = await client.queryArray(query, args);
await client.end();
return result;
eidam avatar
ratelimit_example
@eidam
// initialise rlimit.com client with your namespace ID and default settings
Script
import { RateLimit } from "https://esm.town/v/rlimit/http";
// initialise rlimit.com client with your namespace ID and default settings
const ratelimit = new RateLimit({ maximum: 5, interval: "20s" });
// increase count & check result for given identifier
isidentical avatar
falImageGen
@isidentical
* Generates an image with Stable Diffusion XL through fal.ai * * @param {string} prompt - The input prompt to send to SDXL model. * @returns {Promise<string>} A promise that resolves to the URL of the image.
Script
input: string,
): Promise<{ url: string }> {
let resp = await fetch("https://isidentical-falimagehandler.web.val.run/", {
method: "POST",
body: JSON.stringify({ prompt: input }),
petermillspaugh avatar
sendTestEmailNewsletter
@petermillspaugh
Val Town email subscriptions: send test email Cousin Val to @petermillspaugh/emailSubscription — see docs there. When you're writing up an email to send to subscribers, it's helpful to send it to yourself ahead of time to proofread and see how it looks in different email clients etc.
Cron
Cousin Val to [@petermillspaugh/emailSubscription](https://www.val.town/v/petermillspaugh/emailSubscription) — see docs there
yourself ahead of time to proofread and see how it looks in different email clients etc.
/** @jsxImportSource https://esm.sh/preact */
import { generateNewsletterJsx } from "https://esm.town/v/petermillspaugh/generateNewsletterJsx";
import { email as sendEmail } from "https://esm.town/v/std/email?v=11";
import { render } from "npm:preact-render-to-string";
export function sendTestEmailNewsletter(interval: Interval) {
robsimmons avatar
aoc_2023_10_1
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.0.10/lib/client.js";
const INPUT = `
7-F7-
rlesser avatar
track
@rlesser
Forked from saolsen/plausible ! Go there for the original val. Plausible analytics Call track with the domain you set up in plausible and the request. I've been using saolsen.val-name . Note that there is no auth for the plausible events API, so if somebody forks the val it'll still work but track all their val page loads in your dashboard which is kinda weird but also kinda cool, idk. See https://www.val.town/v/saolsen/plausible_example for how to use.
Script
headers: {
"User-Agent": req.headers.get("user-agent")!,
"X-Forwarded-For": req.headers.get("true-client-ip")!,
"Content-Type": "application/json",
// "X-Debug-Request": "true",