Header logo.
small hallucinations
home • years • tags • about • rss

A Few Updates on Morceau

I've been working on a reading app I'm calling Morceau for now. The name is a metaphor for reading a long piece of text in little bites, like nibbling on breadcrumbs.

For the longest time, I insisted on building the backend in Elixir because I liked its elegant syntax and how easy GenServers made it to send messages between processes. I seriously considered using Cloudflare Workers from day one, but decided against it partly because I wanted to avoid vendor lock-in. (Looking back, that was probably overthinking.)

I deployed my last product, a word game named Lexocube, on Railway. These days it barely has any daily active users, and Railway still charges me about $5 a month. Elixir apps are good at handling lots of concurrent requests (an overkill), and I assume Railway keeps the server running so it’s ready for them. (I didn’t check.) With so few players, CPU, storage, and bandwidth barely showed up on the bill. The surprise was how much I was paying for memory.

This time around, when I deployed the Morceau backend to staging, I chose Hetzner. I figured I could run the app alongside a Postgres instance for a flat fee. I didn't want to SSH into the server and type commands to configure it. That felt cumbersome. So I installed Coolify.

Coolify is a great piece of software. It lets you run projects and attach resources to them. (The GUI is a bit too complicated.) For my project, I linked a GitHub repository and attached a Postgres database. What's useful is that Coolify notifies you about the most recent dependency updates. That saved me a lot of headaches during the recent flurry of CVEs. I can imagine how painful it would be to hunt down every update and apply it by hand.

For the first week, both Coolify and my backend ran perfectly. Then one day, I noticed that four recent deployments of the backend service I managed in Coolify had failed. I could've paid more attention to error messages, but this is the staging environment for a product that's still early in development.

With Codex's help, I waded through the logs and was surprised to find that the server had run out of memory while building the Elixir binary. Following a misleading suggestion from Codex, I tried different versions of Elixir, Erlang, and one Elixir dependency. It turned out that Coolify was using 1.2 GB of the VPS's 2 GB of RAM. (The VPS is a good deal. It costs less than what I pay Railway for memory.) I tried increasing the size of the swap file, but that didn't work either. (The last time I resized a swap file, I was probably in high school.)

Then I asked myself why don't I just hosted everything on Cloudflare? It would've been much easier to deploy and configure. Since Morceau is still early in development and has only test users, I probably won't need to pay Cloudflare a dime for a long time.

The rewrite was simple enough. The TypeScript code Codex generated was easy enough to read. (I still prefer reading Elixir code.) Codex missed one small thing though. It didn't find the R2 bucket I was already using, so it created a new one without asking me. I fixed that manually.

I created a migration file that reflected the latest state of the schema of the Postgres database. I then exported the Postgres database from the VPS, converted the data to SQLite, and loaded it into the D1 database on Cloudflare. Everything is working fine now.

Ah, well, I really should start talking to potential users.

In the meantime, I shipped a few features for Morceau. Now, When Morceau ingests a webpage, it tries to extract the article's hero image. With this new feature, I crop a distinctive part of the image to use as the article's “icon” and use the image to generate three pairs of background and text colors that readers can choose from. Pretty cute, isn't it?

While looking for a way to parse webpages, I found out that the now-defunct Omnivore used a library called Readability.js. I thought the algorithm was quite clever. It uses a few heuristics to guess which elements belong to the main article. I adapted the algorithm and added domain-specific preprocessors to improve ingestion.

◆

Email OTP and the Case of the Missing Logo

I was implementing authentication for a service I was building.

I've been logging in to a few online services using Passkeys, though I don't remember opting in.

Logging in with a fingerprint on my Mac is a quality-of-life improvement. Upon reading how passkeys work, however, I didn't quite understand why it was necessary. There are complaints on the internet.

So for my service, I implemented email OTP instead. If it's about liberating the user from remembering another password, I believe the six-digit login code is much easier for developers and sufficiently familiar to users, at least for a non-critical and non-sensitive service.

I also updated the login-code email template, although I had a hard time including the logo. It turned out email services would strip out inline SVG markup and base64 data URLs from the embedded HTML. (It was very entertaining to watch AI painstakingly try and fail to reproduce the logo with an elaborate table.)

The correct approach is to set the image source in the email's HTML to a cid: URL, attach the base64-encoded PNG to the message, and assign the attachment a matching Content-ID. With those IDs linked up, the image renders correctly and the email is ready to send.

◆

Streaks Are for Boring Things

I was studying the UX design of Apple Books and noticed that at the bottom of the Home screen, there is a reading goal progress dial, followed by your current streak, and your longest streak. You keep the streak alive if you spend enough time reading in the Apple Books app to meet your goal.

This streak design is not really a source of bragging rights, as there isn't much of a social element in Apple Books. There's no “my streak is longer than my frenemy's” badge of honor for readers to display.

At the same time, Duolingo's design has combined streaks with social features to an extreme. You have your own streak. When you break your streak, your friend can save it for you by spending their own gems. When you pledge to maintain a streak of a certain length and fulfill the pledge, you get extra gems. You are also constantly reminded that your friend has achieved a remarkably long streak. All this adds to the social pressure on users to keep coming back to the game. (Duolingo has taken gamification to another level. It would be disrespectful not to call it a game.)

Now, what's interesting is that you only want to use the streak feature for activities that are traditionally considered boring or unengaging (reading, learning vocabulary).

If something is inherently engaging, you don't need a “streak” feature to remind users to come back. For example, you don't see a “streak” reminder splashed across TikTok's home screen.

◆

Building a Landing Page with Codex, Astro, and Cloudflare

I created a landing page for a project that I've wanted to start for a long time. Much of the delay came from my struggle to wrap my head around it.

The best way to beat procrastination is to do something—anything, really—and simply get started. For me, that “something” was building a landing page.

I asked Codex to generate five landing-page mockups in vastly different styles. I then refined the design by asking it to create variants of the two I liked best.

As of August 2026, Codex (with gpt-5.6-sol) understands images remarkably well. It can generate design mockups and accurately interpret their layouts.

After some discussion, I asked Codex to build the site with server-side rendering so that users would receive fully rendered HTML without much JavaScript fluff. I also wanted the landing page to include a waitlist feature.

This was my first time using Astro. Judging by the code Codex produced, Astro handles the job cleanly and elegantly.

What's remarkable is that Astro creates a server-side endpoint that receives signup requests without adding any bloat. The endpoint then inserts each email address into a database table.

Cloudflare makes this especially simple. I deployed the landing page to Cloudflare Pages and connected it to a D1 database to store incoming waitlist signups. It just worked.

◆

A lightweight Swift workflow with Zed

I played with Swift over the weekend, and Xcode felt sluggish at times on my machine. I also had to ask Codex for help quite often just to navigate its UI.

When I tried coding in Zed, it failed to recognize structs, variables, and similar symbols defined in other project files.

A quick Google search led me to a very helpful blog post, “How I Got Zed Editor Working with Swift Projects,” and a GitHub repository: xcode-build-server.

Following the instructions in the blog post, I installed xcode-build-server and generated a buildServer.json file with the following command:

xcode-build-server config -scheme SCHEME_NAME -project PROJECT_NAME.xcodeproj

Zed could now recognize the project's symbols.

I wanted to use the simulator without opening Xcode. After some trial and error, I got hot reload working too. Here's how:

  • Navigate to the project directory and run open -a Simulator.
  • Run xcodebuild to build the codebase as an .app bundle.
  • Run xcrun to install and launch the built bundle in the simulator.

I've shared the Bash script I'm using in a GitHub Gist. Update the project name, scheme, directories, and other values as needed, then install fswatch to watch for file changes. Now you can run this command and have fun:

open -a Simulator && dev.sh

◆

Your ideas are wrong (and your instincts aren't)

I've been reading Life at the Speed of Play by Mark Pincus, the founder of Zynga, the social gaming company behind FarmVille.

Here are a few takeaways that I found fascinating:

  1. Instincts and ideas are two different things. Your instincts are almost always right; your ideas are often wrong. Recognizing this distinction makes it much easier to abandon failing ideas without giving up on the core insight. Your instinct tells you where the market is going or which problems are worth solving. Your ideas represent specific ways of building a product or finding a solution. Ideas tend to be wrong because they involve countless permutations of details. Which brings us to:
  2. Proven, better, new. When you follow an instinct, find the features that are proven to work in competing products and copy them. Identify which details in existing products you can objectively make better. Introducing new features or ways of interacting is risky. That's why:
  3. A “minimum idea state” is much more useful than a “minimum viable product.” MVPs are too heavy. Instead, build just enough of your idea to rapidly gather data and test the waters.
◆

Alpaca WebSocket Authentication with WebSockex

I was trying to stream market data through Alpaca's WebSocket endpoint.

Alpaca's documentation lists the following three steps for receiving market data from the stream:

  1. Connect to the endpoint.
  2. Send an authentication frame.
  3. Send a subscription frame.

Step 2 proved tricky.

The library I'm using is WebSockex. As a best practice, you should either send the auth frame in the handle_connect function or reply with one from handle_frame when the “connected” message is received. In this particular case, both approaches failed or timed out.

The handle_connect function is called immediately after the WebSocket connection is established. From handle_connect, you cannot return {:reply, auth_frame, state}; you can only return {:ok, state} or {:close, state}.

If you want to send the auth frame to the server, you have to use WebSockex.send_frame(pid, frame). ChatGPT keeps telling me to do the following, although it invariably causes a CallingSelfError. Apparently, you cannot simply ask yourself—the same process—to send a frame.

1def handle_connect(_conn, state) do
2  # This will cause an error.
3  WebSockex.send_frame(self(), {:text, auth_frame})
4  {:ok, state}
5end

But in the handle_frame function, you can return a tuple like this: {:reply, auth_frame, state}. You only need to pattern-match the incoming frames. When you see “connected,” return that reply tuple. This would have worked had it not timed out. (Curiously, replying with a subscription frame worked.)

In the end, I sent the auth frame inside the start_link function.

 1  def start_link(state) do
 2    connected = WebSockex.start_link(@uri, __MODULE__, state)
 3
 4    case connected do
 5      {:ok, pid} ->
 6        WebSockex.send_frame(pid, {:text, auth_json})
 7        {:ok, pid}
 8
 9      {:error, reason} ->
10        Logger.info(reason)
11    end
12  end
◆