Search
markdownToHtml
@jessmartin
An interactive, runnable TypeScript val by jessmartin
Script
export const markdownToHtml = async (res, req) => {
const remarkHtml = (await import("npm:remark-html")).default;
const unified = (await import("npm:unified")).unified;
const markdown = (await import("npm:remark-parse")).default;
const markdownToConvert = fetch(
"https://jessmartin-todoMarkdown.express.val.run",
unified()
.use(markdown)
.use(remarkHtml)
.process(markdownToConvert, function (err, file) {
switchExtractor
@temptemp
An interactive, runnable TypeScript val by temptemp
Script
const regex = /case (0[xX][\da-fA-F]+):([a-zA-Z\d]+)=(.),([a-zA-Z\d]+)=(.)/gm;
const site = {
"megacloud.tube": "https://megacloud.tube/js/player/m/e1-player-v2.min.js?v=0.0.9",
"megacloud.tv": "https://megacloud.tv/js/player/a/prod/e1-player-debug.min.js",
"southcloud.tv": "https://southcloud.tv/js/player/a/sc/prod/p1-debug.min.js",
"rapid-cloud.tv": "https://rapid-cloud.co/js/player/prod/e6-player-v2-debug.min.js",
const req = await fetch(site["megacloud.tv"]);
const str = await req.text();
let m;
const dataChart: { variable: string; value: number }[][] = [];
purpleBee
@rayman
Quill.js WYSIWYG Basic WYSIWYG rich text editor, using quill.js . Press the "Get HTML" button to show the HTML in an alert window.
HTTP
# Quill.js WYSIWYG
Basic WYSIWYG rich text editor, using [quill.js](https://quilljs.com/).
Press the "Get HTML" button to show the HTML in an alert window.
export default async function(req: Request) {
if (req.method === "POST") {
const name = (await req.formData()).get("name");
return new Response("Hello World");
return new Response(
`<html>
<head>
fetchTwitterUserInfoBroken
@shawnbasquiat
// This approach will use web scraping to fetch user information given a Twitter handle.
HTTP
// This approach will use web scraping to fetch user information given a Twitter handle.
// We'll fetch the public Twitter profile page and extract the required information.
export default async function server(req: Request): Promise<Response> {
const url = new URL(req.url);
const formData = await req.formData().catch(() => null);
const handle = formData?.get('handle') as string | null;
if (!handle) {
return new Response(`
<html>
<head>
getWeather
@chet
Must set process.env.WEATHER_API_KEY for weatherapi.com
Script
/** Must set process.env.WEATHER_API_KEY for weatherapi.com **/
export async function getWeather(
query: string,
days = 10,
): Promise<WeatherApiResponse> {
const weatherApiKey = process.env.WEATHER_API_KEY;
const q = encodeURIComponent(query);
const apiUrl = `https://api.weatherapi.com/v1/forecast.json?key=${weatherApiKey}&q=${q}&days=${days}`;
const response = await fetch(apiUrl);
const data: any = await response.json();
bookmarklets
@vladimyr
Bookmarklet Manager Write your bookmarklets in val.town. Usage You val should export an anonymous function, containing the code that will run when the bookmarklet is triggered. export default () => {
alert("Hi mom!");
} Make sure that your val is either unlisted or public, then navigate to https://pomdtr-bookmarklets.web.val.run/v/:author/:name to generate the bookmarklet link. Sharing a bookmarklet Make sure that your val is public, and add a #bookmarklet tag anywhere in the code. export default () => {
alert("Hi mom!");
}
// #bookmarklet It should automatically appears on https://pomdtr-bookmarklets.web.val.run . ⚠️
If you are using the Arc Browser , you can use the Powerlet extension to install bookmarklets.
HTTP
# Bookmarklet Manager
Write your bookmarklets in val.town.
## Usage
You val should export an anonymous function, containing the code that will run when the bookmarklet is triggered.
```typescript
export default () => {
/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
const app = new Hono();
async function bookmarkletUrl(author: string, name: string) {
const { code } = await api(`/v1/alias/${author}/${name}`);
vtu_updateUser
@rozek
(documentation follows)
Script
(documentation follows)
throwError, quoted,
allowNonEmptyString, expectEMailAddress
} from 'npm:javascript-interface-library'
export default async function updateUser (
UserId:string, Password?:string, Roles?:string
):Promise<void> {
expectEMailAddress ('user id',UserId)
allowNonEmptyString('password',Password)
const normalizedUserId = UserId.toLowerCase().trim()
valle_tmp_8577620427908266060740786834009
@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),
mgsrBotEndpoint2
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export async function mgsrBotEndpoint(request) {
const signatureTimestamp = request.headers.get("X-Signature-Timestamp");
const signatureEd25519 = request.headers.get("X-Signature-Ed25519");
console.log(signatureTimestamp);
console.log(signatureEd25519);
if (!signatureTimestamp || !signatureEd25519) {
return new Response("Signature headers missing!", { status: 400 });
const body = await request.json();
const verified = await verify_discord_signature(
process.env.discord_pubkey,
htmlExample
@antonnyman
An interactive, runnable TypeScript val by antonnyman
HTTP
export const htmlExample = () =>
new Response("<h1>Hello, world</h1>", {
headers: {
"Content-Type": "text/html",
markdownExample
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Express (deprecated)
export const markdownExample = async (req: express.Request, res: express.Response) => {
const marked = await import("npm:marked");
res.send(marked.parse(`
Using Marked, a Markdown Parser
[Marked](https://marked.js.org) is a widely used markdown parser.
Here, we've imported it using \`const marked = await import("npm:marked");\`!
evalPost1
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export let evalPost1 = fetchJSON(
"https://api.val.town/v1/eval",
method: "POST",
body: JSON.stringify({ code: "1+1" }),
vec_prac
@valilo
An interactive, runnable TypeScript val by valilo
Script
export let vec_prac = () => {
const vec_val = () => {
const min = -75;
const max = 75;
return Math.floor(Math.random() * (max - min) + min);
const a = {
1: vec_val(),
2: vec_val(),
3: vec_val(),
const b = {
vanPlateExample
@pomdtr
Van Plate Example of building html using the mini-van lib. Access it at https://pomdtr-vanPlateExample.web.val.run
HTTP
# [Van Plate](https://pomdtr-vanPlateExample.web.val.run)
Example of building html using the [mini-van](https://github.com/vanjs-org/mini-van) lib.
Access it at <https://pomdtr-vanPlateExample.web.val.run>
export async function vanPlateExample(req: Request) {
const { default: van } = await import(
"https://deno.land/x/minivan@0.3.9/src/van-plate.js"
const { a, body, li, p, ul } = van.tags;
return new Response(
van.html(
body(
valle_tmp_471598988784462057650343979850462
@janpaul123
// This demo showcases a sparkline SVG and an animated cat GIF crawling around the screen.
HTTP
// This demo showcases a sparkline SVG and an animated cat GIF crawling around the screen.
// Sparklines are created using the `@stevekrouse/sparklineSVG` module, and the animated
// cat GIF is embedded in the HTML with simple CSS for animation.
// Data for the sparkline chart
const sparklineData = [5, 10, 5, 20, 15, 30, 25];
export default function handler() {
const svg = sparklineSVG({ data: sparklineData });
return html(`
<html>
<head>