Search
musicianApi
@maclong
An interactive, runnable TypeScript val by maclong
Script
export async function musicianApi(req: express.Request, res: express.Response) {
const { data, type } = req.body;
const { tracks, events, emails } = musicianDb;
switch (req.method) {
case "POST": {
try {
switch (type) {
case "track":
tracks.push({
id: tracks.length === 0 ? 0 : tracks.length + 1,
tldrawStars
@jamie_tldraw
An interactive, runnable TypeScript val by jamie_tldraw
Script
export let tldrawStars = fetchJSON("https://api.github.com/repos/tldraw/tldraw")
.then(
(resp) =>
<style>
@keyframes pulse-animation {
0% {
transform: scale(1) rotate(0deg);
20% {
transform: scale(1.1) rotate(10deg);
40% {
npmProxy
@wilt
// import tsBlankSpace from "npm:ts-blank-space";
HTTP
// import tsBlankSpace from "npm:ts-blank-space";
// https://raw.githubusercontent.com/FerroEduardo/bskye/refs/heads/main/src/index.ts
// https://wilt-npmproxy.web.val.run/raw.githubusercontent.com/FerroEduardo/bskye/refs/heads/main/src/index.ts
const npmImportRegex = /\s+from\s+['"]([^.][^:\n]*)['"];?\s*$/gm;
const relativeImportRegex = /\s+from\s+['"](\..*)['"];?\s*$/gm;
const extensions = [
".ts",
// ".tsx",
// ".js",
// ".jsx",
valle_tmp_526792188447901650436660713051491
@janpaul123
// This script creates an HTTP val that generates a Sparkline SVG and embeds an animated crawling cat GIF overlaying the screen.
HTTP
// This script creates an HTTP val that generates a Sparkline SVG and embeds an animated crawling cat GIF overlaying the screen.
// Load essential libraries
export default async function (req: Request): Promise<Response> {
const data = [5, 3, 9, 6, 5, 9, 7, 3, 5, 2, 6]; // Sample data for the sparkline
// SVG and inline CSS to animate a crawling cat GIF
const bodyContent = `
<div>
<img src="https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif" style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);animation:crawl 10s infinite;">
<div style="margin-top:100px;text-align:center;">
${await sparklineSVG(data)}
valle_tmp_98139518017595684072811081715226
@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) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
postEval
@vladimyr
// import { fetchTweet } from "https://esm.town/v/dpetrouk/fetchTweet?v=35";
HTTP
// import { fetchTweet } from "https://esm.town/v/dpetrouk/fetchTweet?v=35";
export default async function(req: Request): Promise<Response> {
const reqURL = new URL(req.url);
const query = reqURL.pathname.slice(1);
if (query.startsWith("https://")) {
const pathname = query.replace(/^https:\/\//, "/");
const redirectURL = new URL(pathname, reqURL);
return Response.redirect(redirectURL);
let post, code, result;
try {
nbbaierImports
@stevekrouse
// Forked from @nbbaier.imports
Script
export const nbbaierImports = async () => {
const cheerio = await import("npm:cheerio");
const _ = await import("npm:lodash-es");
return { cheerio, _ };
// Forked from @nbbaier.imports
blobReadPictureExample
@adnanwahab
Browserbase Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents. Get started with Browserbase for free here . If you have any questions, reach out to developer@browserbase.com.
HTTP
### Browserbase
Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents.
Get started with Browserbase for free [here](browserbase.com).
If you have any questions, reach out to developer@browserbase.com.
export default async function handler(request: Request): Promise<Response> {
const searchParams = new URL(request.url).searchParams;
const url = searchParams.get("url") || "https://www.browserbase.com";
try {
// Use a public screenshot service that doesn't require authentication
const screenshotResponse = await fetch(`https://api.urlbox.io/v1/render/screenshot?url=${encodeURIComponent(url)}&width=1280&height=720`);
zestyPurplePanda
@niek
Fetch Template Example template to quickly get started with a backend for Fetch in Framer.
HTTP
# Fetch Template
Example template to quickly get started with a backend for Fetch in Framer.
import { cors } from "npm:hono/cors";
const app = new Hono();
app.use(cors());
app.get("/", async (c) => {
const isHover = c.req.query("isHover");
const speed = Math.floor(Math.random() * (60 - 80 + 1)) + 80;
return c.json({ speed: isHover ? speed + 30 : speed, isHover });
export default app.fetch;
ChibifyBase
@jeffreyyoung
An interactive, runnable TypeScript val by jeffreyyoung
HTTP
const basePrompt = [
`Generate an image generation model prompt (description) for the previous image, in nightmare before christmas chibi 3D anime style.`,
`The objective is to try to replicate the image as closely as possible,`,
`but in the new style. To do that, you should be very detailed in including`,
`relevant information necessary to reproduce the image, e.g. colors, poses,`,
`facial expressions, background objects, etc. Ensure that the entire description `,
`is consistent with the nightmare before christmas chibi 3D anime style, especially`,
`the 'nightmare before christmas 3D' part. Output only the prompt and nothing else.`,
].join(" ");
export default serve({
solidExample
@maxm
@jsxImportSource https://esm.sh/solid-jsx
HTTP
/** @jsxImportSource https://esm.sh/solid-jsx */
import { renderToString } from "npm:solid-js/web";
export const solidExample = async () =>
new Response(await renderToString(() => <div>Test {1 + 1}</div>), {
headers: {
"Content-Type": "text/html",
valle_tmp_40006751975257874463561930335375
@janpaul123
// Define the main function that will be executed on each HTTP request
HTTP
// Define the main function that will be executed on each HTTP request
export default async function main(req: Request): Promise<Response> {
// Return a simple "Hello, World!" response
return new Response("Hello, World!", { headers: { "Content-Type": "text/plain" } });
test
@ccallaway93
An interactive, runnable TypeScript val by ccallaway93
Script
export async function test() {
const { default: axios } = await import("npm:axios");
const url = "http://207.244.232.58:8011/api/login";
const message = "testing";
const loginInfo = {
username: "HAZAH",
password: "HAZAHisOP1!",
try {
const response = await axios.post(url, loginInfo);
const data = response.json();
mermaidHtml
@jdan
An interactive, runnable TypeScript val by jdan
Script
export async function mermaidHtml() {
const numElements = 30;
const ngram = 2;
const mermaid = mermaidStateDiagramOfMarkov(
markov(
elements.slice(0, numElements),
ngram,
return new Response(
<!DOCTYPE html>
<html lang="en">
valle_tmp_39122300029538671437128838517412
@janpaul123
// We'll create a simple comment system using an input field and a button to submit comments.
HTTP
// We'll create a simple comment system using an input field and a button to submit comments.
// Comments will be persisted using SQLite and displayed below the input box.
// Initialize SQLite and create the comments table if it doesn't exist.
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT NOT NULL
// Define the main function to handle HTTP requests.
export default async function main(req: Request): Promise<Response> {
if (req.method === "POST") {