Search

Results include substring matches and semantically similar vals. Learn more
tmcw avatar
formatFloat
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
[87, "⅞"],
// TODO: refactor
export function formatFloat(a: number) {
const intPart = Math.floor(a);
const remainder = Math.floor((a - intPart) * 100);
xkonti avatar
timeSpanUnion
@xkonti
timeSpanUnion function Combines overlapping time spans into single time spans. Parameters: timespans - An array of TimeSpan objects to unify. Returns: An array of unified TimeSpan objects. TimeSpan type Represents a span of time with a starting point and a duration in minutes.
Script
# `timeSpanUnion` function
Combines overlapping time spans into single time spans.
tmcw avatar
big_stories_ranks
@tmcw
// set by tmcw.big_story at 2023-07-21T13:27:35.553Z
Script
"ranks": [[1689676050115, 8], [1689679650435, 9], [1689683250422, 9], [1689686850141, 9], [1689690449649, 9], [1689694050
"https://www.nytimes.com/2023/07/18/technology/openai-chatgpt-facial-recognition.html": {
"title": "OpenAI Worries About What Its Chatbot Will Say About People’s Faces",
"url": "https://www.nytimes.com/2023/07/18/technology/openai-chatgpt-facial-recognition.html",
"section": "technology",
eczajk avatar
bulletJournalMonth
@eczajk
An interactive, runnable TypeScript val by eczajk
Script
export async function bulletJournalMonth(month, year) {
const d = new Date();
let month2 = typeof month === "number" ? month : d.getMonth();
chet avatar
diffLines
@chet
An interactive, runnable TypeScript val by chet
Script
export function diffLines(before: string, after: string) {
const addedLines = new Set(after.split("\n"));
before.split("\n").forEach((line) => addedLines.delete(line));
iamseeley avatar
flashBorder
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
export function flashBorder(element) {
if (!element) return;
let flash = true;
shanberg avatar
theme
@shanberg
An interactive, runnable TypeScript val by shanberg
Script
transitionDuration: "fast",
transitionTimingFunction: "ease-out",
cursor: "pointer",
transitionDuration: "fast",
transitionTimingFunction: "ease-out",
cursor: "pointer",
transitionDuration: "ultra-fast",
transitionTimingFunction: "ease-in",
_focus: {
fiberplane avatar
OpenTelemetryCollector
@fiberplane
A simple service that can receive OpenTelemetry traces from a Hono api instrumented with @fiberplane/hono-otel
HTTP
function getOpenAPISpec() {
function getExampleTracePayload() {
"{\"OPENAI_API_KEY\":\"sk-proj-uoRQ71Oaz16IbDJRJXY5T3BlbkFJgqSSf3Xglg0V0V2FhFrO\",\"ANTHROPIC_API_KEY
function logger() {
async function fromCollectorRequest(
async function mapAttributeValue(value: IAnyValue): Promise<AttributeValue> {
async function mapAttributes(
async function mapEvent(event: IEvent) {
async function mapLink(link: ILink) {
function stringOrUintToString(id: string | Uint8Array) {
fil avatar
d3ChordDiagram
@fil
D3 Chord diagram Example taken from the D3 Gallery , and rendered (server-side) as a static SVG served through the web end point .
HTTP
import { svgServer } from "https://esm.town/v/fil/svgServer";
export async function d3ChordDiagram(req) {
// Import D3 and create a DOM document for server-side-rendering.
return svgServer(req, chart(data).outerHTML);
function chart(data) {
const width = 640;
return svg.node();
function groupTicks(d, step) {
const k = (d.endAngle - d.startAngle) / d.value;
saolsen avatar
example_rust_http_val
@saolsen
Built from https://gist.github.com/saolsen/294683088bae9a8f9a8cf93e2b392729 See https://gist.github.com/saolsen/d273bb1baba5e912e4dc2b187511affa for how to build a rust val. See https://www.val.town/v/saolsen/use_example_rust_http_val for how to use this.
Script
function getUint8Memory0() {
function getStringFromWasm0(ptr, len) {
const encodeString = typeof cachedTextEncoder.encodeInto === "function"
? function(arg, view) {
: function(arg, view) {
function passStringToWasm0(arg, malloc, realloc) {
function getInt32Memory0() {
function getObject(idx) {
function dropObject(idx) {
function takeObject(idx) {
wilt avatar
formatCurrentDatetimeSentence
@wilt
// Outputs, e.g., "It is currently Sunday, May 21, 2023 at 12:11:04 PM Pacific Daylight Time."
Script
// Outputs, e.g., "It is currently Sunday, May 21, 2023 at 12:11:04 PM Pacific Daylight Time."
// timeZone should be a tz identifier as listed at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
export function formatCurrentDatetimeSentence(timeZone: string): string {
const dateFormatter = new Intl.DateTimeFormat([], {
dateStyle: "full",
willthereader avatar
brokenCountVowels
@willthereader
An interactive, runnable TypeScript val by willthereader
Script
export function brokenCountVowels(str) {
const lowerStr = str.toLowerCase();
const vowels = ["a", "e"]; // Still broken - only counting 'a' and 'e'
iakovos avatar
formatFeedDate
@iakovos
An interactive, runnable TypeScript val by iakovos
Script
export function formatFeedDate(dateString: string): string {
const options: Intl.DateTimeFormatOptions = {
year: "numeric",
charmaine avatar
valTownProPerks
@charmaine
Other awesome perks I found for Val Town Pro hidden in docs, not covered on the Pricing Page . Updated: Oct 5, 2024. Subject to change. Custom Domains Ability to have custom domains Additional std/email Options Ability to email anyone via the to, cc, and bcc fields socialDataProxy to retrieve data from X 100 calls to SocialData every day, which will allow for calling it in an interval that runs once every 15 min
Script
**socialDataProxy to retrieve data from X**
ww.val.town/v/stevekrouse/socialDataSearch) every day, which will allow for calling it in an interval that runs once every 15
rwev avatar
wrapInHTMLElements
@rwev
An interactive, runnable TypeScript val by rwev
Script
export function wrapInHTMLElements(
elements: string | string[],
html: string