<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Ben White — Snippets</title>
    <subtitle>Bits and bobs that don&#39;t end up as blogs.</subtitle>
    <link href="https://benwhite.com.au/rss/snippets.xml" rel="self"/>
    <link href="https://benwhite.com.au/"/>
    <updated>2025-08-04T00:00:00Z</updated>
    <id>https://benwhite.com.au/</id>
    <author>
        <name>Ben White</name>
    </author>
    <entry>
        <title>Worker config examples</title>
        <link href="https://benwhite.com.au/snippets/pages-to-workers-config/"/>
        <updated>2025-08-04T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/pages-to-workers-config/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Some config snippets to support the &lt;a href=&quot;https://benwhite.com.au/blog/pages-to-workers/&quot; target=&quot;_blank&quot;&gt;Migrating an 11ty site from Cloudflare Pages to Workers&lt;/a&gt; blog.&lt;/p&gt;
    &lt;h3&gt;Assets only Worker&lt;/h3&gt;
    &lt;p&gt;This config should work for most straight up, simple, no fuss migrations from Cloudflare Pages to Workers.&lt;/p&gt;
    &lt;p&gt;
      &lt;strong&gt;&lt;code&gt;wrangler.jsonc&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;name&quot;: &quot;name-of-worker-here&quot;,
  &quot;compatibility_date&quot;: &quot;2025-05-05&quot;,
  &quot;assets&quot;: { &quot;directory&quot;: &quot;_site&quot;, &quot;not_found_handling&quot;: &quot;404-page&quot; }
}
&lt;/code&gt;&lt;/pre&gt;
    &lt;h3&gt;Assets and Functions (or APIs) Worker&lt;/h3&gt;
    &lt;p&gt;This config should provide a path forward for anyone that was using Cloudflare Pages Functions for simple APIs.&lt;/p&gt;
    &lt;p&gt;
      &lt;strong&gt;&lt;code&gt;wrangler.jsonc&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;name&quot;: &quot;name-of-worker-here&quot;,
  &quot;compatibility_date&quot;: &quot;2025-05-05&quot;,
  &quot;main&quot;: &quot;src/index.js&quot;,
  &quot;assets&quot;: {
    &quot;directory&quot;: &quot;_site&quot;,
    &quot;not_found_handling&quot;: &quot;404-page&quot;,
    &quot;run_worker_first&quot;: [&quot;/api/*&quot;]
  }
}
&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      &lt;strong&gt;&lt;code&gt;src/index.js&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    if (url.pathname.startsWith(&#39;/api/&#39;)) {
      // API code goes here.
      const exampleResponse = { hello: &#39;world&#39; };
      return Response.json(exampleResponse);
    }
    return request;
  },
};
&lt;/code&gt;&lt;/pre&gt;
    &lt;h3&gt;Assets (via middleware) and API Worker&lt;/h3&gt;
    &lt;p&gt;This is a more advanced path for users who were using Cloudflare Pages Functions for simple APIs along with &lt;code&gt;_middleware.js&lt;/code&gt; for intercepting and modifying responses on the way through. You could probably do it without switching over to &lt;code&gt;hono&lt;/code&gt;, but from my limited time using it, &lt;code&gt;hono&lt;/code&gt; is &lt;em&gt;excellent&lt;/em&gt; and worth the time learning how it works.&lt;/p&gt;
    &lt;p&gt;This will push pretty much everything through the Worker, so tread with caution if you&#39;re running a site with spiky traffic.&lt;/p&gt;
    &lt;p&gt;
      &lt;strong&gt;Install &lt;code&gt;hono&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;npm install hono
&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      &lt;strong&gt;&lt;code&gt;wrangler.jsonc&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;name&quot;: &quot;name-of-worker-here&quot;,
  &quot;main&quot;: &quot;src/index.js&quot;,
  &quot;compatibility_date&quot;: &quot;2025-05-05&quot;,
  &quot;assets&quot;: {
    &quot;binding&quot;: &quot;ASSETS&quot;,
    &quot;directory&quot;: &quot;_site&quot;,
    &quot;run_worker_first&quot;: true
  },
  &quot;services&quot;: [{ &quot;binding&quot;: &quot;SELF&quot;, &quot;service&quot;: &quot;name-of-worker-here&quot; }]
}
&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      &lt;strong&gt;&lt;code&gt;src/index.js&lt;/code&gt;&lt;/strong&gt;
    &lt;/p&gt;
    &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;import { Hono } from &#39;hono&#39;;

const app = new Hono();

// Set up API routes.
app.get(&#39;/api/*&#39;, (c) =&gt; {
  const exampleResponse = { hello: &#39;world&#39; };
  return c.json(exampleResponse);
});

// Serve static assets with middleware support.
app.get(&#39;*&#39;, async (c) =&gt; {
  try {
    // Bail early for non-HTML requests (fonts, images, etc).
    const accept = c.req.header(&#39;accept&#39;) || &#39;&#39;;
    if (!accept.includes(&#39;text/html&#39;)) {
      return await c.env.ASSETS.fetch(c.req.url);
    }
    // Get requested the asset from the _site build.
    const assetResponse = await c.env.ASSETS.fetch(c.req.url);
    if (assetResponse.ok) {
      // Add &#39;hello world&#39; to the asset HTML response.
      return new HTMLRewriter()
        .on(&#39;body&#39;, {
          async element(element) {
            element.prepend(&#39;&amp;lt;h1&gt;hello world&amp;lt;/h1&gt;&#39;, { html: true });
          },
        })
        .transform(assetResponse);
    }
  } catch (error) {
    console.error(error);
  }
  return c.notFound();
});

// Handle 404s gracefully.
app.notFound(async (c) =&gt; {
  const url = new URL(c.req.url);
  const res = await c.env.SELF.fetch(`${url.origin}/404`);
  return c.html(await res.text(), 404);
});

export default app;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>Louis Cole</title>
        <link href="https://benwhite.com.au/snippets/louis-cole/"/>
        <updated>2025-02-20T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/louis-cole/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;I don&#39;t remember how I stumbled onto Clown Core, but I do remember how it made me feel.&lt;/p&gt;
    &lt;p&gt;Watch this, and see how you feel.&lt;/p&gt;
    &lt;p&gt;&lt;video-youtube webc:nokeep=&quot;&quot; id=&quot;sR_rPd_ufK4&quot;&gt;&lt;/video-youtube&gt;&lt;/p&gt;
    &lt;p&gt;When you get past all of the... unsettling feelings... all that is left is insane, raw talent and one of the coolest songs you&#39;ve ever heard.&lt;/p&gt;
    &lt;p&gt;I went down the Google rabbit hole, trying to work out who the band was. At that time, there was no Wikipedia article, and there wasn&#39;t much on who they were or why there was clowns.&lt;/p&gt;
    &lt;p&gt;At some point I added a few Clown Core songs to some playlists in Spotify, and this &lt;em&gt;Louis Cole&lt;/em&gt; guy started popping up in my recommendations.&lt;/p&gt;
    &lt;p&gt;I eventually came across this song and was like yep, this artist and friends are absolutely, 100%, Clown Core.&lt;/p&gt;
    &lt;p&gt;&lt;video-youtube webc:nokeep=&quot;&quot; id=&quot;_1PdtPuaS-k&quot;&gt;&lt;/video-youtube&gt;&lt;/p&gt;
    &lt;p&gt;Didn&#39;t take me too long to then stumble into KNOWER and this track, which might be a top 5 of all time song for me. It is just the coolest song ever. Every person in the clip is the coolest, most talented person I&#39;ve ever seen.&lt;/p&gt;
    &lt;p&gt;&lt;video-youtube webc:nokeep=&quot;&quot; id=&quot;Ois3gfcwKSA&quot;&gt;&lt;/video-youtube&gt;&lt;/p&gt;
    &lt;p&gt;There are &lt;a href=&quot;https://www.youtube.com/watch?v=GZlVT8gPGEs&quot; target=&quot;_blank&quot;&gt;so&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=6Gha9xrM10w&quot; target=&quot;_blank&quot;&gt;many&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=NDpeHQUSWT0&quot; target=&quot;_blank&quot;&gt;other&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=ls17vqcH-Xw&quot; target=&quot;_blank&quot;&gt;great&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=RqQgBDzHLPM&quot; target=&quot;_blank&quot;&gt;songs&lt;/a&gt;. Add them to your playlists. Tell your kids about them.&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>The Flaming Lips</title>
        <link href="https://benwhite.com.au/snippets/flaming-lips/"/>
        <updated>2025-02-03T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/flaming-lips/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;The Flaming Lips played at the Hordern in Sydney last night. It was a fairly standard Flaming Lips show — which is to say it was a really, really fun time.&lt;/p&gt;
    &lt;p&gt;I wouldn&#39;t call myself a diehard fan, but I&#39;ve been lucky enough to catch every one of their Australian shows since 2009. And &lt;em&gt;every time&lt;/em&gt;, I&#39;ve left feeling good about life — like things are gonna be alright. That might seem odd if you focus on the lyrics about death by volcano or inevitable selfishness that comes with power. But it&#39;s not weird at all if you&#39;ve seen them live, where the overwhelming message and tone is love.&lt;/p&gt;
    &lt;p&gt;In 2016, a friend I brought along had a bad day. They knew a few Flaming Lips songs but weren&#39;t really into the band. Work had been rough, and they&#39;d struggled to find parking at the venue. They plonked down in the stands, frowning. But by the end of the &lt;em&gt;first verse of the first song&lt;/em&gt;, that frown was gone, and in its place was the biggest smile I&#39;d seen since their wedding day.&lt;/p&gt;
    &lt;p&gt;This is The Flaming Lips&#39; superpower. For a band that came into this world &lt;em&gt;a year before I was born&lt;/em&gt; to still be touring with so much energy and love to share... blows the mind.&lt;/p&gt;
    &lt;p&gt;The crowd last night was a mix of families with young kids (babies, even!), uni students, and older folks from all walks of life. At one point I was standing next to a politician (👋 Tanya Plibersek).&lt;/p&gt;
    &lt;p&gt;The highlight for me was &lt;em&gt;Pompeii am Götterdämmerung&lt;/em&gt;, being blanketed in black confetti. Yay, volcanoes!&lt;/p&gt;
    &lt;p&gt;If you haven&#39;t seen them live, do yourself a favour and grab a ticket when they&#39;re in your town.&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>Tech resolutions</title>
        <link href="https://benwhite.com.au/snippets/resolutions/"/>
        <updated>2025-01-13T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/resolutions/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;My new year (tech) resolutions are to have some fun with:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://www.jetify.com/devbox&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;Devbox&lt;/strong&gt;&lt;/a&gt; Can I replace Docker for my local dev environment?
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;HTMLRewriter&lt;/strong&gt;&lt;/a&gt; How much can I (or should I!?) mess with content on the edge?
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://cube.fyi/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;CUBE CSS&lt;/strong&gt;&lt;/a&gt; Would this methodology be worth adopting? What problems does it solve?
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://htmx.org/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;htmx&lt;/strong&gt;&lt;/a&gt; I&#39;m very happy with static build + Alpine.js, what benefits would &lt;code&gt;htmx&lt;/code&gt; provide?
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://github.com/11ty/eleventy/issues/3388&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;11ty docs&lt;/strong&gt;&lt;/a&gt; I dropped the ball on this last year. I&#39;d like to make a meaningful contribution towards the docs this year.
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;https://pixelfed.org/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;Pixelfed&lt;/strong&gt;&lt;/a&gt; After spinning up a private instance, would I be able to get my friends and family to delete Instagram?
      &lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;What are your tech resolutions? &lt;a href=&quot;https://infosec.exchange/@d3v1an7&quot; target=&quot;_blank&quot;&gt;Let me know&lt;/a&gt;!&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>The last Gambino</title>
        <link href="https://benwhite.com.au/snippets/bando-stone/"/>
        <updated>2024-07-25T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/bando-stone/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Childish Gambino&#39;s latest album, &lt;a href=&quot;https://open.spotify.com/album/1jzqiffupvhniPZB4aBNEv&quot; target=&quot;_blank&quot;&gt;Bando Stone and The New World&lt;/a&gt; is a very Gambino ride, and comes close to topping &lt;a href=&quot;https://open.spotify.com/album/62yjWIhnATHxPqGbgC9Lqr&quot; target=&quot;_blank&quot;&gt;Because the Internet&lt;/a&gt; for me. It&#39;s so diverse! The production is so good and weird!&lt;/p&gt;
    &lt;p&gt;There is a tiny sample from Undertale in the first track, which on the whole, reminds me of the opening of Yeezus. I&#39;ve been whisting along to &lt;em&gt;Lithonia&lt;/em&gt; all week. The Prodigy sample in &lt;em&gt;Got To Be&lt;/em&gt; is perfect. Steve Lacy vibes on &lt;em&gt;Dadvocate&lt;/em&gt;.&lt;/p&gt;
    &lt;p&gt;Check it out! Or don&#39;t! That&#39;s also fine.&lt;/p&gt;
    &lt;p&gt;&lt;video-youtube webc:nokeep=&quot;&quot; id=&quot;co-bx0mBsLc&quot;&gt;&lt;/video-youtube&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>Outsource naming things</title>
        <link href="https://benwhite.com.au/snippets/naming-things/"/>
        <updated>2024-06-20T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/naming-things/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;No, but really, &lt;em&gt;every single time&lt;/em&gt; I socialise what I&#39;m thinking when writing or refactoring &quot;important stuff&quot;, I get feedback that greatly improves clarity.&lt;/p&gt;
    &lt;p&gt;Today I started with:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;paid_subscriber_list&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;registered_user_list&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;Fine I guess, technically correct, but it wasn&#39;t sitting quite right. So I threw it out there, and within 10 seconds we ended up with:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;paid_user_list&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;nonpaid_user_list&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;Less ambiguity, more consistent verbiage, chef kiss.&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
    <entry>
        <title>Kumano Kodo in 16 minutes</title>
        <link href="https://benwhite.com.au/snippets/kumano-kodo/"/>
        <updated>2024-06-20T00:00:00Z</updated>
        <id>https://benwhite.com.au/snippets/kumano-kodo/</id>
        <content type="html">&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;It was beautiful. I think about it often, and would do it again in a heartbeat.&lt;/p&gt;
    &lt;p&gt;The edit is a bit zoomy cause I was trying to fit 6 days worth of footage into a single video. When I have a spare weekend, I&#39;ll probably do a day-by-day recut and write up a blog to go with it.&lt;/p&gt;
    &lt;p&gt;But until then, please enjoy.&lt;/p&gt;
    &lt;p&gt;&lt;video-youtube webc:nokeep=&quot;&quot; id=&quot;d33uwAD8o6I&quot;&gt;&lt;/video-youtube&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</content>
    </entry>
</feed>