Search

jsr
@vladimyr
Try on Val Town This service enables quick generation of new val with specified jsr package.
Package authors can provide custom examples by setting either: valtownExample property of jsr.json / deno.json to contain example js/ts code valtownExampleFilename property of jsr.json / deno.json to point to the file with example js/ts code If no example is found val will be created with the default snippet, using @luca/flag as an example : import * as flag from "jsr:@luca/flag"; Go ahead ↗️ try it (on Val Town) ! 🎉 Additionally, the service supports ?code=<base64code> query param that allows overriding extracted/generated example code.
For example one might want to override @luca/flag 's snippet with: import { printProgress } from "jsr:@luca/flag@1";
printProgress(); In order to do so first you need to convert it to base64: $ printf 'import { printProgress } from "jsr:@luca/flag@1";\n\nprintProgress();' | base64 -w0
# ==> aW1wb3J0IHsgcHJpbnRQcm9ncmVzcyB9IGZyb20gImpzcjpAbHVjYS9mbGFnQDEiOwoKcHJpbnRQcm9ncmVzcygpOw== Then you simply construct the URL by setting the returned value to code query param: ↗️ https://vladimyr-jsr.web.val.run?code=aW1wb3J0IHsgcH... Usage https://vladimyr-jsr.web.val.run/<scope>/<name>[@<version>] https://vladimyr-jsr.web.val.run?code=<base64code> Example https://vladimyr-jsr.web.val.run/@luca/flag https://vladimyr-jsr.web.val.run/@std/assert@0.220.1 https://vladimyr-jsr.web.val.run/@mark/html@latest
HTTP
import { type HtmlProcessor, serveReadme } from "https://esm.town/v/vladimyr/serveReadme";
import ky from "npm:ky";
export default async function(req: Request, options?: {
transformReadme: HtmlProcessor;
}): Promise<Response> {
code = `import * as ${name} from "${importSpec}";`;
return Response.redirect(newValURL(code));
async function fetchValtownExample(scope: string, name: string, version: string) {
const pkgConfig = await getConfig(scope, name, version);
version = pkgConfig.version;
pirateTalk
@dctalbot
A Slack bot which rephrases messages in a channel in the voice of a Pirate. Originally built for National Talk Like a Pirate Day, September 19, 2024. https://dctalbot.nyc/blog/pirate-talk/
HTTP
import { OpenAI } from "https://esm.town/v/std/openai";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
const openai = new OpenAI();
const ok = new Response(undefined, { status: 200 });
const unauthorized = new Response(undefined, { status: 401 });
async function ahoy(prompt: string): Promise<string> {
const completion = await openai.chat.completions.create({
messages: [
savvyPurpleSpoonbill
@all
@jsxImportSource https://esm.sh/react
HTTP
function App() {
async function fetchSavedSnippets() {
async function handleSave() {
async function handleDelete(id: number) {
async function handleSubmit(e: React.FormEvent) {
function handleBack() {
function handleForward() {
function client() {
function extractCodeFromFence(text: string): string {
export default async function server(req: Request): Response {
aqi
@danielmorgan
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast
AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
export async function aqi(interval: Interval) {
const location = "12494"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
ddg_chat
@kauri
Simple AI chat app with markdown reneder utilizing DuckDuckGo Chat API
HTTP
"mixtral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1"
function MarkdownMessage({ content, role }) {
return (
</div>
function App() {
const [messages, setMessages] = useState([]);
paddingLeft: '30px'
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
// Proxy for DuckDuckGo API calls
valle_tmp_459423574352421057264033168224449
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
valle_tmp_7848874273078958552804771654705
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
reply_to_slack_message
@curtcox
This val provides a way of readily having lots of different Slack bots that do different things and support different Slack workspaces without needing a bunch of Val Town accounts. If you only need a single bot on a single workspace, just go with the approach in the Val Town docs . This bot is essentially the one described in the Val Town docs , but without any of the details. Those are externalized by the SlackConfig and SlackFunction interfaces. It is just glue. In order to make it work, you will need the following additional glue: a public HTTP val to handle requests like this one a private val to supply any info missing from the public one like this one Actually, those could both be public or all in the same val, but the whole point of this scheme is to allow you to hide anything you want.
HTTP
This val provides a way of readily having lots of different Slack bots that do different things and support different Slack workspaces without needing a bunch of Val Town accounts. If you only need a single bot on a single workspace, just go with the approach in the Val Town [docs](https://docs.val.town/integrations/slack/bot/).
This bot is essentially the one described in the Val Town [docs](https://docs.val.town/integrations/slack/bot/), but without any of the details. Those are externalized by the SlackConfig and SlackFunction interfaces. It is just glue. In order to make it work, you will need the following additional glue:
- a public HTTP val to handle requests like [this one](https://www.val.town/v/curtcox/Chatio)
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
async function post_response(body, f: SlackFunction, config: SlackConfig) {
// Note: `body.event` has information about the event like the sender and the message text
// This will process the message and produce a response
export interface SlackFunction {
(body: any): Promise<string>;
export const reply_to_slack_message = async (req: Request, f: SlackFunction, config: SlackConfig) => {
let body = null;
magicalRoseBlackbird
@nguyenric
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
healthdatasimple
@ejfox
@jsxImportSource https://esm.sh/react
HTTP
// Client-side App component
function App({ data }) {
return (
// Client-side rendering
function client() {
fetch('/api/health-data')
client();
export default async function server(request: Request): Promise<Response> {
const { blob } = await import("https://esm.town/v/std/blob");
spotify
@ejfox
// Thank you for the feedback! You're right, we need to handle cases where playlist images might be missing.
HTTP
window.location.href = url;
window.onerror = function(message, source, lineno, colno, error) {
console.error('An error occurred:', error);
console.log('Access token received');
async function fetchPlaylists() {
try {
document.getElementById('error').textContent = 'Error fetching playlists: ' + error.message;
async function fetchTracks(playlistId, playlistName) {
try {
anime
@yieldray
An interactive, runnable TypeScript val by yieldray
Script
eval: cookie.length === 0
: cookie.map((c) => `document.cookie='${c.split("; ").slice(0, 5).join("; ")}'`).join(";") + ";",
export async function anime(catOrName?: number | string, episode?: string | number) {
if (catOrName != undefined)
if (episode != undefined) return getEpisode(catOrName, episode);
Snake_game
@ilianp
@jsxImportSource https://esm.sh/react
HTTP
const INITIAL_FOOD = { x: 15, y: 15 };
// Helper function to check if two directions are opposite
const isOppositeDirection = (dir1, dir2) => {
return oppositeMap[dir1] === dir2;
function SnakeGame() {
const [snake, setSnake] = useState(INITIAL_SNAKE);
</div>
function client() {
createRoot(document.getElementById("root")).render(<SnakeGame />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
aqi
@alaq
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast
AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
export async function aqi(interval: Interval) {
const location = "Brooklyn NY 11206"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
niceSnippetPostmanCodegen
@mark05e
An interactive, runnable TypeScript val by mark05e
HTTP
export default async function handler(request: Request) {
function writeLog(text = "Hello World") {
function generateSnippet(inputText) {
function genUrlCode(jsonObj) {
function getUrl(jsonObj) {
function getQueryString(jsonObj) {
function genHeaderCode(jsonObj, skipRestProxy = false) {
function genMethodCode(jsonObj) {
function genBodyCode(jsonObj) {
function insertNewLine() {