Skip to content

Today I learned / Web development

Web development notes

Vue, Nuxt, TypeScript and the browser platform: fixes, configuration details and patterns found while building real web products.

#Web development

How do I stop long URLs from causing horizontal scroll on mobile?

A bare URL or a long identifier in inline code is one unbreakable "word" to the browser. On a phone it ran past the column and gave the whole page a sideways scrollbar.

css
.prose {
  overflow-wrap: break-word;
}
.prose a,
.prose :not(pre) > code {
  overflow-wrap: anywhere; /* also shrinks min-content width */
}

body {
  overflow-x: clip; /* guard rail, not hidden */
}

Two details that matter:

  1. break-word only wraps once the line already overflows. It doesn't lower the element's min-content width, so inside a flex or grid item the column still stretches to the full URL. anywhere does, so it works there too. For flex rows, also put min-width: 0 on the text item.
  2. Use overflow-x: clip, not hidden. hidden turns the element into a scroll container (and the other axis becomes auto), which quietly breaks position: sticky headers. clip just cuts off the overflow.

Code blocks keep their own horizontal scroll, so only inline text wraps.

Hit this on the TIL pages of this site: one note with a long link widened every page on mobile.

Source: MDN: overflow-wrap, MDN: overflow clip

How do I call Steamworks from a Vue + Electron game and get the overlay?

A Vue game in Electron can't talk to Steam on its own: steamworks.js is a native Node module, and the Steam overlay doesn't appear over Chromium's window by default.

Keep Steam in the main process and give Vue a small API through the preload script:

js
// main.js
const steamworks = require('steamworks.js')
const client = steamworks.init(2757440) // your App ID

ipcMain.handle('steam:unlock', (_e, id) => client.achievement.activate(id))
ipcMain.handle('steam:name', () => client.localplayer.getName())

steamworks.electronEnableSteamOverlay() // last line of main.js
js
// preload.js
contextBridge.exposeInMainWorld('steam', {
  unlock: id => ipcRenderer.invoke('steam:unlock', id),
  name: () => ipcRenderer.invoke('steam:name'),
})

In a Vue component it is then just await window.steam.unlock('FIRST_CARD'). The renderer keeps contextIsolation on, so you don't need the nodeIntegration: true shortcut from the README. When you package, unpack the .node binary from the asar (asarUnpack: ['**/*.node'] in electron-builder), or require fails in the shipped build only.

What I saw: everything worked in dev, the overlay never showed up, and it turned out electronEnableSteamOverlay() was missing. It adds the Chromium flags the overlay needs to hook the window.

Source: steamworks.js, Electron section

How do I cap a Postgres table by size and delete the oldest rows first?

Preview images for share links sat in a bytea column and were never deleted. Refusing new links at a ceiling is worse: the newest links are the ones in fresh posts.

One DELETE with a running sum, newest first, removes every row past the ceiling:

sql
DELETE FROM shares WHERE id IN (
  SELECT id FROM (
    SELECT id,
      sum(octet_length(image)) OVER (ORDER BY created_at DESC, id DESC) AS acc,
      row_number()             OVER (ORDER BY created_at DESC, id DESC) AS nth
    FROM shares
  ) t
  WHERE acc > $1 AND nth > 1   -- $1 = ceiling in bytes; keep the newest row
) RETURNING octet_length(image) AS freed;
  • Trim to 95% of the ceiling, or a full table runs this on every insert.
  • Cache the total: re-read the sum every 10 minutes, add each insert's size in between. octet_length on bytea doesn't decompress, so it's cheap.
  • Add a per-user cap (newest 200 per user_id), or one heavy user evicts everyone else.

Hit this bounding share-image storage in a game backend (1 GB guests, 4 GB players). Window functions docs

How do I restart a Node.js container when its event loop hangs?

A Node server stuck in an endless loop answers nothing, and Docker won't restart it: a failing healthcheck only marks it unhealthy, and restart: acts only when the process exits. Nothing on the stuck thread can notice, so the watchdog lives on a worker thread and kills the process from there.

ts
// main thread
const w = new Worker(new URL('./watchdog.js', import.meta.url), { workerData: 30_000 })
w.unref()
setInterval(() => w.postMessage(0), 1000).unref()

// watchdog.js (worker)
let last = Date.now()
parentPort.on('message', () => { last = Date.now() })
setInterval(() => {
  if (Date.now() - last > workerData) process.kill(process.pid, 'SIGKILL')
}, 1000)

The gotcha: in a container your server is PID 1, and the kernel won't deliver that SIGKILL to PID 1. Add init: true to the service in Compose so the server runs as a normal child.

I added this to a game's WebSocket gateway, where every player socket hangs on one thread. Keep it off in development: a breakpoint looks exactly like a hang. Docs: Compose init.

How do I build an ECS where mechanics can be swapped while the game runs?

Keep all state in components as plain data and all code in modules that own no state. A snapshot is then just the stores, and swapping a mechanic is just swapping the systems that read them.

ts
world.add(e, 'Napping', {}) // state: plain data, saved in every snapshot

export default defineModule({
  id: 'siesta', version: '1.1.0',
  components: { Napping: { version: 2, migrate: { 1: old => ({ ...old, since: 0 }) } } },
  install(ctx) { /* one-time world changes */ },
  setup(ctx) { ctx.extend(ACTIONS_REGISTRY, 'siesta_nap', nap) }, // runs on every attach: never writes the world
  systems: [{ id: 'wake', every: 10, run(ctx) { /* query, then mutate */ } }],
})

In Glimtide every mechanic, even hunger, is a module installed into the live world between two ticks. The rules that make it work: no state in closures (an upgrade drops it), randomness only from the world's seeded RNG and time only from ticks, or a trial run on a snapshot can't be compared. More in the Glimtide write-up and the ECS FAQ.

How to make a narrated explainer video for a side project from one prompt

My tool pages explained everything in text, and I wasn't going to record and edit a video for each of them by hand.

I used Animator, a Python CLI that turns one prompt into a hand-drawn whiteboard video with narration:

bash
pip install -r requirements.txt   # plus FFmpeg on PATH and GEMINI_API_KEY in .env
python -m animator --prompt "How tabs-broadcast lets browser tabs talk to each other" --scenes 4 -o tabs_broadcast.mp4

Gemini writes the storyboard, draws each scene, voices it and finds every icon in the frame. A local CPU engine then draws each icon while its sentence is being spoken. A 4–5 scene video takes about a minute.

That's how I got the videos on tabs-broadcast, XPLOIT Game UI, Steam AI Disclosure and Contract Red-Flag Scanner: one command each, uploaded to YouTube as is.

If a caption shows up before it's spoken, rerun with --save-storyboard and fix the beat in scene_XX.regions.json. The art style and the script tone are plain-text prompts in animator/prompts/, so you can change them without touching code.

Asking Claude to "add feature X" gets you X.

The loop I use on ravy.pro:

  1. Keep a CLAUDE.md in the repo: the architecture, plus the rules that are easy to break (where data lives, what must stay prerendered, which analytics events exist).
  2. Ask for ideas against a goal, not for a feature:
text
Read CLAUDE.md and the site. My goal: companies hiring a CTO should find me.
Propose 10 features ranked by impact vs. effort.
For each: what it is, why it helps, which files it touches.
  1. Pick one and let it build the whole thing: code, tests, lint, a production build, then screenshots to check the layout.

This feed is item 10 on that list. The ⌘K search and the press kits for my games came from the same list.

What made it work: every rule goes into CLAUDE.md the day it bites. Claude reads that file at the start of every session, so the same mistake rarely comes back.

Docs: How Claude remembers your project

Newsletter

Occasional notes on engineering, game tech, and new tools — no spam, unsubscribe anytime.

Ravy

Engineering manager, founder, and software developer building web platforms, game systems, real-time services, and automation tools. 15 years of shipped work — currently at Gaijin.net.

Get in Touch

Building an MVP, shipping a game feature, or automating a team workflow? Open source or paid — let's talk.

Contact Me
© 2020-2026 XPLOIT FZE. All trademarks, names and logos belong to their respective copyright holders.