<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sharing on miti99</title><link>https://miti99.com/en/categories/sharing/</link><description>Recent content in Sharing on miti99</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 16 Nov 2026 17:39:19 +0700</lastBuildDate><atom:link href="https://miti99.com/en/categories/sharing/index.xml" rel="self" type="application/rss+xml"/><item><title>My Late-2026 Workspace Setup: DeskMini at Home, code-server in the Cloud</title><link>https://miti99.com/en/post/2026/11/04/</link><pubDate>Wed, 04 Nov 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/11/04/</guid><description>&lt;p&gt;I wanted to be able to open my workspace from any device, let coding agents shoulder more and more of the heavy lifting, and make the most of long-term free tiers. After plenty of rounds of installing, testing, and tearing things down, my late-2026 setup has settled into three parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;In the cloud:&lt;/strong&gt; &lt;code&gt;code-server&lt;/code&gt; running inside a container on OCI Always Free ARM, deployed via Coolify from &lt;a href="https://github.com/tiennm99/composes" rel="noopener noreferrer"&gt;tiennm99/composes&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;At home:&lt;/strong&gt; an ASRock DeskMini X600 running Ubuntu, handling heavy builds, containers, and coding agents for remote access.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On the go:&lt;/strong&gt; a lightweight ThinkPad acting as a thin client to connect to the other two over SSH, Tailscale, or &lt;code&gt;code-server&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Getting here took plenty of trial and error: switching &lt;code&gt;code-server&lt;/code&gt; images, hunting for a good browser-based terminal, and spending two weeks wrestling with remote Linux desktop solutions. Some things stuck; others now live only in my archive folder.&lt;/p&gt;
&lt;p&gt;This post was drafted with AI assistance from my Git history, plans, and notes, and I then filled in the reasoning behind each decision. I didn&amp;rsquo;t check the DeskMini live while writing; anything unverified or where I no longer remember the exact reason is called out explicitly in the relevant section.&lt;/p&gt;
&lt;h2 id="starting-point-code-server-in-a-container"&gt;Starting Point: &lt;code&gt;code-server&lt;/code&gt; in a Container&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ve been self-hosting Coolify since at least May 2025. On August 14, 2026, while reorganizing my &lt;code&gt;composes&lt;/code&gt; repo, I added &lt;code&gt;code-server&lt;/code&gt; using the LinuxServer.io image (lsio for short). Go, Node, and Python were installed via &lt;code&gt;DOCKER_MODS&lt;/code&gt;, and extra packages via &lt;code&gt;INSTALL_PACKAGES&lt;/code&gt;. The &lt;code&gt;abc&lt;/code&gt; user&amp;rsquo;s home directory lived at &lt;code&gt;/config&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Running that image under Coolify had a few annoyances. Every redeploy recreated the container, re-downloaded the mods, and forced &lt;code&gt;apt&lt;/code&gt; to resolve the entire &lt;code&gt;INSTALL_PACKAGES&lt;/code&gt; list from scratch — enough that I had to trim the package list down. Worse, if a mod failed to install, the error was simply logged and ignored: the editor still opened, just missing tools. Freshly created workspace volumes were also owned by &lt;code&gt;root&lt;/code&gt;, which I had to work around in a Dockerfile.&lt;/p&gt;
&lt;p&gt;Those were the friction points with lsio. The reason I switched to Coder&amp;rsquo;s official image was to stay closer to upstream. I added &lt;code&gt;codercom/code-server&lt;/code&gt; with a custom Dockerfile on October 6, then removed the lsio setup and moved it to the archive on October 12.&lt;/p&gt;
&lt;p&gt;The new Dockerfile bakes in the tools I need right at build time: build-essential, &lt;code&gt;bubblewrap&lt;/code&gt;, networking CLIs, search and linting tools, database clients, plus &lt;code&gt;gh&lt;/code&gt;, Docker CLI, Compose, Buildx, &lt;code&gt;glab&lt;/code&gt;, and &lt;code&gt;gt&lt;/code&gt;. That way, helper commands and shell completions are ready out of the box. I use &lt;code&gt;FROM codercom/code-server:latest&lt;/code&gt; because the official image doesn&amp;rsquo;t publish major-version tags.&lt;/p&gt;
&lt;p&gt;So that &lt;code&gt;agent-browser&lt;/code&gt; can run headlessly on ARM64, the image includes Debian&amp;rsquo;s Chromium package along with the required fonts, and I tuned shared memory so Chromium wouldn&amp;rsquo;t crash. GTK and WebKitGTK are included for headless Tauri builds and tests.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Language toolchains, on the other hand, stay in my home directory outside the image:&lt;/strong&gt; &lt;code&gt;fnm&lt;/code&gt;, &lt;code&gt;uv&lt;/code&gt;, &lt;code&gt;rustup&lt;/code&gt;, Go from the official tarball, and SDKMAN. Baking another copy into the image would only bloat the build while getting shadowed by the versions in &lt;code&gt;$HOME&lt;/code&gt; anyway. Keeping them separate also prevents a container redeploy from silently upgrading the compiler or runtime version I&amp;rsquo;m in the middle of using.&lt;/p&gt;
&lt;p&gt;One remaining annoyance is typing Vietnamese inside the browser terminal when using Claude Code. As of my last notes on October 18, I still haven&amp;rsquo;t found an officially supported fix. Backspace events and diacritic composition have to travel through the entire chain of browser → &lt;code&gt;xterm.js&lt;/code&gt; → WebSocket → PTY. For now, I just type longer Vietnamese text outside and paste it in.&lt;/p&gt;
&lt;h2 id="things-i-evaluated-tried-and-removed-on-the-server"&gt;Things I Evaluated, Tried, and Removed on the Server&lt;/h2&gt;&lt;p&gt;Alongside switching the &lt;code&gt;code-server&lt;/code&gt; image, I looked for ways to use a terminal and coding agents directly in the browser. Between September and early November, several tools came and went on the server:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OpenHands:&lt;/strong&gt; tried from September 18 to 19 — about a day.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;opencode web:&lt;/strong&gt; tried from September 18 to October 5 for a browser-based shell.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Paseo:&lt;/strong&gt; used from September 16 to November 3 (last tweaked on October 6). This daemon initially seemed like a good fit, but each agent CLI needed around 200 MB installed at startup. I eventually dropped it because Orca and T3 Code offered better features and a smoother experience.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For OpenHands and opencode web, I didn&amp;rsquo;t write down why I removed them.&lt;/p&gt;
&lt;p&gt;The Zellij web client was the one I really wanted to make work. I ran it in a container from October 21 to November 3, but immediately ran into keyboard shortcut conflicts: the browser reserves &lt;code&gt;Ctrl+T&lt;/code&gt;, &lt;code&gt;Ctrl+W&lt;/code&gt;, &lt;code&gt;Ctrl+N&lt;/code&gt;, and &lt;code&gt;Ctrl+Tab&lt;/code&gt; — the exact combinations I needed for Zellij&amp;rsquo;s modes. With the Unlock-First layout, &lt;code&gt;Ctrl+G&lt;/code&gt; opened Firefox&amp;rsquo;s find bar instead, so I had to rebind it to &lt;code&gt;Alt+G&lt;/code&gt;. On top of that, opening the root URL always spawned a brand-new session that I couldn&amp;rsquo;t clean up from the UI. Ultimately, the shortcut conflicts were what made me drop it.&lt;/p&gt;
&lt;p&gt;While setting it up, I also used &lt;code&gt;socat&lt;/code&gt; as a relay and ran into a quirk where Zellij exited silently if its config file was missing.&lt;/p&gt;
&lt;p&gt;Typing occasionally felt laggy too, though I never proved Zellij was the culprit. The container itself was barely under any load; an incorrect &lt;code&gt;TERM&lt;/code&gt; variable, Vietnamese IME input through the browser, or network latency could all have played a part. I did fix one specific bug where &lt;code&gt;TERM=unknown&lt;/code&gt; caused Backspace to move the cursor to the right.&lt;/p&gt;
&lt;p&gt;An alternative I evaluated on October 24 was &lt;code&gt;tmux&lt;/code&gt; over &lt;code&gt;ttyd&lt;/code&gt;. Because &lt;code&gt;tmux&lt;/code&gt; uses &lt;code&gt;Ctrl+B&lt;/code&gt; as its prefix, its default bindings clash much less with browser shortcuts than Zellij&amp;rsquo;s modal bindings — though it still has to live within whatever keys the browser allows through.&lt;/p&gt;
&lt;p&gt;I added a &lt;code&gt;ttyd&lt;/code&gt; template to the repo but never actually deployed it. Soon after, Orca and T3 Code covered my needs, so I archived the template too. A bare terminal alone still felt too limiting anyway: having to ask Claude just to inspect a single file felt unnecessarily roundabout.&lt;/p&gt;
&lt;p&gt;On November 3, I moved Paseo, Zellij, and the &lt;code&gt;ttyd&lt;/code&gt; template into the archive in a single commit. The Zellij container was removed; the only browser terminals I still use are Cloudflare&amp;rsquo;s browser SSH to the DeskMini and the integrated terminal inside &lt;code&gt;code-server&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="the-deskmini-at-home"&gt;The DeskMini at Home&lt;/h2&gt;&lt;p&gt;The machine sitting at home is an ASRock DeskMini X600: X600M-STX motherboard, Ryzen 7 8700G (8 cores, 16 threads, integrated Radeon 780M graphics), and 32 GB of RAM. It has two 500 GB NVMe drives — one for the OS and one for my workspace. As of my October 21 check, it runs Ubuntu 26.04 Desktop with GNOME on Wayland.&lt;/p&gt;
&lt;p&gt;I picked the DeskMini because it&amp;rsquo;s compact yet powerful and has a capable iGPU, making it a great &lt;strong&gt;always-on home Linux box for heavy workloads and remote access&lt;/strong&gt;. My Windows desktop is even more powerful, but I didn&amp;rsquo;t want to run a Windows rig 24/7 for that role. When I&amp;rsquo;m at home, I still sit at my Windows desktop; when I&amp;rsquo;m at the office and need a beefy homelab, I open Orca on the DeskMini over Tailscale.&lt;/p&gt;
&lt;p&gt;That keeps my ThinkPad light and cool: compiling, running containers, language toolchains, and long-running tasks all happen on the DeskMini or the cloud server. The DeskMini doesn&amp;rsquo;t run Coolify — services there use plain Docker Compose and &lt;code&gt;systemd&lt;/code&gt;, with browser access routed through Cloudflare Tunnel and Access.&lt;/p&gt;
&lt;p&gt;I gradually set up its toolchains starting in late October: Node via &lt;code&gt;fnm&lt;/code&gt;, Python via &lt;code&gt;uv&lt;/code&gt;, Go from the official tarball with &lt;code&gt;GOTOOLCHAIN=auto&lt;/code&gt;, Rust via &lt;code&gt;rustup&lt;/code&gt;, and Java 21 via SDKMAN, alongside &lt;code&gt;gcc&lt;/code&gt;, &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;gh&lt;/code&gt;, Docker, &lt;code&gt;glab&lt;/code&gt;, and later &lt;code&gt;gt&lt;/code&gt;. One easy-to-forget gotcha when writing automation scripts: &lt;code&gt;fnm&lt;/code&gt; and SDKMAN are loaded in interactive &lt;code&gt;zsh&lt;/code&gt; startup files, so &lt;code&gt;cron&lt;/code&gt; jobs and &lt;code&gt;systemd&lt;/code&gt; services won&amp;rsquo;t see them automatically.&lt;/p&gt;
&lt;p&gt;Since October 22, the DeskMini has had its own dedicated notes in my workspace repo. At that time, its role was also tied to something I really wanted to get working smoothly: opening a full Linux desktop right inside the browser via Apache Guacamole.&lt;/p&gt;
&lt;h2 id="two-weeks-chasing-a-browser-based-linux-desktop"&gt;Two Weeks Chasing a Browser-Based Linux Desktop&lt;/h2&gt;&lt;p&gt;My goal at the time was very specific: open my Linux desktop from anywhere in a browser without installing any client software on the machine in front of me. That meant routing through Cloudflare Tunnel and Access rather than requiring Tailscale on the client machine.&lt;/p&gt;
&lt;p&gt;Among the options I surveyed on October 19, Guacamole stood out as free, self-hosted, clientless, and capable of speaking RDP to both Linux and Windows. Cloudflare&amp;rsquo;s browser RDP ranked lower in my comparison notes, yet I tried it first anyway. On October 21, GNOME Remote Desktop rejected the connection with:&lt;/p&gt;
&lt;blockquote&gt;
 &lt;p&gt;Client did not advertise support for the Graphics Pipeline, closing connection&lt;/p&gt;

&lt;/blockquote&gt;
&lt;p&gt;GNOME requires the RDP Graphics Pipeline extension, and Cloudflare&amp;rsquo;s IronRDP client didn&amp;rsquo;t advertise support for it at the time, causing GNOME to close the connection immediately. Cloudflare&amp;rsquo;s documentation also listed only Windows targets as supported. So that path was a dead end with GNOME in my test.&lt;/p&gt;
&lt;p&gt;VNC was also in my survey notes, though I never installed it. With GNOME on Ubuntu 26.04 in this configuration, everything runs on Wayland with GNOME Remote Desktop speaking RDP. The VNC options I looked into required either X11 or &lt;code&gt;wlroots&lt;/code&gt;, and older guides referencing a VNC toggle in GNOME Settings no longer matched this release.&lt;/p&gt;
&lt;p&gt;So I moved on to Guacamole, deploying &lt;code&gt;guacamole&lt;/code&gt;, &lt;code&gt;guacd&lt;/code&gt;, and PostgreSQL via Docker on the DeskMini over October 21–22. I pinned version &lt;code&gt;1.6.0&lt;/code&gt; because it was the first release supporting the RDP Graphics Pipeline (and the &lt;code&gt;latest&lt;/code&gt; tag at the time pointed to an &lt;code&gt;amd64&lt;/code&gt;-only development build).&lt;/p&gt;
&lt;p&gt;The desktop connected, but sessions kept dropping mid-use. The drops happened over both QUIC and HTTP/2 tunnels, and &lt;code&gt;cloudflared&lt;/code&gt; logged no errors corresponding to the disconnects — so switching the tunnel transport didn&amp;rsquo;t help. In the logs I captured, &lt;code&gt;guacd&lt;/code&gt; reported &lt;code&gt;User is not responding.&lt;/code&gt; after 15 seconds of silence and closed the RDP connection. Those 15-second timeouts are hardcoded at compile time and cannot be changed via configuration.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I still haven&amp;rsquo;t pinned down the root cause.&lt;/strong&gt; At first I suspected the browser was throttling timers in background tabs, but sessions dropped even while the tab was focused right in front of me. The most plausible theory at the time was a set of regressions in Guacamole 1.6.0 — specifically &lt;code&gt;GUACAMOLE-2118&lt;/code&gt;, its duplicate reports, and &lt;code&gt;GUACAMOLE-2081&lt;/code&gt;. Those bugs had already been fixed on the &lt;code&gt;1.6.1&lt;/code&gt; branch, which hadn&amp;rsquo;t been released yet when I investigated.&lt;/p&gt;
&lt;p&gt;Even so, I never ran a pure LAN test to rule out the Cloudflare Tunnel completely. There was also one occasion where both SSH and RDP froze simultaneously despite running in separate &lt;code&gt;guacd&lt;/code&gt; processes, which that bug theory doesn&amp;rsquo;t neatly explain either.&lt;/p&gt;
&lt;p&gt;For SSH through Guacamole, disconnects were even more painful: because the shell was tied directly to the browser connection, a single drop could kill a running command and lose unsaved state. That&amp;rsquo;s what pushed me to move terminal workflows out of Guacamole altogether. I had already drafted the Zellij template on October 21 prior to this debugging session, and the Guacamole SSH drops only reinforced how much I needed terminal sessions that outlive a browser tab.&lt;/p&gt;
&lt;p&gt;Initially, I planned to stay on &lt;code&gt;1.6.0&lt;/code&gt; and wait for &lt;code&gt;1.6.1&lt;/code&gt;, falling back to &lt;code&gt;1.5.5&lt;/code&gt; only if the drops became unbearable (downgrading required backing up PostgreSQL and preparing a &lt;code&gt;1.5.5&lt;/code&gt; schema since Guacamole doesn&amp;rsquo;t support reverse migrations).&lt;/p&gt;
&lt;p&gt;By November 3, I stopped using Guacamole and archived its setup because the connection just wasn&amp;rsquo;t reliable enough. Cloudflare&amp;rsquo;s browser-rendered SSH was sufficient for quick terminal access, and whenever I need a full desktop, I use Tailscale with the official Windows RDP app. My original goal was making everything 100% browser-based, but in the end I compromised on using a native RDP client for desktop sessions.&lt;/p&gt;
&lt;h2 id="whats-running-on-the-deskmini-today"&gt;What&amp;rsquo;s Running on the DeskMini Today&lt;/h2&gt;&lt;p&gt;As of the state recorded when writing this post, browser SSH, &lt;code&gt;code-server&lt;/code&gt;, T3 Code, and Orca are all accessible through &lt;strong&gt;Cloudflare Tunnel and Access&lt;/strong&gt;, while Tailscale connects my personal devices directly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;code-server&lt;/code&gt;&lt;/strong&gt; is installed from the official &lt;code&gt;.deb&lt;/code&gt; package, runs via &lt;code&gt;systemd&lt;/code&gt;, and has been in my machine notes since October 22. Since it can&amp;rsquo;t use official VS Code Settings Sync, I plan to keep its configuration and extension list — Claude Code plus a theme — in my dotfiles and apply them via a manual script. I haven&amp;rsquo;t applied those dotfiles to the DeskMini yet.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Orca and T3 Code&lt;/strong&gt; were recently migrated from desktop GUI launches to &lt;code&gt;systemd&lt;/code&gt; user services. I installed Orca (&lt;code&gt;stablyai/orca&lt;/code&gt;) from its &lt;code&gt;.deb&lt;/code&gt; package on October 27 (I didn&amp;rsquo;t record the exact date I installed T3 Code). According to my notes, the goal of moving them to user services in early November was having them come up automatically on boot without needing to log into the desktop session first. One quirk with Orca: when run with &lt;code&gt;--supervise&lt;/code&gt;, the service waits if another Orca instance is already serving the same profile, so launching the desktop app first can make the background service wait.&lt;/p&gt;
&lt;p&gt;In my November 2 comparison notes, Orca is described as a desktop workspace built around Git worktrees that runs agent CLIs directly inside terminals, whereas T3 Code organizes work around conversation threads, drives agents through adapters, and offers a lightweight web UI. That comparison was based purely on documentation rather than side-by-side testing, and its conclusion was to keep Orca as my primary tool while trying T3 Code for steering agents from a phone or browser. Today, both run as services, and Orca is the app I use the most.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tailscale and &lt;code&gt;cloudflared&lt;/code&gt;&lt;/strong&gt; split responsibilities cleanly: Cloudflare Tunnel + Access handle remote sign-in and web UIs, while Tailscale handles direct traffic between my own devices. I went with this split because I found it simpler than setting up WARP-to-WARP. For GNOME Remote Desktop, my research notes distinguish between remote login at the GDM login screen and desktop sharing after logging in, though I don&amp;rsquo;t have recorded test results for that part yet.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Gitea and &lt;code&gt;gitea-mirror&lt;/code&gt;&lt;/strong&gt; run from my &lt;code&gt;composes&lt;/code&gt; repo as my local GitHub backup on the DeskMini. I already told the story of AI crawlers discovering my Gitea instance in &lt;a href="https://miti99.com/en/post/2026/10/29/"&gt;the October 29, 2026 post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Setting up the mirror had its own hiccups: Gitea&amp;rsquo;s default timeouts cut off multi-gigabyte clones mid-transfer, and Bun&amp;rsquo;s &lt;code&gt;fetch&lt;/code&gt; aborted connections after five minutes without data, leaving half-imported repos behind. Bumping the timeouts fixed that. Health checks polling the GitHub API without a token also hit anonymous rate limits until I lowered their frequency. And in the CLI tooling, I replaced &lt;code&gt;tea&lt;/code&gt; with &lt;code&gt;gt&lt;/code&gt; after &lt;code&gt;tea&lt;/code&gt; was archived upstream and &lt;code&gt;gt&lt;/code&gt; hit &lt;code&gt;1.0.0&lt;/code&gt;. As for why I moved the backup instance from the cloud server to my home DeskMini, I didn&amp;rsquo;t write the reason down, so I won&amp;rsquo;t attribute it to a specific incident.&lt;/p&gt;
&lt;h2 id="remote-power-on-from-rtc-wake-to-a-smart-plug"&gt;Remote Power-On: From RTC Wake to a Smart Plug&lt;/h2&gt;&lt;p&gt;Originally, waking the machine remotely wasn&amp;rsquo;t even in scope. My research notes mentioned using an ESP32 listening to a Telegram bot to send Wake-on-LAN / power signals, though I never built it.&lt;/p&gt;
&lt;p&gt;Starting October 28, I used RTC wake (&lt;code&gt;rtcwake&lt;/code&gt;) via a &lt;code&gt;systemd&lt;/code&gt; unit to schedule the DeskMini to boot itself up. The catch with RTC wake is that a power outage or hard shutdown can cause the machine to miss setting the next wake alarm.&lt;/p&gt;
&lt;p&gt;On November 3, I removed the OS-level RTC wake schedule and switched toward using a smart plug paired with the BIOS &amp;ldquo;restore on AC power loss&amp;rdquo; setting. I didn&amp;rsquo;t record the exact trigger for dropping RTC wake, but the planned workflow is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Shut the OS down cleanly first — never cut power while the PC is running.&lt;/li&gt;
&lt;li&gt;Turn the smart plug off for about 30 seconds, then turn it back on to trigger boot.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;This part isn&amp;rsquo;t finished yet.&lt;/strong&gt; I still need to disable the RTC alarm in the BIOS, set &lt;em&gt;Restore on AC Power Loss&lt;/em&gt; to &lt;em&gt;Power On&lt;/em&gt;, and test the full smart-plug power cycle as well as simulated power outages. So I can&amp;rsquo;t claim remote power-on via smart plug is working in production just yet.&lt;/p&gt;
&lt;h2 id="coolify-and-two-always-free-cloud-servers"&gt;Coolify and Two Always Free Cloud Servers&lt;/h2&gt;&lt;p&gt;On the cloud side, Coolify manages two OCI Always Free ARM servers running Ubuntu 24.04 Minimal, fronted by Traefik v3 and Let&amp;rsquo;s Encrypt. I chose OCI for its generous, non-expiring free tier. Choosing Coolify over Dokploy came down to personal impression — it felt more stable to me in day-to-day use, though I haven&amp;rsquo;t run formal benchmarks comparing the two. In my compose files, I still keep Dokploy-compatible sections ready just in case.&lt;/p&gt;
&lt;p&gt;My shared deployment configs live in the public &lt;code&gt;composes&lt;/code&gt; repo under the Apache 2.0 license. Each service gets its own folder with a &lt;code&gt;compose.yml&lt;/code&gt;, a &lt;code&gt;README.md&lt;/code&gt;, and an &lt;code&gt;.env.example&lt;/code&gt;, wired up to its own Coolify application with path-filtered webhooks so changes to one service don&amp;rsquo;t trigger redeploys of another. Inline comments explain &lt;em&gt;what&lt;/em&gt; the config does, while the &lt;code&gt;README.md&lt;/code&gt; records &lt;em&gt;why&lt;/em&gt; I chose it. Tools I wrote myself keep their &lt;code&gt;compose.yml&lt;/code&gt; inside their own repositories.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;archive/&lt;/code&gt; directory makes it easy to look back at what I tried and when I retired it. What&amp;rsquo;s occasionally missing is the &lt;em&gt;why&lt;/em&gt; — I didn&amp;rsquo;t always write down the reason I dropped a tool at the moment I removed it.&lt;/p&gt;
&lt;h2 id="keeping-everything-consistent-across-machines"&gt;Keeping Everything Consistent Across Machines&lt;/h2&gt;&lt;p&gt;What keeps both me and my coding agents from getting lost across all these machines is a shared workspace repository checked out everywhere. The repo started on July 25 just to hold a few GitHub audit skills and grew organically from there. By late October, I reorganized per-machine notes so agents only load the context relevant to the host they&amp;rsquo;re running on. Claude Code and Codex share the same rule definitions (though I primarily use Claude Code), and my AgentKit CLI installs the kit into each agent&amp;rsquo;s home directory.&lt;/p&gt;
&lt;p&gt;I split context by how it gets consumed: &lt;strong&gt;rules&lt;/strong&gt; are loaded into every session, &lt;strong&gt;skills&lt;/strong&gt; are read on demand per task, and &lt;strong&gt;memory&lt;/strong&gt; has an always-loaded index pointing to topic files. Hooks block costly mistakes; notes and plans track upcoming work; Git history and docs preserve what already happened. Memory is tracked in Git too. One important lesson I have to keep in mind: only rules are guaranteed to be loaded — if you put a behavioral instruction inside memory, the agent might never read it.&lt;/p&gt;
&lt;p&gt;Dotfiles synchronization, meanwhile, &lt;strong&gt;hasn&amp;rsquo;t been rolled out to any machine yet&lt;/strong&gt;. In my October 29 comparison, I picked &lt;code&gt;chezmoi&lt;/code&gt;: it was the only tool in the group that ships as a single native binary on Windows, supports per-machine templates, prompts once for machine variables, integrates with &lt;code&gt;sops&lt;/code&gt; when applying files, and offers a dry-run diff preview. &lt;code&gt;dotter&lt;/code&gt; came in second, while Ansible required WSL on Windows and felt too heavy compared to managing config files directly.&lt;/p&gt;
&lt;p&gt;My toolchain plan evolved too: on October 30, I dropped &lt;code&gt;mise&lt;/code&gt; from the plan in favor of ecosystem-native managers — &lt;code&gt;rustup&lt;/code&gt;, &lt;code&gt;uv&lt;/code&gt;, &lt;code&gt;fnm&lt;/code&gt;, SDKMAN (or Temurin via &lt;code&gt;winget&lt;/code&gt; on Windows), and the official Go binary with &lt;code&gt;GOTOOLCHAIN=auto&lt;/code&gt;. I didn&amp;rsquo;t log any specific bug with &lt;code&gt;mise&lt;/code&gt; when making that switch.&lt;/p&gt;
&lt;p&gt;For the shell, I plan to switch from &lt;code&gt;oh-my-zsh&lt;/code&gt; + &lt;code&gt;powerlevel10k&lt;/code&gt; to &lt;code&gt;zsh&lt;/code&gt; + &lt;code&gt;zimfw&lt;/code&gt; + Starship. Among the frameworks I compared, &lt;code&gt;zimfw&lt;/code&gt; was the most popular actively maintained option and the fastest in recorded benchmarks, with built-in completions covering nearly everything I need — whereas &lt;code&gt;powerlevel10k&lt;/code&gt;&amp;rsquo;s README explicitly notes that project maintenance is now very limited. That switch is still on the to-do list; the servers are still running &lt;code&gt;oh-my-zsh&lt;/code&gt; for now.&lt;/p&gt;
&lt;h2 id="unfinished-tasks-and-lessons-learned"&gt;Unfinished Tasks and Lessons Learned&lt;/h2&gt;&lt;p&gt;As of November 4, 2026, two items are still unfinished:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Updating the DeskMini BIOS settings and testing smart-plug power-on, including recovery after a power cut.&lt;/li&gt;
&lt;li&gt;Rolling out the dotfiles repo across my machines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Looking back over all these iterations, a few lessons stand out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Record the &lt;em&gt;why&lt;/em&gt;, not just the &lt;em&gt;what&lt;/em&gt;.&lt;/strong&gt; Git history reconstructs &lt;em&gt;what&lt;/em&gt; changed and &lt;em&gt;when&lt;/em&gt;, but it can&amp;rsquo;t tell you your motivation if you didn&amp;rsquo;t write it down. Jotting down the reason at decision time saves you from having to reconstruct it later like I did for this post.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Browser-based remote desktops have to be tested against your exact display stack.&lt;/strong&gt; On my GNOME Wayland setup, the RDP Graphics Pipeline requirement ruled out one browser RDP option right away, and older VNC guides no longer applied.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Terminal sessions should survive closing a browser tab.&lt;/strong&gt; Tying a shell&amp;rsquo;s lifecycle directly to a browser connection means a single hiccup can take down whatever command was running.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Separating language toolchains from the container image keeps version upgrades under your control.&lt;/strong&gt; Redeploying a container shouldn&amp;rsquo;t silently swap out the compiler or runtime version you&amp;rsquo;re actively working with.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Splitting access paths by use case makes daily life much simpler.&lt;/strong&gt; Cloudflare Tunnel + Access handle browser logins and web UIs; Tailscale handles direct device-to-device connections.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This setup will surely keep evolving. Right now, I spend most of my time in Orca, keep &lt;code&gt;code-server&lt;/code&gt; around for opening workspaces in a browser, and let the DeskMini and cloud servers do the heavy lifting. Every tool I tried and retired along the way made it much clearer what I actually need next time.&lt;/p&gt;</description></item><item><title>When AI Crawlers Went Strolling Through My Self-Hosted Gitea</title><link>https://miti99.com/en/post/2026/10/29/</link><pubDate>Thu, 29 Oct 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/10/29/</guid><description>&lt;p&gt;I self-host Gitea on an OCI Always Free server to keep mirrors of my GitHub repositories. I always thought of it as a quiet little corner only I ever visited — until I discovered three regular &amp;ldquo;guests&amp;rdquo; dropping by: ClaudeBot, GPTBot, and Reflectionbot. Starting from a few unusual signs in the logs, I tracked down a private repository that had unintentionally been made public, then figured out how to block the crawlers while keeping all my other apps running smoothly. Here is the full story, from discovery to mitigation and follow-up monitoring.&lt;/p&gt;
&lt;h2 id="discovery"&gt;Discovery&lt;/h2&gt;&lt;p&gt;On the morning of October 29, 2026, I noticed that the server running Gitea in Japan was unusually busy. When I opened Traefik&amp;rsquo;s access log, I realized the logs were rotating so fast that the retained portion only covered about 4.5 hours — from 17:55 to 22:22 UTC on October 28. In just that window, there were &lt;strong&gt;86,765 requests&lt;/strong&gt;.&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;User agent&lt;/th&gt;
 &lt;th&gt;Requests&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;ClaudeBot (Anthropic)&lt;/td&gt;
 &lt;td&gt;39,860&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;GPTBot (OpenAI)&lt;/td&gt;
 &lt;td&gt;26,901&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Reflectionbot (Reflection AI)&lt;/td&gt;
 &lt;td&gt;16,412&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Bun (my own &lt;code&gt;gitea-mirror&lt;/code&gt; syncing)&lt;/td&gt;
 &lt;td&gt;3,587&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Others (DuckDuckBot, OAI-SearchBot)&lt;/td&gt;
 &lt;td&gt;5&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Around 95% of the HTTP 200 responses came from &lt;code&gt;src&lt;/code&gt;, &lt;code&gt;commit&lt;/code&gt;, and &lt;code&gt;raw&lt;/code&gt; pages across 86 mirrored repositories. The crawlers were walking through &lt;strong&gt;every single commit of every single repo&lt;/strong&gt;, and each commit had multiple pages to fetch. Added together, the request volume snowballed fast.&lt;/p&gt;
&lt;p&gt;Looking back at the full month&amp;rsquo;s metrics, traffic was virtually zero until October 10. Starting October 11, it spiked and stayed consistently high:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/requests-by-day.png" alt="Daily request count from September 30 to October 28"&gt;&lt;/p&gt;
&lt;p&gt;In total, that came out to nearly &lt;strong&gt;13.9 million requests&lt;/strong&gt; and &lt;strong&gt;1.48 TB&lt;/strong&gt; of bandwidth — all to serve a Gitea instance meant for an audience of one:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/traffic-overview.png" alt="Traffic overview: requests, unique visitors, bandwidth, error rate, and P95 latency"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If you self-host on a VPS, keep a close eye on bandwidth costs.&lt;/strong&gt; Data downloaded by bots still counts toward your server&amp;rsquo;s outbound transfer quota. Depending on your provider and plan, going over your allowance can mean surprise overage charges or throttled speeds. I got lucky because OCI&amp;rsquo;s outbound bandwidth allowance is very generous, so this incident didn&amp;rsquo;t cost me anything extra. On a VPS with a tighter cap, though, 1.48 TB from crawlers alone could easily turn into an unexpected bill.&lt;/p&gt;
&lt;p&gt;Nearly all of the traffic came from bots, and almost all of it originated in the United States:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/client-types.png" alt="Client type breakdown: almost entirely Bots"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/traffic-by-country.png" alt="Traffic by country: United States accounts for 13.51 million requests"&gt;&lt;/p&gt;
&lt;p&gt;ClaudeBot alone accounted for 10.82 million requests and 1.4 TB of bandwidth. GPTBot chipped in another 2.52 million requests:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/ai-bots.png" alt="AI agents &amp;amp; bots table: ClaudeBot and GPTBot"&gt;&lt;/p&gt;
&lt;h2 id="figuring-out-the-cause"&gt;Figuring Out the Cause&lt;/h2&gt;&lt;p&gt;My first worry was whether my account had been compromised. Checking the logs, I found:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Every single request was anonymous — none of them were authenticated.&lt;/li&gt;
&lt;li&gt;No external client sent any POST, PATCH, push, or API requests. All write operations came from the server itself via &lt;code&gt;gitea-mirror&lt;/code&gt; running its sync jobs.&lt;/li&gt;
&lt;li&gt;All three crawlers were legitimate: GPTBot&amp;rsquo;s IPs matched OpenAI&amp;rsquo;s published ranges, ClaudeBot came from Anthropic&amp;rsquo;s IP space, and Reflectionbot&amp;rsquo;s reverse DNS resolved back to &lt;code&gt;reflection.ai&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2026/10/29/crawler-verification.png" alt="Verifying the three crawlers: Reflectionbot, GPTBot, and ClaudeBot are all genuine bots"&gt;&lt;/p&gt;
&lt;p&gt;Nothing pointed to an account breach. The bots were simply crawling pages that Gitea left publicly accessible to anonymous visitors: they requested &lt;code&gt;/robots.txt&lt;/code&gt; first, got a 404 because none existed, and proceeded to scrape every page returning HTTP 200. Looking back, I had left the front door wide open without realizing it; the primary issue to fix was my own configuration.&lt;/p&gt;
&lt;p&gt;While auditing further, I uncovered something much more concerning: &lt;strong&gt;one private repository had been exposed&lt;/strong&gt;. The source repo on GitHub was private, but its mirror on Gitea was &lt;strong&gt;public&lt;/strong&gt;, and Reflectionbot had already fetched 48 pages from it. Tracing the sync history led me to a stale record that &lt;code&gt;gitea-mirror&lt;/code&gt; had reused:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Originally, that repository name belonged to a public repo. When importing it the first time, &lt;code&gt;gitea-mirror&lt;/code&gt; saved the flag &lt;code&gt;is_private = 0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Later, that public repo was moved to a different namespace.&lt;/li&gt;
&lt;li&gt;I created a new &lt;strong&gt;private&lt;/strong&gt; repository under the old name. The existing record in &lt;code&gt;gitea-mirror&lt;/code&gt; still pointed to that URL and kept the public flag. Because the tool treated it as the same repository, it never re-checked its visibility.&lt;/li&gt;
&lt;li&gt;Gitea kept pulling updates from that URL using my GitHub token. As a result, the contents of the new private repo were synced straight into the public mirror on Gitea.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Even setting &lt;code&gt;visibility: &amp;quot;private&amp;quot;&lt;/code&gt; in &lt;code&gt;gitea-mirror&lt;/code&gt; didn&amp;rsquo;t prevent this: that setting only applies to organizations created by the tool, whereas individual repository visibility is still taken from the GitHub private flag captured at the initial import.&lt;/p&gt;
&lt;p&gt;I audited everything and found 105 repositories readable without signing in, all under my personal Gitea account. All other organizations were private. Out of those 105 public mirrors, only the one I had just caught corresponded to a private repo on GitHub.&lt;/p&gt;
&lt;p&gt;Why Cloudflare hadn&amp;rsquo;t blocked the bots was even simpler: every DNS record for my apps was an &lt;code&gt;A&lt;/code&gt; record set to &lt;strong&gt;DNS only&lt;/strong&gt; (grey cloud). Bots were hitting the origin server directly, so their requests never passed through Cloudflare to be filtered in the first place.&lt;/p&gt;
&lt;h2 id="mitigation"&gt;Mitigation&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Step one was stopping any further data exposure.&lt;/strong&gt; I stopped both Gitea and &lt;code&gt;gitea-mirror&lt;/code&gt;, then switched the exposed repository to private.&lt;/p&gt;
&lt;p&gt;Initially, I considered putting all my applications behind Cloudflare Tunnel and Cloudflare Access. However, that approach would have required quite a bit of rework: changing URLs in Coolify to &lt;code&gt;http://&lt;/code&gt;, reconfiguring each app, and sorting out webhooks. I set that aside for later and chose a less invasive first step: &lt;strong&gt;enabling the Cloudflare proxy (orange cloud)&lt;/strong&gt; on my DNS records. They still point to the same IP, Traefik and Coolify keep working the same way, and Cloudflare sits in the middle to filter out bots.&lt;/p&gt;
&lt;p&gt;On the afternoon of October 29, I rolled out the changes step by step:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Switched SSL/TLS from Full to Full (strict).&lt;/strong&gt; Traefik continues using its Let&amp;rsquo;s Encrypt certificates and renews them via HTTP-01 even with the proxy enabled. I avoided Flexible mode because Traefik already redirects HTTP to HTTPS; combining the two would cause an infinite redirect loop.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tested on a low-risk app first&lt;/strong&gt; — a web-based terminal. I verified the &lt;code&gt;server: cloudflare&lt;/code&gt; response header, page loading, and WebSocket connectivity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enabled the bot-blocking layers&lt;/strong&gt; available on the Cloudflare Free plan:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AI bot policies&lt;/strong&gt;: set Training, Agent, and Search to Block, since I have no reason for these self-hosted apps to show up in AI search results.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bot Preference Sync&lt;/strong&gt; (Cloudflare-managed &lt;code&gt;robots.txt&lt;/code&gt;): automatically injects &lt;code&gt;Disallow&lt;/code&gt; rules for AI bots into &lt;code&gt;robots.txt&lt;/code&gt;, or serves one if the app doesn&amp;rsquo;t have its own.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;A custom WAF rule&lt;/strong&gt; to catch anything the built-in policies might miss:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;(cf.verified_bot_category in {&amp;#34;AI Crawler&amp;#34; &amp;#34;AI Assistant&amp;#34; &amp;#34;AI Search&amp;#34;})
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;or (http.user_agent contains &amp;#34;Reflectionbot&amp;#34;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enabled the proxy on the wildcard record&lt;/strong&gt; &lt;code&gt;*.miti99.dev&lt;/code&gt;. Flipping that single switch covered nearly 20 apps at once, and any new app using the wildcard record will be proxied by default. If I ever need to roll back, I can just toggle the proxy off.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enabled the proxy on Coolify last&lt;/strong&gt;, then tested GitHub push deployment webhooks, Sentinel metrics coming from my second server, MCP, and real-time WebSocket connections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Configured Traefik to trust Cloudflare&amp;rsquo;s IP ranges&lt;/strong&gt; via &lt;code&gt;forwardedHeaders.trustedIPs&lt;/code&gt;, so backend applications see the real visitor IP instead of Cloudflare&amp;rsquo;s edge IP.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I also deliberately &lt;strong&gt;left Bot Fight Mode turned off&lt;/strong&gt;. On the Free plan, its challenge mechanism can block legitimate automated traffic, and WAF rules aren&amp;rsquo;t allowed to bypass it. For my setup, turning it on risked breaking GitHub webhooks, Sentinel, MCP, Nextcloud sync, and even Git operations over HTTP.&lt;/p&gt;
&lt;p&gt;Testing with &lt;code&gt;curl&lt;/code&gt;, requests with a normal browser user agent returned HTTP 200, while requests spoofing GPTBot, ClaudeBot, or Reflectionbot user agents received an immediate HTTP 403 at Cloudflare&amp;rsquo;s edge. Once that was confirmed, I started Gitea back up behind the proxy.&lt;/p&gt;
&lt;p&gt;Even so, routing traffic through Cloudflare comes with a few limitations to keep in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Request bodies larger than 100 MB are rejected. Nextcloud uses chunked uploads, so it isn&amp;rsquo;t affected by this limit.&lt;/li&gt;
&lt;li&gt;Requests that take longer than ~100 seconds without sending data can hit an HTTP 524 timeout. Long-running LLM calls that don&amp;rsquo;t stream responses are something to watch out for.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The origin server IP is still reachable directly.&lt;/strong&gt; Any bot that already knows the origin IP can talk straight to Traefik. Proxying filters crawlers that resolve via DNS through Cloudflare, but it doesn&amp;rsquo;t replace proper access control.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="follow-up-monitoring"&gt;Follow-Up Monitoring&lt;/h2&gt;&lt;p&gt;The post-cutover logs illustrated that last point clearly. I enabled the proxy for Gitea at 09:14 UTC (16:14 Vietnam time), then filtered the access log on the origin server to see whether the three bots were still getting through:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; ua in GPTBot ClaudeBot Reflectionbot&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$ua&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;grep -c &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$ua&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; access.log&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;ClaudeBot&lt;/strong&gt; stopped completely at 09:14:20 — almost immediately after the DNS change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reflectionbot&lt;/strong&gt; trickled in for about 6 more minutes, likely due to DNS caching.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GPTBot&lt;/strong&gt; kept sending requests directly to the origin IP — another &lt;strong&gt;7,056 requests over the next hour&lt;/strong&gt; — before finally stopping at 10:14. The &lt;code&gt;ClientAddr&lt;/code&gt; field showed OpenAI&amp;rsquo;s IPs rather than Cloudflare&amp;rsquo;s. My guess is that the bot caches DNS responses longer than the record&amp;rsquo;s TTL.&lt;/li&gt;
&lt;li&gt;From that point until the time of writing — about 4 hours — the origin server recorded &lt;strong&gt;0 requests&lt;/strong&gt; from all three bots.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To make sure this setup stays effective, here&amp;rsquo;s what I&amp;rsquo;ll continue monitoring:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Security → Events&lt;/strong&gt; in Cloudflare: verify that AI bots continue to be blocked and check whether any new user agents need to be added to the WAF rule.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Traefik access logs on the origin server&lt;/strong&gt;: filter using the snippet above. If a crawler reappears with a &lt;code&gt;ClientAddr&lt;/code&gt; outside Cloudflare&amp;rsquo;s IP ranges, it&amp;rsquo;s hitting the origin IP directly. At that point, I&amp;rsquo;ll either lock the firewall down to allow only Cloudflare IPs or revisit the Cloudflare Tunnel approach.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;robots.txt&lt;/code&gt; on each host&lt;/strong&gt;: run &lt;code&gt;curl https://&amp;lt;app&amp;gt;.example.com/robots.txt&lt;/code&gt; to confirm Cloudflare&amp;rsquo;s AI bot &lt;code&gt;Disallow&lt;/code&gt; rules are present.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New applications&lt;/strong&gt;: Coolify creates new DNS records in DNS-only mode by default. Any host with its own dedicated record needs the proxy toggled on manually; forgetting one leaves a direct path open again.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cloudflare IP ranges&lt;/strong&gt;: although they rarely change, I still need to keep Traefik&amp;rsquo;s &lt;code&gt;trustedIPs&lt;/code&gt; list updated when they do.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I still have a few follow-up tasks left: enabling &lt;code&gt;REQUIRE_SIGNIN_VIEW&lt;/code&gt; so Gitea requires authentication before viewing any page, wiping the existing mirrors, and rotating the GitHub token used by &lt;code&gt;gitea-mirror&lt;/code&gt;. Requiring sign-in is what truly stops outsiders from reading repositories; the Cloudflare proxy is just an extra layer of defense in front. I&amp;rsquo;m also considering sending data deletion requests to Reflection AI, OpenAI, and Anthropic.&lt;/p&gt;
&lt;h2 id="takeaways"&gt;Takeaways&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Anything public on the internet will eventually be scraped thoroughly.&lt;/strong&gt; AI crawlers don&amp;rsquo;t stop at your homepage — they will walk through every single commit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Double-check visibility settings when syncing across systems.&lt;/strong&gt; A single stale record under a reused repo name was enough to mirror a private GitHub repository into a public Gitea repo.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you want Cloudflare to filter traffic, traffic actually has to go through the proxy.&lt;/strong&gt; For my small self-hosted setup, flipping on the proxy was a practical first step before moving to tunnels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audit your automated integrations before enabling Bot Fight Mode.&lt;/strong&gt; When your server also receives webhooks and serves non-browser clients, bot protection has to account for those workflows too.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Trying Different AI Coding Tools to Write My Newsletter</title><link>https://miti99.com/en/post/2026/06/01/</link><pubDate>Mon, 01 Jun 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/06/01/</guid><description>&lt;p&gt;Starting today, I&amp;rsquo;m going to rotate through several AI coding tools to write my newsletter: &lt;strong&gt;Claude Code&lt;/strong&gt;, &lt;strong&gt;Codex&lt;/strong&gt;, &lt;strong&gt;OpenCode&lt;/strong&gt;, and &lt;strong&gt;Gemini CLI / Antigravity&lt;/strong&gt;. The goal is to &lt;strong&gt;get the most value out of my active subscriptions&lt;/strong&gt;. Instead of relying on a single tool while leaving the others idle, I&amp;rsquo;ll spread the work across all the plans I&amp;rsquo;ve paid for—prioritizing whichever subscription has the most remaining quota so nothing goes to waste.&lt;/p&gt;
&lt;h2 id="opencode--opencode-go"&gt;OpenCode + OpenCode Go&lt;/h2&gt;&lt;p&gt;For &lt;strong&gt;OpenCode&lt;/strong&gt;, I&amp;rsquo;m using &lt;strong&gt;OpenCode Go&lt;/strong&gt; as the provider. It includes a solid lineup of Chinese models, giving me more options to experiment with. Right now, I&amp;rsquo;m using &lt;strong&gt;DeepSeek V4 Pro&lt;/strong&gt; on this plan. Word is that DeepSeek is both capable and affordable, so let&amp;rsquo;s see how it holds up! 😉&lt;/p&gt;
&lt;h2 id="gemini-cli--antigravity"&gt;Gemini CLI → Antigravity&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ve also been using &lt;strong&gt;Gemini CLI&lt;/strong&gt;—Google&amp;rsquo;s AI coding tool. However, Google &lt;a href="https://blog.google/technology/developers/antigravity/" rel="noopener noreferrer"&gt;announced the deprecation of Gemini CLI on May 19&lt;/a&gt;, and it will be &lt;strong&gt;shut down on June 18, 2026&lt;/strong&gt;. Its replacement is &lt;strong&gt;Antigravity CLI&lt;/strong&gt; (&lt;code&gt;agy&lt;/code&gt;), rewritten in Go for faster performance and better multi-agent workflow support. I&amp;rsquo;ve already started migrating over to Antigravity.&lt;/p&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s Next&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ll share more thoughts after rotating through these tools for a while. Stay tuned!&lt;/p&gt;</description></item><item><title>Mocking Time in Java: A Simple Way to Test Time-Dependent Logic</title><link>https://miti99.com/en/post/2026/04/11/</link><pubDate>Sat, 11 Apr 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/04/11/</guid><description>&lt;p&gt;Anyone who writes Java has probably run into this situation: business logic that depends on the current time — an order expires after 30 minutes, a voucher is only valid during happy hour, a cron job runs at midnight, a token refreshes after an hour&amp;hellip; When writing unit tests for code like that, how do you &amp;ldquo;fast-forward&amp;rdquo; or &amp;ldquo;rewind&amp;rdquo; time?&lt;/p&gt;
&lt;p&gt;In this post, I&amp;rsquo;m sharing the approach I use in my project &lt;a href="https://github.com/tiennm99/mitisrv" rel="noopener noreferrer"&gt;mitisrv&lt;/a&gt; — super simple, with no heavy frameworks required. It was inspired by the article &lt;a href="https://dzone.com/articles/mock-java-datetime-for-testing" rel="noopener noreferrer"&gt;Mock Java Date/Time for Testing&lt;/a&gt; on DZone.&lt;/p&gt;
&lt;h2 id="the-problem"&gt;The Problem&lt;/h2&gt;&lt;p&gt;Suppose you have a piece of code like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;isExpired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="na"&gt;isAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExpiredAt&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;When writing tests, you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create an order with &lt;code&gt;expiredAt&lt;/code&gt; in the past → expired test case ✓&lt;/li&gt;
&lt;li&gt;Create an order with &lt;code&gt;expiredAt&lt;/code&gt; in the future → still-valid test case ✓&lt;/li&gt;
&lt;li&gt;But what about the test case &amp;ldquo;at the exact moment of expiration&amp;rdquo;? Or testing logic that only runs at 00:00 tomorrow?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Calling &lt;code&gt;LocalDateTime.now()&lt;/code&gt; directly makes your code &lt;strong&gt;non-deterministic&lt;/strong&gt; — a test run at 11:59 PM might pass, while the same test run at 12:01 AM fails. That&amp;rsquo;s a CI/CD nightmare.&lt;/p&gt;
&lt;h2 id="common-approaches"&gt;Common Approaches&lt;/h2&gt;&lt;h3 id="1-injecting-javatimeclock"&gt;1. Injecting &lt;code&gt;java.time.Clock&lt;/code&gt;&lt;/h3&gt;&lt;p&gt;Java 8+ recommends using &lt;code&gt;Clock&lt;/code&gt; and injecting it wherever needed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderService&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;private&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;final&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;OrderService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;isExpired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="na"&gt;isAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExpiredAt&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;In tests, you use &lt;code&gt;Clock.fixed(...)&lt;/code&gt; to pin the time. &lt;strong&gt;Pros:&lt;/strong&gt; clean and idiomatic. &lt;strong&gt;Cons:&lt;/strong&gt; you have to touch the entire codebase to inject &lt;code&gt;Clock&lt;/code&gt; into every class that needs it, which is a pain in a large existing project.&lt;/p&gt;
&lt;h3 id="2-static-mocking-with-powermockmockito"&gt;2. Static Mocking with PowerMock/Mockito&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MockedStatic&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mocked&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mockStatic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;mocked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="na"&gt;thenReturn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixedTime&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// test code&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; no changes to production code. &lt;strong&gt;Cons:&lt;/strong&gt; static mocking is slow, easy to leak across tests if you&amp;rsquo;re not careful, and &lt;code&gt;mockStatic&lt;/code&gt; requires Mockito 3.4+. Plus, if your code mixes &lt;code&gt;LocalDate.now()&lt;/code&gt;, &lt;code&gt;Instant.now()&lt;/code&gt;, and &lt;code&gt;ZonedDateTime.now()&lt;/code&gt;, you have to mock each one separately.&lt;/p&gt;
&lt;h3 id="3-custom-time-utility-with-a-delta-offset"&gt;3. Custom &lt;code&gt;Time&lt;/code&gt; Utility with a Delta Offset&lt;/h3&gt;&lt;p&gt;This is the approach I chose for mitisrv. The idea: create a &lt;code&gt;Time&lt;/code&gt; class that replaces all calls to get the current time, and internally store a &lt;code&gt;deltaMillis&lt;/code&gt; — the offset between &amp;ldquo;mock time&amp;rdquo; and the actual system time.&lt;/p&gt;
&lt;h2 id="implementation-in-mitisrv"&gt;Implementation in mitisrv&lt;/h2&gt;&lt;p&gt;Here is the complete &lt;a href="https://github.com/tiennm99/mitisrv/blob/main/src/main/java/com/miti99/mitisrv/util/time/Time.java" rel="noopener noreferrer"&gt;&lt;code&gt;Time.java&lt;/code&gt;&lt;/a&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;span class="lnt"&gt;17
&lt;/span&gt;&lt;span class="lnt"&gt;18
&lt;/span&gt;&lt;span class="lnt"&gt;19
&lt;/span&gt;&lt;span class="lnt"&gt;20
&lt;/span&gt;&lt;span class="lnt"&gt;21
&lt;/span&gt;&lt;span class="lnt"&gt;22
&lt;/span&gt;&lt;span class="lnt"&gt;23
&lt;/span&gt;&lt;span class="lnt"&gt;24
&lt;/span&gt;&lt;span class="lnt"&gt;25
&lt;/span&gt;&lt;span class="lnt"&gt;26
&lt;/span&gt;&lt;span class="lnt"&gt;27
&lt;/span&gt;&lt;span class="lnt"&gt;28
&lt;/span&gt;&lt;span class="lnt"&gt;29
&lt;/span&gt;&lt;span class="lnt"&gt;30
&lt;/span&gt;&lt;span class="lnt"&gt;31
&lt;/span&gt;&lt;span class="lnt"&gt;32
&lt;/span&gt;&lt;span class="lnt"&gt;33
&lt;/span&gt;&lt;span class="lnt"&gt;34
&lt;/span&gt;&lt;span class="lnt"&gt;35
&lt;/span&gt;&lt;span class="lnt"&gt;36
&lt;/span&gt;&lt;span class="lnt"&gt;37
&lt;/span&gt;&lt;span class="lnt"&gt;38
&lt;/span&gt;&lt;span class="lnt"&gt;39
&lt;/span&gt;&lt;span class="lnt"&gt;40
&lt;/span&gt;&lt;span class="lnt"&gt;41
&lt;/span&gt;&lt;span class="lnt"&gt;42
&lt;/span&gt;&lt;span class="lnt"&gt;43
&lt;/span&gt;&lt;span class="lnt"&gt;44
&lt;/span&gt;&lt;span class="lnt"&gt;45
&lt;/span&gt;&lt;span class="lnt"&gt;46
&lt;/span&gt;&lt;span class="lnt"&gt;47
&lt;/span&gt;&lt;span class="lnt"&gt;48
&lt;/span&gt;&lt;span class="lnt"&gt;49
&lt;/span&gt;&lt;span class="lnt"&gt;50
&lt;/span&gt;&lt;span class="lnt"&gt;51
&lt;/span&gt;&lt;span class="lnt"&gt;52
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;package&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;com.miti99.mitisrv.util.time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.Instant&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.LocalDate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.LocalTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.OffsetDateTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.ZoneId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.time.ZonedDateTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;java.util.TimeZone&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;private&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;final&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TimeZone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TIME_ZONE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TimeZone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;private&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;final&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZoneId&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TIME_ZONE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toZoneId&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;private&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;volatile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;deltaMillis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;0L&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInstant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInstant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentDateTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInstant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OffsetDateTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentOffsetDateTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;OffsetDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInstant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZonedDateTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentZonedDateTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZonedDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofInstant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZONE_ID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Instant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentInstant&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofEpochMilli&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currentTimeMillis&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;currentTimeMillis&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;currentTimeMillis&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;deltaMillis&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;useMockTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dateTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZoneId&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;zoneId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;deltaMillis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;atZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;zoneId&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="na"&gt;toInstant&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="na"&gt;toEpochMilli&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;currentTimeMillis&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;useSystemDefaultZoneClock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;deltaMillis&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;0L&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;A few notable details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Every time-fetching API&lt;/strong&gt; (&lt;code&gt;currentDate&lt;/code&gt;, &lt;code&gt;currentDateTime&lt;/code&gt;, &lt;code&gt;currentInstant&lt;/code&gt;, etc.) funnels through a single method: &lt;code&gt;currentTimeMillis()&lt;/code&gt;. Mocking that one place keeps the entire system in sync.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;deltaMillis&lt;/code&gt; is &lt;code&gt;volatile&lt;/code&gt;&lt;/strong&gt; to ensure changes are immediately visible across threads — important when testing in multi-threaded environments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;useMockTime()&lt;/code&gt; doesn&amp;rsquo;t freeze time&lt;/strong&gt; — it &lt;strong&gt;shifts&lt;/strong&gt; it. That means if you mock the time to &lt;code&gt;2026-01-01 00:00:00&lt;/code&gt; and wait 5 real seconds, &lt;code&gt;Time.currentDateTime()&lt;/code&gt; will return &lt;code&gt;2026-01-01 00:00:05&lt;/code&gt;. That&amp;rsquo;s an important difference from &lt;code&gt;Clock.fixed()&lt;/code&gt; — time still flows naturally, just starting from a different point.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;useSystemDefaultZoneClock()&lt;/code&gt; resets&lt;/strong&gt; back to real system time; call it in &lt;code&gt;@AfterEach&lt;/code&gt; so test cases don&amp;rsquo;t bleed into one another.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="how-to-use-it"&gt;How to Use It&lt;/h2&gt;&lt;p&gt;In production code, instead of calling &lt;code&gt;LocalDateTime.now()&lt;/code&gt;, call &lt;code&gt;Time.currentDateTime()&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;isExpired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;currentDateTime&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="na"&gt;isAfter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getExpiredAt&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;In your test:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nd"&gt;@Test&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;orderShouldBeExpiredAfter30Minutes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setExpiredAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;2026&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;0&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// &amp;#34;Fast-forward&amp;#34; time to 12:31&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;useMockTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LocalDateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;2026&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ZoneId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;systemDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isExpired&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;useSystemDefaultZoneClock&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// reset&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Use &lt;code&gt;@AfterEach&lt;/code&gt; to make sure it always resets cleanly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nd"&gt;@AfterEach&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;tearDown&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;useSystemDefaultZoneClock&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="comparing-the-approaches"&gt;Comparing the Approaches&lt;/h2&gt;&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Criterion&lt;/th&gt;
 &lt;th&gt;&lt;code&gt;Clock&lt;/code&gt; injection&lt;/th&gt;
 &lt;th&gt;&lt;code&gt;mockStatic&lt;/code&gt;&lt;/th&gt;
 &lt;th&gt;Custom &lt;code&gt;Time&lt;/code&gt; util&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;Production code changes&lt;/td&gt;
 &lt;td&gt;Heavy (inject Clock everywhere)&lt;/td&gt;
 &lt;td&gt;None&lt;/td&gt;
 &lt;td&gt;One-off (replace &lt;code&gt;.now()&lt;/code&gt;)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Framework dependency&lt;/td&gt;
 &lt;td&gt;None&lt;/td&gt;
 &lt;td&gt;Mockito 3.4+&lt;/td&gt;
 &lt;td&gt;None&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Test speed&lt;/td&gt;
 &lt;td&gt;Fast&lt;/td&gt;
 &lt;td&gt;Slow&lt;/td&gt;
 &lt;td&gt;Fast&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Time continues flowing&lt;/td&gt;
 &lt;td&gt;No (&lt;code&gt;Clock.fixed&lt;/code&gt;)&lt;/td&gt;
 &lt;td&gt;No&lt;/td&gt;
 &lt;td&gt;Yes&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Thread-safe&lt;/td&gt;
 &lt;td&gt;Yes&lt;/td&gt;
 &lt;td&gt;Yes (scoped)&lt;/td&gt;
 &lt;td&gt;Yes (&lt;code&gt;volatile&lt;/code&gt;)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Idiomatic &amp;ldquo;Java way&amp;rdquo;&lt;/td&gt;
 &lt;td&gt;✓✓✓&lt;/td&gt;
 &lt;td&gt;✓&lt;/td&gt;
 &lt;td&gt;✓&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="downsides-of-the-custom-time-util"&gt;Downsides of the Custom &lt;code&gt;Time&lt;/code&gt; Util&lt;/h2&gt;&lt;p&gt;No approach is perfect, and this one has a few trade-offs too:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Global state&lt;/strong&gt;: &lt;code&gt;deltaMillis&lt;/code&gt; is &lt;code&gt;static&lt;/code&gt;, so if you run tests in parallel within the same JVM, tests will step on each other&amp;rsquo;s toes. If you need parallel execution, you either have to configure your test runner to fork a separate JVM per class, or replace &lt;code&gt;volatile&lt;/code&gt; with &lt;code&gt;ThreadLocal&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Requires codebase-wide discipline&lt;/strong&gt; not to call &lt;code&gt;LocalDateTime.now()&lt;/code&gt; directly anymore. And if a third-party library calls &lt;code&gt;.now()&lt;/code&gt; internally, this utility won&amp;rsquo;t control it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not standard Java&lt;/strong&gt;: newcomers to the project might be surprised to see &lt;code&gt;Time.currentDateTime()&lt;/code&gt; instead of &lt;code&gt;LocalDateTime.now()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="when-should-you-use-which"&gt;When Should You Use Which?&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;New or small project, team comfortable with DI&lt;/strong&gt;: use &lt;code&gt;Clock&lt;/code&gt; injection for the clean, standard approach.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Legacy project where you want to avoid a big refactor&lt;/strong&gt;: use &lt;code&gt;mockStatic&lt;/code&gt; locally in individual tests and accept the slower execution.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Project where you want both simplicity and flowing time, running tests sequentially&lt;/strong&gt;: use a custom &lt;code&gt;Time&lt;/code&gt; util like in mitisrv.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For me, the &lt;code&gt;Time&lt;/code&gt; utility is simple, easy to understand, easy to maintain, and doesn&amp;rsquo;t require learning another framework. The trade-off is maintaining discipline when writing code — always calling &lt;code&gt;Time.xxx()&lt;/code&gt; instead of &lt;code&gt;LocalDateTime.now()&lt;/code&gt;. A simple lint rule or check during PR review is enough to keep that habit intact.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dzone.com/articles/mock-java-datetime-for-testing" rel="noopener noreferrer"&gt;Mock Java Date/Time for Testing - DZone&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tiennm99/mitisrv/blob/main/src/main/java/com/miti99/mitisrv/util/time/Time.java" rel="noopener noreferrer"&gt;&lt;code&gt;Time.java&lt;/code&gt; in mitisrv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/Clock.html" rel="noopener noreferrer"&gt;Java &lt;code&gt;Clock&lt;/code&gt; documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Hibernate merge: Getting the Entity ID the Right Way</title><link>https://miti99.com/en/post/2026/04/10/</link><pubDate>Fri, 10 Apr 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/04/10/</guid><description>&lt;p&gt;A small pitfall that once cost me a fair bit of debugging time.&lt;/p&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;&lt;p&gt;When using &lt;code&gt;EntityManager.merge()&lt;/code&gt; to save a new entity, many people are in the habit of writing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;entityManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getId&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// null or stale value!&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;And&amp;hellip; &lt;code&gt;id&lt;/code&gt; doesn&amp;rsquo;t have the value you expected.&lt;/p&gt;
&lt;h2 id="cause"&gt;Cause&lt;/h2&gt;&lt;p&gt;&lt;code&gt;merge()&lt;/code&gt; &lt;strong&gt;does not update&lt;/strong&gt; the object you pass in. Instead, it copies the state from that object into a &lt;strong&gt;new managed instance&lt;/strong&gt; and returns that instance. The original object remains detached and is never assigned an ID by Hibernate.&lt;/p&gt;
&lt;h2 id="the-right-way"&gt;The Right Way&lt;/h2&gt;&lt;p&gt;Use the &lt;strong&gt;returned object&lt;/strong&gt; from &lt;code&gt;merge()&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;MyEntity&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;managed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;entityManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Long&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;managed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getId&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s all there is to it. Unlike &lt;code&gt;persist()&lt;/code&gt; — which mutates the passed-in object directly and therefore doesn&amp;rsquo;t have this issue.&lt;/p&gt;</description></item><item><title>Fixing Gradle Test Crashes Due to Out of Memory: Configuring maxHeapSize</title><link>https://miti99.com/en/post/2026/04/08/</link><pubDate>Wed, 08 Apr 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/04/08/</guid><description>&lt;p&gt;A quick tip I figured out a long time ago and am finally getting around to sharing.&lt;/p&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;&lt;p&gt;When running &lt;code&gt;./gradlew test&lt;/code&gt;, tests occasionally crash mid-run with an &lt;code&gt;OutOfMemoryError&lt;/code&gt; or a message that the worker process &amp;ldquo;disappeared unexpectedly&amp;rdquo;. Re-running them sometimes passes and sometimes fails — super flaky.&lt;/p&gt;
&lt;h2 id="cause"&gt;Cause&lt;/h2&gt;&lt;p&gt;Gradle runs tests in a separate JVM worker process whose default heap size is fairly small (usually just 512MB). A heavy test suite (Spring context, H2, lots of test data, etc.) can easily hit that ceiling.&lt;/p&gt;
&lt;h2 id="how-to-fix"&gt;How to Fix&lt;/h2&gt;&lt;p&gt;Add this to &lt;code&gt;build.gradle&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-groovy" data-lang="groovy"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;maxHeapSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;1024m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Or in &lt;code&gt;build.gradle.kts&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-kotlin" data-lang="kotlin"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;maxHeapSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;1024m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Done. If it still crashes, bump it up to &lt;code&gt;&amp;quot;2048m&amp;quot;&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Fixing 'Pairing Required' When Connecting to OpenClaw via Docker</title><link>https://miti99.com/en/post/2026/04/05/</link><pubDate>Sun, 05 Apr 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/04/05/</guid><description>&lt;p&gt;If you&amp;rsquo;re self-hosting &lt;a href="https://github.com/open-claw/open-claw" rel="noopener noreferrer"&gt;OpenClaw&lt;/a&gt; with Docker and run into the &lt;strong&gt;&amp;ldquo;disconnected (1008): pairing required&amp;rdquo;&lt;/strong&gt; error when accessing it from your browser, this post will help you fix it quickly.&lt;/p&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;&lt;p&gt;After setting up OpenClaw with Docker on Ubuntu, the browser shows:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;disconnected (1008): pairing required
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Trying to use the CLI to approve the device then fails with &lt;strong&gt;&amp;ldquo;gateway token mismatch&amp;rdquo;&lt;/strong&gt; — the CLI inside the Docker container doesn&amp;rsquo;t properly resolve the authentication token from the config file.&lt;/p&gt;
&lt;h2 id="cause"&gt;Cause&lt;/h2&gt;&lt;p&gt;There is an authentication token mismatch between the host and the Docker container. The CLI inside the container fails to read the right token from &lt;code&gt;openclaw.json&lt;/code&gt;, which prevents it from listing or approving devices.&lt;/p&gt;
&lt;h2 id="how-to-fix"&gt;How to Fix&lt;/h2&gt;&lt;h3 id="step-1-get-the-gateway-token-from-the-host"&gt;Step 1: Get the Gateway Token from the Host&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cat ~/.openclaw/openclaw.json &lt;span class="p"&gt;|&lt;/span&gt; grep -A5 &lt;span class="s1"&gt;&amp;#39;&amp;#34;auth&amp;#34;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Copy the token value under &lt;code&gt;gateway.auth&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="step-2-check-the-token-inside-the-container"&gt;Step 2: Check the Token Inside the Container&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker ps &lt;span class="c1"&gt;# Get the CONTAINER_ID of openclaw-gateway&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; -it &amp;lt;CONTAINER_ID&amp;gt; cat /home/node/.openclaw/openclaw.json &lt;span class="p"&gt;|&lt;/span&gt; grep -A5 &lt;span class="s1"&gt;&amp;#39;&amp;#34;auth&amp;#34;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Verify whether the token on the host matches the one inside the container.&lt;/p&gt;
&lt;h3 id="step-3-list-devices-with-a-token-override"&gt;Step 3: List Devices with a Token Override&lt;/h3&gt;&lt;p&gt;Inject the token directly via the &lt;code&gt;-e&lt;/code&gt; environment variable flag when running the command in the container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; -e &lt;span class="nv"&gt;OPENCLAW_GATEWAY_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;YOUR_TOKEN&amp;gt; -it &amp;lt;CONTAINER_ID&amp;gt; &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; openclaw devices list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This command will display the list of devices waiting for approval along with their &lt;strong&gt;Request ID&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id="step-4-approve-the-device"&gt;Step 4: Approve the Device&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;docker compose &lt;span class="nb"&gt;exec&lt;/span&gt; openclaw-gateway &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; openclaw devices approve &amp;lt;REQUEST_ID&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id="step-5-verify-the-result"&gt;Step 5: Verify the Result&lt;/h3&gt;&lt;p&gt;Reload &lt;code&gt;http://localhost:18789&lt;/code&gt; in your browser — the pairing error will be gone.&lt;/p&gt;
&lt;h2 id="note"&gt;Note&lt;/h2&gt;&lt;p&gt;The key to this fix is injecting the token via an environment variable (&lt;code&gt;-e OPENCLAW_GATEWAY_TOKEN=...&lt;/code&gt;) rather than passing it as a command-line flag, because the CLI inside Docker doesn&amp;rsquo;t handle the token flag properly.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/pulse/fixing-openclaw-dockers-pairing-required-dead-end-ubuntu-rik-banerjee-j09de/" rel="noopener noreferrer"&gt;Fixing OpenClaw Docker&amp;rsquo;s &amp;ldquo;Pairing Required&amp;rdquo; Dead End on Ubuntu - Rik Banerjee&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Investing in AI Coding: Claude Max, ClaudeKit, and MiniMax</title><link>https://miti99.com/en/post/2026/04/01/</link><pubDate>Wed, 01 Apr 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/04/01/</guid><description>&lt;p&gt;After going back and forth for a long time, I finally decided to open my wallet and spend on AI coding tools for both work and personal projects. And no, this is definitely not an April Fools&amp;rsquo; joke 😄&lt;/p&gt;
&lt;h2 id="claude-max"&gt;Claude Max&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ve been using Claude for quite a while now and even tried Pro early on. Claude models are genuinely great, but the pricing is pretty steep — so I mostly stuck to the free tier and spent a little on Chinese models or free alternatives. Recently, though, Claude Code has really blown up, and I can clearly feel that pairing Claude Code with Claude models outshines everything else by a wide margin. Luckily (or maybe not), two weeks ago Anthropic rolled out a 2x token promotion during off-peak hours. Even on the Pro plan I was still hitting limits left and right, so after thinking it over, I decided to go all in on Claude Max. Using it all day long without worrying about limits feels amazing 😂&lt;/p&gt;
&lt;p&gt;Of course, I&amp;rsquo;ll also be using Claude to help with blogging — hopefully my upcoming posts will be much better.&lt;/p&gt;
&lt;h2 id="claudekit"&gt;ClaudeKit&lt;/h2&gt;&lt;p&gt;Alongside Claude Max, I also bought &lt;a href="https://claudekit.cc/?ref=BWA910UK" rel="noopener noreferrer"&gt;ClaudeKit&lt;/a&gt;. This is a product by &lt;a href="https://substack.com/@goonnguyen" rel="noopener noreferrer"&gt;Duy (Zuey)&lt;/a&gt;, whom I&amp;rsquo;ve followed for a long time — I really enjoy his AI news updates as well as his practical tips for working with AI. ClaudeKit is a platform providing tools, prompt templates, workflows, and extensions to work with Claude more effectively. It&amp;rsquo;s a passion project he&amp;rsquo;s been pouring his heart into lately. I saw the big Lunar New Year sale he ran earlier, hesitated to spend the money, and ended up paying more now 🥹.&lt;/p&gt;
&lt;p&gt;From my initial impressions, ClaudeKit is a prompting framework for Claude Code, similar to SuperPowers. However, the tools in this &amp;ldquo;ecosystem&amp;rdquo; fit together super smoothly and cover almost everything you need. It really feels like an &amp;ldquo;All-in-One&amp;rdquo; toolkit where ClaudeKit alone is enough. Hopefully ClaudeKit will help me get the absolute most out of Claude in my upcoming software development work. When I find the time, I&amp;rsquo;ll write a proper review or share some tips on using it (though who knows when that&amp;rsquo;ll be :3)&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re interested, you can sign up via &lt;a href="https://claudekit.cc/?ref=BWA910UK" rel="noopener noreferrer"&gt;my referral link&lt;/a&gt; to get &lt;strong&gt;20% off&lt;/strong&gt; your first purchase!&lt;/p&gt;
&lt;h2 id="minimax-token-plan"&gt;MiniMax Token Plan&lt;/h2&gt;&lt;p&gt;Outside the Claude ecosystem, I&amp;rsquo;m also experimenting with the &lt;a href="https://platform.minimax.io/docs/token-plan/intro" rel="noopener noreferrer"&gt;&lt;strong&gt;MiniMax Token Plan&lt;/strong&gt;&lt;/a&gt;. MiniMax is an AI platform whose models boast impressive long-context handling. Version M2.7 is even advertised as having self-learning and self-improving capabilities, which sounds pretty promising. Right now I&amp;rsquo;m hosting it on OpenClaw so a few teammates and my younger brother can connect to it as a fallback whenever their Claude Pro tokens run out. One senior teammate told me he&amp;rsquo;d rate MiniMax around a 7/10 compared to Claude — pretty solid potential! He even rated MiniMax higher than Z.ai&amp;rsquo;s GLM-5 from earlier. By the time GLM-5.1 came out, my coding plan there was almost expired, so I didn&amp;rsquo;t compare them much.&lt;/p&gt;
&lt;h2 id="wrap-up"&gt;Wrap-Up&lt;/h2&gt;&lt;p&gt;My total monthly subscription bill has gone up significantly, but I see this as a worthwhile investment (or maybe because I hate wasting money, I&amp;rsquo;ll grind even harder to get my money&amp;rsquo;s worth 🤣). If these tools help me write code faster, ship fewer bugs, and save time debugging — then it&amp;rsquo;s completely worth it.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll share more hands-on experiences after using this setup for a while. Stay tuned!&lt;/p&gt;</description></item></channel></rss>