Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
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) {
mantas avatar
myApi
@mantas
An interactive, runnable TypeScript val by mantas
Script
export function myApi(name) {
return "hi " + name;
matthamlin avatar
api500
@matthamlin
An interactive, runnable TypeScript val by matthamlin
Script
export function api500(req: express.Request, res: express.Response) {
res.status(503);
res.json({
just_be avatar
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(
samweist avatar
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 `
janpaul123 avatar
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) {
janpaul123 avatar
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" },
pomdtr avatar
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 & {
stevekrouse avatar
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;
mmabrouk avatar
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 };
ryoid avatar
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, {
doublelotus avatar
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.ones
tps://documentation.onesignal.com/docs/web-sdk-setup) so you can build this functionality into a React, Angular, Vue app or e
## 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%5
insectagon avatar
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(`
dhvanil avatar
web_mqybI9ybHZ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_mqybI9ybHZ(req) {
return new Response(`<!DOCTYPE html>
<html lang="en">
dhvanil avatar
val_wrXS4vL012
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {