Search

Results include substring matches and semantically similar vals. Learn more
lalowebos avatar
DiceJS
@lalowebos
// Prints dice roll to the page
Script
var dice = {
sides: 6,
roll: function() {
var randomNumber = Math.floor(Math.random() * this.sides) + 1;
return randomNumber;
// Prints dice roll to the page
iamseeley avatar
falSDXLExample
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
import * as fal from "npm:@fal-ai/serverless-client";
fal.config({
// Can also be auto-configured using environment variables:
willthereader avatar
AlgoliaInstantSearchWebsite
@willthereader
An interactive, runnable TypeScript val by willthereader
HTTP
<script>
console.log("Initializing Algolia search with App ID:", "${appId}");
const searchClient = algoliasearch("${appId}", "${apiKey}");
const search = instantsearch({
//indexName: 'Test_index',
indexName: 'ChapterTitleTest',
searchClient,
debug: true,
search.addWidgets([
thejeshgn avatar
imd_distrcitwise_warnings
@thejeshgn
IMD Warnings Get IMD Warning for a location ( actually of the district the location belongs to). Go to the blog post below for all the details. Blog: https://thejeshgn.com/2024/09/11/simple-imd-alerts/ Credit : https://mausam.imd.gov.in/responsive/subDivisionWiseWarningGIS.php URL Format HTML - https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906&format=html JSON - https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906&format=json where lat = latitude lon = longitude format = html or json defaults If no lat or lon given, it will take bangalore's. defaults : If no format is given then it is html Examples: Bangalore, KA https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=12.9796&lon=77.5906 Thrissur, KL https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=10.527611&lon=76.214389 Lalitpur, UP https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=24.6936599&lon=78.412621 Vishisha, MP https://thejeshgn-imd_distrcitwise_warnings.web.val.run/?lat=23.5210259&lon=77.809569
HTTP (deprecated)
const dist_nowcast_warnings =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3ANowcast_StateDistrict_Merged&styles
+ bbox;
const dist_warnings_today =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&style
+ bbox;
const dist_warnings_today_plus_1 =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&style
+ bbox;
const dist_warnings_today_plus_2 =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&style
+ bbox;
const dist_warnings_today_plus_3 =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&style
+ bbox;
const dist_warnings_today_plus_4 =
"https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&style
+ bbox;
nbbaier avatar
testScriptTag
@nbbaier
@jsxImportSource https://esm.sh/preact
Script
/** @jsxImportSource https://esm.sh/preact */
import { preact } from "https://esm.town/v/stevekrouse/preact";
export function testScriptTag() {
return preact(
<script
liamdanielduffy avatar
REACT_DOM_MINIFIED_PT4
@liamdanielduffy
// set by liamdanielduffy.buildReactDomMinified at 2023-06-01T12:04:43.724Z
Script
// set by liamdanielduffy.buildReactDomMinified at 2023-06-01T12:04:43.724Z
export let REACT_DOM_MINIFIED_PT4 = "ontext};c.sibling=a.sibling;c.index=a.index;c.ref=a.ref;return c}function wd(a,b,c,d,e,f
endzel avatar
status
@endzel
Uptime Status Page This is the status page for the data generated by this uptime cron: @stevekrouse/uptime
HTTP
/** @jsxImportSource https://esm.sh/react */
import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
import { html } from "https://esm.town/v/stevekrouse/html";
import { SparklineSVG } from "https://esm.town/v/stevekrouse/sparklineSVGReact";
import { renderToString } from "npm:react-dom/server";
function StatusRow({ rows }) {
janpaul123 avatar
debugValEmbeddings
@janpaul123
An interactive, runnable TypeScript val by janpaul123
Script
import { decode as base64Decode, encode as base64Encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
import { createClient } from "https://esm.sh/@libsql/client@0.6.0/web";
import { sqlToJSON } from "https://esm.town/v/nbbaier/sqliteExportHelpers?v=22";
import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
apppeak avatar
wetGrayQuelea
@apppeak
An interactive, runnable TypeScript val by apppeak
Cron
import process from "node:process";
import { Client } from "npm:@notionhq/client";
import dayjs from "npm:dayjs";
const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
const notion = new Client({ auth: process.env.NOTION_API_KEY });
const intervalMapping = {
"Weekly": (date) => dayjs(date).add(1, "week"),
petermillspaugh avatar
elaborationAndReflection
@petermillspaugh
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
import { generateLessonHtml } from "https://esm.town/v/petermillspaugh/lessonTemplate";
import { renderToString } from "npm:react-dom/server";
* Note: this lesson is a work in progress 👷‍♂️
const TITLE = "Elaboration & reflection";
rtm avatar
esmTownTranspileDemo
@rtm
Val Town's esm.town Transpiles TypeScript and JSX for browsers When Val Town's code registry (esm.town) gets a request from a browser (which it can detect via the User Agent header), it transpiles that val's code to web-standard JavaScript be able to run in the browser. It does do as much as other transpilers (such as esm.sh, such as rewriting npm: imports, etc). We may add that capability in the future. For now, if you want your npm imports to run in the browser, use https://esm.sh/package instead of npm:package . The below script demonstrates this transiplation behavior by fetching its own source code ( import.meta.url ) with the user agent of a browser. You can uncoment the line setting the browser agent if you want to see the difference in the output. Or you could just load this val's module URL in your browser to see the untranspiled TS.
Script
/** @jsxImportSource https://esm.sh/react */
import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
const browserUserAgent: string =
andreterron avatar
posthogNode
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
const { PostHog } = await import("npm:posthog-node");
const client = new PostHog(process.env.posthog_debug_key, {
host: "https://app.posthog.com",
client.capture({
distinctId: "andre@val.town",
event: "user signed up",
client.on("error", (err) => {
console.log(err);
await client.shutdownAsync();
// flush events:
std avatar
openaiproxy
@std
OpenAI Proxy This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
HTTP (deprecated)
import { RateLimit } from "npm:@rlimit/http";
const client = new OpenAIUsage();
const allowedPathnames = [
// We don't await this promise so that it's not adding to request time.
client.writeUsage({
userId: user.id,
if (user.tier == "pro" && isExpensiveModel(input.model)) {
const count = await client.recentGpt4Usage(user.id);
if (count <= 10) {
mark05e avatar
niceSnippetPostmanCodegen
@mark05e
An interactive, runnable TypeScript val by mark05e
HTTP (deprecated)
urlCode += "\n\nRestProxy_Url.append(RestProxy_UrlQueryParams)";
let postmanVars = findInsideCurly(urlCode);
if (postmanVars.length > 0) {
// check for variables
if (findInsideCurly(line).length > 0) {
postmanVars.push(findInsideCurly(line));
// Add lines to request body
return "";
function findInsideCurly(line) {
// Check for postman vars
// https://stackoverflow.com/questions/413071/regex-to-get-string-between-curly-braces
// let findInsideCurly = /[^{\}]+(?=})/g // single curly
let findInsideCurly = /[^{{\}]+(?=}})/g; // double curly
let result = [];
let matchLength = "";
if (findInsideCurly.test(line)) {
match = line.match(findInsideCurly);
let matchLength = match.length;
robincsl avatar
status
@robincsl
Uptime Status Page This is the status page for the data generated by this uptime cron: @stevekrouse/uptime
HTTP
/** @jsxImportSource https://esm.sh/react */
import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
import { html } from "https://esm.town/v/stevekrouse/html";
import { SparklineSVG } from "https://esm.town/v/stevekrouse/sparklineSVGReact";
import { renderToString } from "npm:react-dom/server";
function StatusRow({ rows }) {