Search

Results include substring matches and semantically similar vals. Learn more
ray1214 avatar
dayOfWeek
@ray1214
An interactive, runnable TypeScript val by ray1214
Script
// 星期几(1~7)
export function dayOfWeek() {
const now = new Date();
let day = now.getDay();
pdebie avatar
getLemmyPosts
@pdebie
Fetches the 20 active posts in a community from a specific Lemmy instance.
Script
// This tries to fetch a specific post on multiple Lemmpy instances
// and can try to fix missing comments on a specific instance.
export async function getLemmyPosts(instance: string, communityName: string) {
const { LemmyHttp } = await import("npm:lemmy-js-client");
let client = new LemmyHttp(`https://${instance}`, {
fetchFunction: fetch,
const { posts } = await client.getPosts({
community_name: communityName,
willthereader avatar
formattingEmailContent
@willthereader
An interactive, runnable TypeScript val by willthereader
Script
import { parentCommentChecker } from "https://esm.town/v/willthereader/parentCommentChecker";
import { replaceHTMLWithTextFormatting } from "https://esm.town/v/willthereader/replaceHtmlWithTextFormatting";
export function formattingEmailContent(commentsArray) {
// console.log(commentsArray);
let commentsString = "";
flxa avatar
htmlExample
@flxa
Searchbar
HTTP
// View at https://andreterron-htmlExample.web.val.run?name=Andre
export default async function(req: Request): Promise<Response> {
const query = new URL(req.url).searchParams;
// Read name from the querystring or body. Defaults to "you" if not present.
all avatar
digitalMemorial
@all
@jsxImportSource https://esm.sh/react
HTTP
function App() {
(function frame() {
function randomInRange(min: number, max: number) {
const interval = setInterval(function() {
function randomInRange(min: number, max: number) {
(function frame() {
function fire(particleRatio: number, opts: any) {
function randomInRange(min: number, max: number) {
(function frame() {
function client() {
mauriciobc avatar
MiauFood
@mauriciobc
// This approach uses Val Town's Blob storage for persistence and a simple HTML interface.
HTTP
cats: string[];
export default async function main(req: Request): Promise<Response> {
const url = new URL(req.url);
mdc.autoInit();
function filterByDate(date) {
var parts = date.split('-');
window.location.href = '/log?date=' + formattedDate;
async function deleteEntry(index) {
const response = await fetch('/log', {
window.location.reload();
async function clearAll() {
if (confirm('Are you sure you want to delete all entries?')) {
andreterron avatar
imageUrlToBase64
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
import { Buffer } from "node:buffer";
export async function imageUrlToBase64(res: Response) {
// From https://stackoverflow.com/a/60321567
const buffer = Buffer.from(await res.arrayBuffer());
U9G avatar
parseICSDate
@U9G
// From: https://www.npmjs.com/package/ical-date-parser
Script
// From: https://www.npmjs.com/package/ical-date-parser
export function parseICSDate(str) {
const T_INDEX = 8;
const Z_INDEX = 15;
teretzdev avatar
scrapeProducts
@teretzdev
* Scrape product details from Delta8Pro website * @returns Array of product objects with details
Script
* @returns Array of product objects with details
export default async function scrapeProducts() {
try {
* @returns Formatted string of product previews
export function previewProducts(products, limit = 5) {
return products.slice(0, limit).map(product => {
* @returns Array of scraped products
export async function runAndPreview() {
const products = await scrapeProducts();
* @returns Filtered array of products
export function filterProductsByCategory(products, category) {
return products.filter(product =>
* @returns Sorted array of products
export function sortProductsByPrice(products, ascending = true) {
return [...products].sort((a, b) => {
vtdocs avatar
sha256
@vtdocs
// Copied from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
Script
// Copied from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
export const sha256 = async function digestMessage(message) {
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8); // hash the message
agmm avatar
periodicCertCheck
@agmm
An interactive, runnable TypeScript val by agmm
Cron
import { blob } from "https://esm.town/v/std/blob";
import { email } from "https://esm.town/v/std/email";
export default async function(interval: Interval) {
const domain = "agmm.xyz";
const results = await getCertificates(domain);
techMember avatar
decisiveRoseFelidae
@techMember
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function WeatherDashboard() {
const [theme, setTheme] = useState('light');
useEffect(() => {
async function fetchWeather() {
try {
</div>
function client() {
createRoot(document.getElementById("root")).render(<WeatherDashboard />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
headers: { "content-type": "text/html" }
function generateCSS(theme: 'light' | 'dark') {
return `
arfan avatar
todoApp
@arfan
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
function BeginnerFriendlyTodoApp(): JSX.Element {
async function fetchTodosFromServer() {
function loadUserPreferences() {
function saveUserPreferences() {
function toggleDarkMode() {
async function handleAddTodo(event: React.FormEvent<HTMLFormElement>) {
async function handleDeleteTodo(id: number) {
function openEditOverlay(todo: TodoItem) {
async function handleSaveTodoEdits() {
function handleVisibleFieldToggle(field: keyof typeof visibleFields) {
bdon avatar
usd_twd_converter
@bdon
An interactive, runnable TypeScript val by bdon
Cron
import { email } from "https://esm.town/v/std/email";
import { fetch } from "https://esm.town/v/std/fetch";
function fetchJSON(url) {
return fetch(url).then(res => res.json());
export let currency = async (desired, base = "usd", amount = 1) => {
chet avatar
frostNotify
@chet
An interactive, runnable TypeScript val by chet
Script
import { getWeather } from "https://esm.town/v/chet/getWeather";
import { email } from "https://esm.town/v/std/email";
export async function frostNotify(
where: string,
minTempF = 33,