Search
valle_tmp_14787389514247828561625352472568
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
import { faker } from "npm:@faker-js/faker";
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {

myApi
@mantas
An interactive, runnable TypeScript val by mantas
Script
export function myApi(name) {
return "hi " + name;
api500
@matthamlin
An interactive, runnable TypeScript val by matthamlin
Script
export function api500(req: express.Request, res: express.Response) {
res.status(503);
res.json({
wasmExample
@just_be
An interactive, runnable TypeScript val by just_be
HTTP
import { default as loadWabt } from "npm:wabt";
const wabt = await loadWabt();
export default async function(req: Request): Promise<Response> {
return new Response(
wabt.parseWat(
ForexDataHub
@samweist
An interactive, runnable TypeScript val by samweist
HTTP
import { addMonths, format, subMonths } from "https://esm.sh/date-fns";
function generateFutureEvents(months = 6) {
const events = [];
return events.sort((a, b) => a.date - b.date);
async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
headers: { "Content-Type": "application/json" },
function getStyles() {
return `
valle_tmp_46943868107891815759175483516619
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
import { faker } from "npm:@faker-js/faker";
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
valle_tmp_187519111800805945311738641630043
@janpaul123
// This val will respond to HTTP requests with a simple "Hello, World!" message
HTTP
// This val will respond to HTTP requests with a simple "Hello, World!" message
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, World!", {
headers: { "Content-Type": "text/plain" },

sync
@pomdtr
Sync local <-> remote vals TODO [ ] Separate the logic in two steps: Detect changes Apply changes
Script
console.error("VALTOWN_TOKEN is required");
Deno.exit(1);
export async function fetchEnv() {
const { data: res, error } = await fetchValTown("/v1/eval", {
method: "POST",
delete env["VALTOWN_API_URL"];
return env;
export async function fetchValTown<T = any>(
path: string,
options?: RequestInit & {

ExampleGetParams
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const search = url.searchParams;
agenta_webhook_eval
@mmabrouk
Example webhook evaluator (see docs in http://docs.agenta.ai/evaluation/evaluators/webhook-evaluator)
HTTP
export default async function server(request: Request): Promise<Response> {
// Parse the request body
let body: { inputs: Record<string, string>, output: string, correct_answer: string };
SolanaJupiterTxParser
@ryoid
// Statically define to reduce size
Script
["outputMint", getAddressDecoder()],
["outputAmount", getU64Decoder()],
function isBytesEqual(a: Uint8Array, b: Uint8Array) {
if (a.length !== b.length) {
return false;
return true;
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
async function getSwapEvent(txId: Signature) {
const rpcTx = await rpc
.getTransaction(txId, {
sendNotification
@doublelotus
Push Notification Sender This val can be used in other vals to send notifications to a segment using OneSignal's REST API This is really handy if you want to send push notifications to your phone without building a native app! I built a barebones React PWA that asks for a password then loads the OneSignal Web SDK that I deployed to Netlify for free. OneSignal has easy to follow docs so you can build this functionality into a React, Angular, Vue app or even Wordpress! Then install the PWA on your platform of choice and you're off to the races! Setup Save your ONESIGNAL_TOKEN and SEGMENT_APPID from OneSignal to your Val Town environment variables Import into another val! import sendNotification from "https://esm.town/v/gwoods22/sendNotification";
Script
This val can be used in other vals to send notifications to a segment using [OneSignal's REST API](https://documentation.onesignal.com/reference/create-notification)
This is really handy if you want to send push notifications to your phone without building a native app! I built a barebones React PWA that asks for a password then loads the OneSignal Web SDK that I deployed to [Netlify](https://www.netlify.com/) for free. OneSignal has [easy to follow docs](https://documentation.onesignal.com/docs/web-sdk-setup) so you can build this functionality into a React, Angular, Vue app or even Wordpress! Then [install the PWA](https://www.bitcot.com/how-to-install-a-pwa-to-your-device/) on your platform of choice and you're off to the races!
## Setup
axios.defaults.headers.get["User-Agent"] =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3";
async function run() {
const imageUrl =
"https://prodimage.images-bn.com/lf?set=key%5Bresolve.pixelRatio%5D,value%5B1%5D&set=key%5Bresolve.width%5D,value%5B600%5D&set=key%5Bresolve.height%5D,value%5B10000%5D&set=key%5Bresolve.imageFit%5D,value%5Bcontainerwidth%5D&set=key%5Bresolve.allowImageUpscaling%5D,value%5B0%5D&set=key%5Bresolve.format%5D,value%5Bwebp%5D&source=url%5Bhttps://prodimage.images-bn.com/pimages/9780063345164_p0_v3_s600x595.jpg%5D&scale=options%5Blimit%5D,size%5B600x10000%5D&sink=format%5Bwebp%5D";
musicFromPrompt
@insectagon
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [prompt, setPrompt] = useState("");
const [error, setError] = useState("");
async function generateImage() {
setIsLoading(true);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(req: Request): Promise<Response> {
return new Response(`