Back

Val.town

If you’re like me, you’ve probably run into the case that you need to run scripts every week, day or every hour. Maybe you want to monitor the daily scoreboard of Advent of Code. Maybe you want to post the status of the Strava running challenge to a Slack channel each week.

I found val.town on hacker news some time ago and have since ported all my scripts to use it.

In this post I have collected some example use-cases:

Monitor Advent of Code score board

Every day in December (at 12, to give everyone a chance to solve the puzzle), we post the scoreboard to the #aoc work Slack channel. First there is the time challenge - and later the total stars.

Advent of Code does provide an API which just requires cookie authentication. - Easily achiveable with val.town.

Summarize the Strava challenge

Every week, we post the current leaderboard of the local running group to a Slack channel.

This is slightly more involved, since Strava does not provide an API anymore. We have to scrape the website and parse the HTML to provide a plaintext representation of the current standing.

This integration also needs to store state, since we want to know if someone has improved their score since last week.

Val.town provides a simple key-value store which can be used for this.

import { blob } from "https://esm.town/v/std/blob?v=3";

await blob.setJSON("stateExample1", { foo: "bar" });

await blob.getJSON("stateExample1");

Find available online booking times

It all started when I got a gift card from my parents for a barber shop. — I wanted to book an appointment, but no times were available for the next 2 months.

Using the browser devtools I inspected the JSON API and wrote a script that calls the API every hour, and send a push notification to my phone when an earlier time would appear.

I ended up getting a time in about a week.

Johan