) provide a simple API for requesting a random cat photo: https://cataas.com/cat . Coda (trying to be helpful) caches images it fetches, so that if you try to add multiple images with that same URL you’ll only get a random cat the first time you add it to the doc, and a copy of it every other time. To get around this we need to do some cache busting. This is the process of adding a value to each URL that will make it unique, therefore causing Coda to fetch a new copy, and get a new cat.
An easy way to get a unique string is to utilize the current date and time, since it will never repeat. However I don’t want the cats to fly by every millisecond, so we’ll need to do some rounding so that the time is only unique every few seconds. Using some of the Date formulas we can do just that!
Time Rounded to Minute:
Rounding the time down to the nearest minute, since we’ll be handling the seconds separately.
8/19/2021 5:10 PM
Using the value of the slider at the top of the doc, round the seconds to the nearest interval.
Floor(Now("seconds").Second() / [Seconds Per Cat]) * [Seconds Per Cat] =>
Combine the two values above to compute the rounded time.
[Time Rounded to Minute] + Seconds([Rounded Seconds]) =>
8/19/2021 5:10:45 PM
Rounded Time as Number:
Convert the time to a number, since that’s easier to plug into a URL (no spaces).
[Rounded Time].ToNumber() =>
Cat Image URL:
Put the time at the end of the URL in a fake parameter called now that