Skip to content

Notes · 14

Today I Learned

One problem and the fix, a few lines each. Things I ran into while building games, web products and AI tools, written down so the next person searching for them finds an answer.

How do I make Unity asset GUIDs the same on every machine?

If a .meta never reaches git, or an editor script builds the same material on two machines, Unity gives the asset a random GUID each time and every prefab that pointed at it loses the reference.

Fix: derive the GUID from the asset path. A Unity GUID is 32 hex characters, so an MD5 fits:

python
import hashlib

def stable_guid(path: str) -> str:  # "Assets/Materials/Rock.mat"
    return hashlib.md5(("my-project:" + path).encode()).hexdigest()

The catch I found testing it: a file dropped into Assets with a ready .meta keeps that GUID, but AssetDatabase.CreateAsset always assigns a random one, and rewriting it mid-build destroys the object the builder holds. So a script fixes GUIDs after the build, with Unity closed, only for assets whose .meta is not in HEAD yet, and rewrites the old GUID in all text assets. A pre-commit hook runs it in check mode (asset without .meta, orphan .meta, duplicate or random GUID), and an [InitializeOnLoad] editor class runs git config core.hooksPath .githooks so every machine gets the hook.

Hit this when code-built prefabs opened on another machine with missing models and materials. Docs: Unity asset metadata.

Blender FBX: why are child objects rotated in Unity?

With Apply Transform (bake_space_transform=True) the Blender FBX exporter bakes the Z-up → Y-up conversion only into top-level objects. Anything parented under another object (a pane inside a door) arrives in Unity rotated and in the wrong place.

Fix: keep every object directly under the root, put the intended parent in the name, re-parent in Unity.

python
pane.parent = root
pane.name = "Pane_03__Door_A0"  # parent travels in the name
csharp
// editor script, after unpacking the model prefab instance
foreach (var t in all) {
    int cut = t.name.IndexOf("__");
    if (cut < 0) continue;
    var owner = all.FirstOrDefault(o => o.name == t.name.Substring(cut + 2));
    t.name = t.name.Substring(0, cut);
    if (owner != null) t.SetParent(owner, worldPositionStays: true);
}

I hit this generating vehicle models from Python in Blender. The glass was transparent, so nothing looked wrong; collider coordinates gave it away. The build now fails if a pane lands outside the vehicle.

Docs: Blender FBX export (Apply Transform is marked experimental).

#Game development

How do I test player input in Godot 4 headless, with real input actions?

Input.action_press() lets a headless test play the game through the same actions a player uses. But a press sent at the wrong moment of the frame is never seen by is_action_just_pressed(), and the test fails at random.

The fix: wait for process_frame (it fires right before every _process), press, hold for at least one frame, release.

gdscript
func press(action: String, hold_s: float = 0.0) -> void:
    await get_tree().process_frame   # start of a frame
    Input.action_press(action)       # lands before _process
    await get_tree().process_frame
    if hold_s > 0.0:
        await get_tree().create_timer(hold_s).timeout
    Input.action_release(action)
    await get_tree().process_frame

Run it from a user argument and quit with an exit code CI can read:

bash
godot --headless --path game -- --test   # OS.get_cmdline_user_args(), then get_tree().quit(0 or 1)

If you read input in _physics_process, await physics_frame instead.

Hit this while building a two-player co-op prototype: one script walks both players through a full scenario in about 80 seconds.

Docs: Input.action_press

#Game development

How do I stop a one-shot input from firing on every fixed-timestep step?

In a fixed-timestep sim a frame can run 0, 1 or 4 physics steps. A "pressed" flag (jump, drop, interact) that you simply overwrite each frame gets lost on a 0-step frame. So you OR it into the pending input instead, and clear it after the first step that reads it. My bug: drop was in the merge but missing from the clear, so one press of X kept dropping everything the player picked up afterwards.

The fix is to keep one list of one-shot fields and derive both the merge and the clear from it, so adding a new action can't break either:

ts
const ONE_SHOTS = ['jump', 'drop', 'interact', 'yank'] as const

// on every input message from a client (can arrive several times per step)
function mergeInput(pending: Input, next: Input): Input {
  const out = { ...next }
  for (const k of ONE_SHOTS) out[k] = pending[k] || next[k]
  return out
}

// at the end of each physics step
function consumeOneShots(i: Input) {
  for (const k of ONE_SHOTS) i[k] = false
}

Held inputs (move axes, "reel while held") stay out of the list and are just overwritten. Add a headless regression test: press once, step for half a second, then check the next pickup stays in hand.

Hit this in a host-authoritative co-op prototype (Rapier, 60 Hz steps, up to 4 per frame).

Background on fixed timesteps: https://gafferongames.com/post/fix_your_timestep/

#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

Why doesn't SetLive put my Steam build live on the default branch?

"SetLive" in a SteamPipe app_build script only works for beta branches. Steam refuses to set the default branch live automatically: that last step is always a click on the app's Builds page in Steamworks.

json
"AppBuild"
{
  "AppID" "1000"
  "Desc" "CI build"
  "SetLive" "staging"   // a beta branch, never "default"
  "Preview" "0"         // "1" = dry run: logs and manifest only, nothing uploaded
  "Depots" { "1001" "depot_build_1001.vdf" }
}
bash
steamcmd +login <account> +run_app_build ../scripts/app_build.vdf +quit

So my pipeline uploads every build straight to a private staging branch, I play it there, and promoting it to default stays a deliberate manual step. That is a feature, not a gap: CI can never ship to all players by itself. Also note that the account setting builds live on a released app needs Steam Guard via a phone or the mobile app.

Source: Steamworks: Uploading to Steam

YouTube API: containsSyntheticMedia not set after upload

I upload AI-voiced Shorts through the YouTube Data API with status.containsSyntheticMedia: true in videos.insert. The upload works, but the "Altered content" flag in Studio stays off.

The fix is to set the flag in a second call, videos.update on the status part. That call replaces the whole status object, so send every field again. Any field you leave out goes back to its default.

js
await fetch('https://www.googleapis.com/youtube/v3/videos?part=status', {
  method: 'PUT',
  headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
  body: JSON.stringify({
    id: videoId,
    status: {
      privacyStatus: 'private', // resend, or it changes
      selfDeclaredMadeForKids: false,
      embeddable: true,
      license: 'youtube',
      containsSyntheticMedia: true,
    },
  }),
})

Check status.containsSyntheticMedia in the response and warn if it is still false. Calls made right after a fresh upload can return 409 ABORTED or a 5xx for a while, so retry them with backoff.

Hit this while building the bot that turns my TIL notes into Shorts with a cloned voice.

Docs: https://developers.google.com/youtube/v3/docs/videos#status.containsSyntheticMedia

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.

How should I organize a Claude project so it stops forgetting context?

A Claude project works best when each kind of context has exactly one home. Otherwise you end up explaining the same thing in every chat.

How I split it for my site:

  • One project per long-running goal ("build my personal site"), not one per task.
  • Project instructions hold what never changes. Keep them short:
text
Owner: Ravy. Reply in Russian; everything on the site is in English.
Code: github.com/Rovniy/ravy.pro. Edit my local checkout, never commit unless asked.
Never publish anything from my private notes.
Rules about the code itself live in the repo's CLAUDE.md, not here.
One chat or thread per task. "Add a press kit" and "fix the OG images" never share a chat, so neither drags the other's history along. A finished task gets closed.
  • Decisions go into memory or a file in the project the moment they're made ("the music is presented openly as AI work"). A new chat reads them instead of asking me again.
  • Code rules live in the repo, next to the code they protect, so every tool that opens the repo sees them. -The test: open a fresh chat, ask for the next feature, and see whether it has to ask you anything it should already know.

Docs: What are projects?

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.