Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_0gHzAuvnHy
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_0gHzAuvnHy(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Enhanced model with purpose regeneration and resonance
class PurposeNode {
constructor(id, initialPurpose) {
this.id = id;
this.purpose = initialPurpose;
this.connections = [];
stevekrouse avatar
lucia_middleware_demo
@stevekrouse
Lucia Middleware Demo Import users. Backed by Val Town SQLite. Initially built by @pomdtr.
HTTP
# Lucia Middleware Demo
Import users. Backed by Val Town SQLite.
Initially built by @pomdtr.
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
app.get("/", (c) => {
const username = c.req.header("X-Lucia-Username");
if (username) {
return c.html(
<div>
dhvanil avatar
val_4INpGNAf93
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_4INpGNAf93(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Let's explore the Mandelbrot set and the concept of self-similarity
// This demonstrates how infinite complexity can emerge from simple rules
function mandelbrotPoint(x0, y0, maxIter) {
let x = 0;
let y = 0;
let iter = 0;
alexmcroberts avatar
v1_cards
@alexmcroberts
An interactive, runnable TypeScript val by alexmcroberts
HTTP
// v1/cards
export default async function(req: Request): Promise<Response> {
const start = Date.now(); // Server-Timing
const header = getHeader();
const divider = getDivider();
const cards = await getCards();
const endCards = Date.now();
let out = {
blocks: [header, divider, cards],
const endBuildOut = Date.now(); // Server-Timing
rodrigotello avatar
testHTML
@rodrigotello
// Forked from @tr3ntg.testHTML
Script
export function testHTML(req: express.Request, res: express.Response) {
res.send(
"<html lang='en'>" +
"<head>" +
"<meta charset='utf-8'>" +
"<title>Hello World</title>" +
"</head>" +
"<body style=`background:tomato; color:white`>" +
"<h1>Hello World</h1>" +
"</body>" +
janpaul123 avatar
valle_tmp_94440105214223307666476397039723
@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),
charmaine avatar
twitterRecentMentions
@charmaine
// This val fetches recent tweets about @SnapAR or Lens Studio
HTTP
// This val fetches recent tweets about @SnapAR or Lens Studio
// Updated to use Social Data instead of Twitter API
export default async function server(request: Request): Promise<Response> {
// Updated to just Specs post-launch
const query = "@Spectacles";
try {
const data = await socialDataSearch(query);
return retResponse(data.tweets);
} catch (error) {
console.error("Error fetching posts:", error);
joodaloop avatar
CLIBlog
@joodaloop
An interactive, runnable TypeScript val by joodaloop
Script
export const CLIBlog = (async () => {
// let response = await fetch(
// "https://example-files.online-convert.com/document/txt/example.txt",
// if (response.status != 200) {
// throw new Error("Server Error");
// // read response stream as text
// let text_data = await response.text();
// let lines = text_data.split("\n");
// return lines;
let entries = [
dhvanil avatar
val_A2hBhiEmpp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() {
let a = 0, b = 1;
let result = [];
while (b < 1000) {
if (b >= 100) {
result.push(b);
let temp = b;
ashryanio avatar
generateQrCode
@ashryanio
QR code generator Submit text and get a QR code back! Based on renderFormAndSaveData by @andreterron .
HTTP
# QR code generator
Submit text and get a QR code back!
Based on [renderFormAndSaveData](https://www.val.town/v/andreterron/renderFormAndSaveData) by [@andreterron](https://www.val.
export const generateQrCode = async (
req: Request,
): Promise<Response> => {
// A visit from a web browser? Serve a HTML page with a form
if (req.method === "GET") {
return html(`
<!DOCTYPE html>
dhvanil avatar
val_AEI5YxH6RC
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() {
let a = 0, b = 1;
while (b < 1000) {
let temp = b;
b = a + b;
a = temp;
return b;
janpaul123 avatar
valle_tmp_46943868107891815759175483516619
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
const SAMPLE_STORIES_KEY = "hn_realistic_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: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
janpaul123 avatar
valle_tmp_857735669745683227119074105407037
@janpaul123
This code sets up a simple comment box system. * It leverages Deno's blob storage for persistence, * and renders an HTML form to accept new comments, * while displaying all existing comments. * TailwindCSS is used to style the HTML elements.
HTTP
/** This code sets up a simple comment box system.
* It leverages Deno's blob storage for persistence,
* and renders an HTML form to accept new comments,
* while displaying all existing comments.
* TailwindCSS is used to style the HTML elements.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<html>
janpaul123 avatar
valle_tmp_18509498710822885445406823160177
@janpaul123
This code sets up a simple comment box system. * It leverages Deno's blob storage for persistence, * and renders an HTML form to accept new comments, * while displaying all existing comments. * Tailwind CSS is used for styling.
HTTP
/** This code sets up a simple comment box system.
* It leverages Deno's blob storage for persistence,
* and renders an HTML form to accept new comments,
* while displaying all existing comments.
* Tailwind CSS is used for styling.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<html>
stevekrouse avatar
cheerioEx
@stevekrouse
// Forked from @maryrosecook.denoImportEx
Script
export let cheerioEx = (async () => {
const cheerio = await import("npm:cheerio@1.0.0-rc.12");
const $ = cheerio.load("<html><h1>hi</h1></html>");
return $("h1")
.toArray()
.map((node) => $(node).text().trim());
// Forked from @maryrosecook.denoImportEx