Search
expSumOfTheDay
@hodge
Exponential Sum Plot Generator An homage to John D. Cook's Exponential Sum of the Day The plot shows the partial sums of the exponential sum: Σ(n=0 to N) exp(2πi(n/m + n²/d + n³/y)) The real part of the sum is plotted on the x-axis, and the imaginary part of the sum is plotted on the y-axis.
HTTP
export async function expSumPlot(req) {
const d3 = await import("npm:d3");
const document = await import("https://esm.sh/linkedom@0.15").then((l) => l.parseHTML("<a>").document);
const data = expSumData();
function render(data) {
beckerBarley
@fil
Becker’s Barley trellis SSR chart with Observable Plot This chart is rendered server-side by val.town, using Observable Plot, from data loaded from the GitHub API. For a more complete example, see https://www.val.town/v/fil.earthquakes. For information on this chart, see https://observablehq.com/@observablehq/plot-barley-trellis.
HTTP
const Plot = await import("https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.14/+esm");
const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
const { document } = await import("https://cdn.jsdelivr.net/npm/linkedom@0.15/+esm").then((
{ parseHTML: p },
) => p(`<a>`));
earthquakes
@fil
Earthquake map 🌏 This val loads earthquake data from USGS, a topojson file for the land shape, and supporting libraries. It then creates a map and save it as a SVG string. The result is cached for a day. Note that we must strive to keep it under val.town’s limit of 100kB, hence the heavy simplification of the land shape. (For a simpler example, see becker barley .) | | |
|-----|-----|
| Web page | https://fil-earthquakes.web.val.run/ |
| Observable Plot | https://observablehq.com/plot/ |
| linkedom | https://github.com/WebReflection/linkedom |
| topojson | https://github.com/topojson/topojson |
| earthquakes | https://earthquake.usgs.gov |
| world | https://observablehq.com/@visionscarto/world-atlas-topojson |
| css | https://milligram.io/ |
HTTP
| Observable Plot | https://observablehq.com/plot/ |
| linkedom | https://github.com/WebReflection/linkedom |
| topojson | https://github.com/topojson/topojson |
let [Plot, { document }, topojson, quakes, world] = await Promise.all([
import("https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.14/+esm"),
import("https://cdn.jsdelivr.net/npm/linkedom@0.15/+esm").then((l) => l.parseHTML("<a>")),
import("https://cdn.jsdelivr.net/npm/topojson@3/+esm"),
fetch(dataUrl).then((r) => r.json()),
jmpblog2lemmy
@singpolyma
An interactive, runnable TypeScript val by singpolyma
Cron
export default async function(interval: Interval) {
const baseUrl = "https://lemmy.ml";
const client: LemmyHttp = new LemmyHttp(baseUrl);
client.setHeaders({ Authorization: `Bearer ${Deno.env.get("LEMMY_JWT")}` });
const feed = await (await fetch("https://blog.jmp.chat/atom.xml")).text();
const parsed = await parseFeed(feed);
const entry = parsed.entries[parsed.entries.length - 1];
const lastPosted = await blob.getJSON("jmp_lemmy_last_posted");
console.log(lastPosted, entry);
if (lastPosted === entry.id) return;
link_of_the_day
@robik
An interactive, runnable TypeScript val by robik
Script
export async function link_of_the_day() {
const rawResponse = await retrieve_pocket({
state: "unread",
detailType: "simple",
console.log(rawResponse);
const unreadLinks = Object.values(rawResponse.list);
const randomNumber = Math.round(Math.random() * unreadLinks.length);
const chosenLink = unreadLinks[randomNumber];
const today = new Intl.DateTimeFormat("it-IT", {
year: "numeric",
MyFooter
@leomp12
Fork this if you want to share random vals from your likes in your projects!
HTTP
Fork this if you want to share random vals from your likes in your projects!
const USERNAME = extractValInfo(import.meta.url).author;
const hello = Deno.env.get("HELLO_WORLD");
export async function MyFooter(logo = valTownLogoAuto) {
const recommendation = rootValRef().handle === USERNAME
? html`<span class="recommends">${await recommends()}</span>`
return html`
<footer>
Made by
<a href="https://val.town/u/${USERNAME}" target="_blank">@${USERNAME}</a>