Search

Results include substring matches and semantically similar vals. Learn more
yawnxyz avatar
blobbyFace
@yawnxyz
(todo) This lists all your blobs. You can create new blobs, edit them, or even preview (and upload) file blobs from both URL and computer!
HTTP
// console.log('blobbyList:', blobbyList.length);
async function streamToBuffer(stream) {
const chunks = [];
return new Uint8Array(chunks.reduce((acc, chunk) => acc.concat(Array.from(chunk)), []));
async function detectFileType(buffer) {
const type = await fileTypeFromBuffer(buffer);
return type ? type.mime : 'text/plain';
export async function get(key, c) {
let result = await blobby.get(key);
newKeyName: '',
init: async function() {
console.log('blobby:', this.blobby);
yawnxyz avatar
honoAlpineExample
@yawnxyz
// Endpoint to catch and log the submitted name
HTTP
output: null,
init() {
// if you don't use an arrow function (this) will refer to document, not alpine
document.addEventListener('htmx:afterSwap', (event) => this.updateOutput(event));
updateOutput(event) {
hafifuyku avatar
myApi
@hafifuyku
An interactive, runnable TypeScript val by hafifuyku
Script
export function myApi(name) {
return "hi " + name;
stevekrouse avatar
getWeather
@stevekrouse
Get Weather Simple function to get weather data from the free wttr.in service. import { getWeather } from "https://esm.town/v/stevekrouse/getWeather"; let weather = await getWeather("Brooklyn, NY"); console.log(weather.current_condition[0].FeelsLikeF)
Script
## Get Weather
Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
```ts
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export async function getWeather(location: string): Promise<WeatherResponse> {
return fetchJSON(`https://wttr.in/${location}?format=j1`);
export interface WeatherResponse {
pomdtr avatar
deeplink
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
export default function(req: Request) {
const url = new URL(req.url);
if (!url.searchParams.has("url")) {
xyh avatar
ping
@xyh
An interactive, runnable TypeScript val by xyh
Script
export function ping() {
return "pong";
stungeye avatar
myApi
@stungeye
An interactive, runnable TypeScript val by stungeye
Script
export function myApi(name) {
return "hi " + name;
stevekrouse avatar
dailyStandupBot
@stevekrouse
Daily Standup Bot Every weekday at 9am EDT send a message to our team's #engineering Discord channel to start a thread to remind us to do our standup. Slack version: @mikker/dailySlackRoundup Note : We started doing in-person standups at Val Town, so this val was unscheduled. To get it working for you, you'll need to: Fork it Change its type from Script to Cron and set a schedule like 0 13 * * 1-5
Cron
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
export default async function() {
discordWebhook({
url: Deno.env.get("engDiscord"),
codingjlu avatar
myApi
@codingjlu
An interactive, runnable TypeScript val by codingjlu
Script
export function myApi(name) {
return "hi " + name;
jbeimler avatar
myApi
@jbeimler
An interactive, runnable TypeScript val by jbeimler
Script
export function myApi(name) {
return "hi " + name;
jdan avatar
emojiGuessr
@jdan
Calorie Count via Photo Uploads your photo to ChatGPT's new vision model to automatically categorize the food and estimate the calories.
HTTP
import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL";
import { modifyImage } from "https://esm.town/v/stevekrouse/modifyImage";
import { chat } from "https://esm.town/v/stevekrouse/openai";
import { Hono } from "npm:hono@3";
function esmTown(url) {
return fetch(url, {
headers: {
zdf188 avatar
myApi
@zdf188
An interactive, runnable TypeScript val by zdf188
Script
export function myApi(name) {
return "hi " + name;
stevekrouse avatar
usageAlert
@stevekrouse
HTTP Val Usage Alert As of Oct 29, 2024, HTTP vals can comfortably run 2k times per minute. If you want to get alerted if you val is getting close to those limits, you can wrap your HTTP handler in this middleware: import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert" async function sampleHandler(req: Request): Promise<Response> { return new Response("Hello, World!"); } export default usageAlert(sampleHandler); It keeps a sliding window count of requests in memory (which is perfect for this sittuation) and will send you an email using @std/email if you go over 1k req / min.
Script
import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert"
async function sampleHandler(req: Request): Promise<Response> {
return new Response("Hello, World!");
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=29";
import { email } from "https://esm.town/v/std/email?v=13";
export function usageAlert(handler: (req: Request) => Promise<Response>) {
const requestCounts: number[] = [];
const LIMIT = 1000;
rlesser avatar
pushover
@rlesser
// Send a pushover message.
Script
// Send a pushover message.
// token, user, and other opts are as specified at https://pushover.net/api
export async function pushover({ token, user, message, title, url, ...opts }) {
return await fetch("https://api.pushover.net/1/messages.json", {
method: "POST",
dhvanil avatar
web_FzOqLTzLOP
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_FzOqLTzLOP(req) {
return new Response(`<!DOCTYPE html>
<html>
…
85
…
Next