Search
arrayDiff
@sprice
An interactive, runnable TypeScript val by sprice
Script
export function arrayDiff(a, b) {
return a.filter((e) => !b.includes(e));
convertString
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
export function convertString(string) {
// Convert uppercase letters to lowercase
let convertedString = string.toLowerCase();
sharpCoralCoyote
@tompatiger
An interactive, runnable TypeScript val by tompatiger
Script
"The mind is everything. What you think you become."
return quotes
# Test the function
quotes = get_quotes()
print(random.choice(quotes))
googleFavicons
@vladimyr
// SPDX-License-Identifier: 0BSD
Script
// SPDX-License-Identifier: 0BSD
const GOOGLE_FAVICONS_BASE_URL = "https://www.google.com/s2/favicons";
export function createFaviconURL(url: string | URL, size = 16): URL {
const { hostname } = new URL(url);
const faviconURL = new URL(GOOGLE_FAVICONS_BASE_URL);
BlueCardChangeDetector
@wilhelm
Sends me an email if Sweden's requirements for EU Blue Card changes. Checks once an hour.
Cron
"https://www.migrationsverket.se/English/Private-individuals/Working-in-Sweden/Employed/Special-rules-for-certain-occupations-and-citizens-of-certain-countries/EU-Blue-Card.html";
const dateChangedKey = "work-permit-change-date";
export default async function(interval: Interval) {
const page = await fetch(site).then(res => res.text());
const date = page.match(/Last updated: <time datetime="([^"]+)">/)?.[1].toString();
readwiseReaderReadItemsRss
@zerovox
Creates an RSS feed of my read items from Readwise Reader. Reader docs here: https://readwise.io/reader_api In order to get read items from Readwise Reader -> Workflowy, this turns the read items (aka "archive") into an RSS feed, which Zapier picks up, and creates bullets in Workflowy. Ideally would store the generated RSS or the last fetch date, and only get new items, but for now readwiseReaderDocumentList re-fetches the full history each time.
HTTP
import { readwiseReaderDocumentList } from "https://esm.town/v/zerovox/readwiseReaderDocumentList";
export async function readwiseReaderReadItemsRss() {
// Get all of a user's archived documents
rssLink: "https://zerovox-readwisereaderreaditemsrss.web.val.run",
function escapeXml(unsafe) {
return unsafe.replace(/[<>&'"]/g, function(c) {
switch (c) {
base256kitten
@vladimyr
// SPDX-License-Identifier: AGPL-3.0-or-later
Script
p[c.codePointAt(0) as number] = i;
return p;
export function encode(data: Uint8Array): string {
return data.reduce((p, c) => {
p += alphabetBytesToChars[c];
return p;
export function decode(str: string): Uint8Array {
const byts = [];
for (const char of str) {
effect
@dvdsgl
// Make a string like 3.1s or 123ms from a Duration
Script
? `${Duration.toSeconds(d).toFixed(1)}s`
: `${Duration.toMillis(d)}ms`;
export function withTimeLog<A, E, C>(
label: string,
): (self: Effect.Effect<A, E, C>) => Effect.Effect<A, E, C> {
return (self) =>
Effect.gen(function*() {
const start = yield* Clock.currentTimeMillis;
const result = yield* self;
hitCounter
@triptych
Create a simple hit counter that you can attach to any website via fetch . I created a web component to use this :
export class HitCounter extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.count = 0;
this.fetchCount();
}
fetchCount() {
fetch('https://triptych-hitcounter.web.val.run/')
.then(response => response.json())
.then(data => {
this.count = data.siteCount;
this.render();
})
.catch(error => console.error('Error fetching count:', error));
}
render() {
const container = document.createElement('div');
container.style.backgroundColor = 'black';
container.style.color = 'white';
container.style.border = '1px solid white';
container.style.padding = '10px';
container.style.display = 'inline-block'; // Add this line
container.textContent = `hit count: ${this.count}`;
this.shadowRoot.appendChild(container);
}
}
customElements.define('hit-counter', HitCounter);
HTTP
await blob.setJSON(KEY, oldState + 1);
const siteCount = await blob.getJSON(KEY);
export default async function(req: Request): Promise<Response> {
return Response.json({ siteCount });
aspBadge
@vladimyr
ASP badge generator This is small SVG badge generator made for Ariadne.id Signature Profiles . Route format is: https://vladimyr-aspbadge.web.val.run/<aspe_uri> with optional format and debug query params. Use ?format=json to get back JSON response.
JSON format can be used as an input for Shields.io's dynamic endpoint badge . Badge with legacy ASPE URI:
[![](https://vladimyr-aspbadge.web.val.run/aspe:keyoxide.org:TOICV3SYXNJP7E4P5AOK5DHW44)](https://keyoxide.org/aspe:keyoxide.org:TOICV3SYXNJP7E4P5AOK5DHW44) ๐ฌ๏ธ inspect ASP JWT token Badge with new ASPE URI (not functional yet โ ๏ธ):
[![](https://vladimyr-aspbadge.web.val.run/aspe:fe7b75c54b95ac019dd48fbefe8d654af383cbfe)](https://keyoxide.org/aspe:fe7b75c54b95ac019dd48fbefe8d654af383cbfe)
HTTP
[๐ฌ๏ธ inspect ASP JWT token](https://vladimyr-aspe_inspector.web.val.run/aspe:keyoxide.org:TOICV3SYXNJP7E4P5AOK5DHW44)
Badge with new ASPE URI (not functional yet โ ๏ธ):
[![](https://vladimyr-aspbadge.web.val.run/aspe:fe7b75c54b95ac019dd48fbefe8d654af383cbfe)](https://keyoxide.org/aspe:fe7b75c54b95ac019dd48fbefe8d654af383cbfe)
const BADGE_COLOR = "6855c3";
export default async function(req: Request): Promise<Response> {
const reqURL = new URL(req.url);
"content-type": "image/svg+xml",
async function getBadgeConfig(aspeUri: string, debug = false): Promise<BadgeConfig> {
const config: BadgeConfig = {
return config;
async function processAspeUri(aspeUri: string) {
let aspeURI: AspeURI | LegacyAspeURI = parseAspeURI(aspeUri);
generateColor
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
import { convertRGBToHex } from "https://esm.town/v/rodrigotello/convertRGBToHex";
export function generateColor(cssColorObject) {
return `#${
Object.values(cssColorObject)
dailySubscriptionStats
@petermillspaugh
Val Town email subscriptions: daily stats Cousin Val to @petermillspaugh/emailSubscription for emailing yourself daily subscriber stats.
Cron
verified: 0 | 1,
totalSubs: number,
export async function dailyEmailSubscriptionStats(interval: Interval) {
const { rows: newSubs } = await sqlite.execute(`
SELECT name, email
computeSchedule
@xkonti
computeSchedule function Combines several schedule segments together to form a complete schedule for a 24-hour period. Parameters: scheduleSegments - An array of ScheduleSegment objects describing the daily loop. Returns: An array of TimeSpan objects representing the complete schedule for the device. TimeSpan type Represents a span of time with a starting point and a duration in minutes. DutyCycle type Represents the "on" state scheduling pattern for a device. It's similar to the concept of Pulse-Width Modulation (PWM). ScheduleSegment type A part of a complete schedule, describing a time frame with a specified duty cycle.
Script
# `computeSchedule` function
Combines several schedule segments together to form a complete schedule for a 24-hour period.
validateHTMLandCSS
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
column: number;
function validateHTML(html: string): ValidationResult {
const errors: ValidationResult['errors'] = [];
return { isValid: errors.length === 0, errors };
function validateCSS(css: string): ValidationResult {
const errors: ValidationResult['errors'] = [];
return { isValid: errors.length === 0, errors };
export function validateHTMLAndCSS(code: string): ValidationResult {
const htmlErrors = validateHTML(code);