$ ls ./blog/tips

Tips

Short fixes taken from work. Each tip is one task, the commands to copy and the gotcha I ran into myself.

Claude Code agents Python

Claude Code UserPromptSubmit hook: a script that adds context

print(json.dumps({"hookSpecificOutput": {

! gotcha The hook runs only when you write something in an open session. While you are silent, the agent still knows nothing.

WebGL GLSL Android

WebGL shader noise is a grey smudge on a phone: precision mediump float

precision highp float;

! gotcha Device mode in DevTools will not show this, because the computer's GPU still runs the shader. For me the bug showed only on the phone.

Django tests Docker

Django tests hang in Docker: test database already exists

docker compose exec -T web python manage.py test --noinput

! gotcha The --noinput flag deletes the old test database without asking, also one you keep on purpose with --keepdb or --reuse-db.

Python Pillow fonts

Pillow: bold text from a variable font

font.set_variation_by_axes([700])

! gotcha The latin file of a font cut up for the web has no ł, ą or ę. Pillow raises no error and reaches for no other font; it leaves a blank.

JavaScript Pointer Events Android

setPointerCapture on touch: lostpointercapture ends the drag at once

if (ev.target !== handle) return;

! gotcha On Android a held finger opens the context menu, and the menu cancels the pointer. preventDefault() on contextmenu stops it.

Django JSON Python

"Object of type Decimal is not JSON serializable" in Django

json.dumps(data, cls=DjangoJSONEncoder)

! gotcha The encoder writes a Decimal as a string: "12.50", not 12.5. Whoever reads that JSON gets text and has to make the number themselves.

Django streaming gzip

Django StreamingHttpResponse not working: GZipMiddleware holds the stream

response["Content-Encoding"] = "identity"

! gotcha Plain curl does not ask for gzip until you add --compressed, so the stream flows in the terminal and not in the browser.

adb Android localhost

Open localhost on an Android phone: adb reverse

adb reverse tcp:8018 tcp:8018

Chrome Android visualViewport CSS

Chrome on Android: visualViewport.height is too tall by the address bar when the keyboard opens

shortest = Math.min(shortest, window.innerHeight);

! gotcha Desktop Chrome does not emulate the on-screen keyboard, so device mode will not reproduce this bug. You need a phone.

adb Android Chrome DevTools agents

Give an AI agent a real phone: Chrome DevTools over Wi-Fi adb

adb forward tcp:9222 localabstract:chrome_devtools_remote

! gotcha When the phone's screen locks, DevTools calls hang with no error at all. You unlock the phone; the agent should not.

adb Android Chrome DevTools

An Android screenshot that includes the keyboard: adb screencap, not DevTools

adb exec-out screencap -p > screen.png

! gotcha The adb screenshot is in device pixels, DevTools taps in CSS pixels: 1280 and 426 px across on a Pixel 9 Pro. Coordinates have to be converted.

adb Android Ubuntu

"adb: unknown command pair" on Ubuntu

~/platform-tools/adb pair <ip>:<port>

! gotcha After unpacking, a bare adb in the terminal is still the old one from apt, so call the new one by its full path: ~/platform-tools/adb.

↑