<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ZHIWEI</title>
    <description>The latest articles on DEV Community by ZHIWEI (@zhiwei_224e5e15600342dc0b).</description>
    <link>https://dev.to/zhiwei_224e5e15600342dc0b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4181129%2F67c44224-3270-4202-b374-fc7b047cf507.png</url>
      <title>DEV Community: ZHIWEI</title>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zhiwei_224e5e15600342dc0b"/>
    <language>en</language>
    <item>
      <title>How GTA 6-style photo filters turn a selfie into cel-shaded art</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Wed, 25 Nov 2026 15:34:05 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/how-gta-6-style-photo-filters-turn-a-selfie-into-cel-shaded-art-449n</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/how-gta-6-style-photo-filters-turn-a-selfie-into-cel-shaded-art-449n</guid>
      <description>&lt;p&gt;If you have been anywhere near gaming social feeds lately, you have seen them: selfies repainted as GTA 6-style promo art, with thick black outlines, cel shading, and that sunset pink-orange-teal grade from the trailers. They look like leaked loading screens. They are not - they are AI image-to-image filters, and they are easier to make than they look.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the "GTA 6 look" actually is
&lt;/h2&gt;

&lt;p&gt;Rockstar's promotional art for Grand Theft Auto VI leans on a few consistent ingredients:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bold outlines&lt;/strong&gt; around characters and objects, the way traditional cel animation is inked&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cel shading&lt;/strong&gt; - flat color regions with hard transitions instead of soft gradients&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A sunset palette&lt;/strong&gt; - pink, orange and teal washing over most of the frame&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Saturated, slightly exaggerated proportions&lt;/strong&gt; that read as "trailer art" at a glance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important part: a filter recreates the illustration style, not any actual game asset. Your photo supplies the composition; the style is painted on top.&lt;/p&gt;

&lt;h2&gt;
  
  
  How image-to-image filters do it
&lt;/h2&gt;

&lt;p&gt;The tools behind the trend are image-to-image models. You feed in a photo plus a style instruction, the model keeps the rough geometry of your picture (where the face is, how the shoulders sit), and repaints every region in the target style. Two things follow from that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Photo quality still matters.&lt;/strong&gt; A blurry, dark selfie gives the model less to hold on to. Face clearly visible, decent light, front-facing - the boring advice is the winning advice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every run is fresh.&lt;/strong&gt; The model generates a new image each time, so two runs with the same photo will not be identical. If a result feels off, another run can genuinely fix it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most tools also run a quick check that the upload contains a real human face before spending GPU time. That check is why photos of pets, drawings, or heavily filtered pictures get rejected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three ways to make one
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web tools - the two-minute route.&lt;/strong&gt; Something like &lt;a href="https://gamefacefilter.com/" rel="noopener noreferrer"&gt;GTA 6 Filter on GameFaceFilter&lt;/a&gt; runs entirely in the browser: upload a selfie, pick one of six styles (loading screen, neon night, street ride and so on), and get a picture back in about two minutes. It is fan-made and unofficial - not affiliated with Rockstar Games - gives you one free image a day after a Google sign-in, and photos plus results are deleted within 24 hours. If you like the result, it can also animate it into an 8-second vertical clip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General image editors - the control-freak route.&lt;/strong&gt; Photoshop-style apps can approximate the look with posterize layers, hard transitions and manual line work. Slower, but you control every edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Open-source style transfer - the GPU route.&lt;/strong&gt; If you already run local models, a ControlNet-style pipeline with a cel-shade LoRA gets you closest to the look and lets you batch it. Expect an evening of tinkering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting a result you will actually post
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Front-facing photo, face unobstructed, decent light&lt;/li&gt;
&lt;li&gt;Pick a style that matches the photo's mood instead of fighting it&lt;/li&gt;
&lt;li&gt;If the upload fails the face check, retake the photo rather than re-uploading the same one&lt;/li&gt;
&lt;li&gt;Judge a tool by whether the second picture looks good too - anyone can get lucky once&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a &lt;a href="https://gamefacefilter.com/how-to-turn-a-selfie-into-a-gta-6-character" rel="noopener noreferrer"&gt;step-by-step walkthrough of turning a selfie into a GTA 6-style character&lt;/a&gt; covering photo choice, style picking, and what to do when a selfie will not take, if you want the full process written out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The trend is a neat demo of how far image-to-image models have come: one selfie in, trailer-grade art out, no editing skills required. Whether you use a browser tool or your own pipeline, the recipe is the same - keep the geometry, repaint the surface, and lean into the sunset.&lt;/p&gt;




&lt;p&gt;Disclosure: this article was researched and drafted with AI tooling (image-to-image models, testing workflows) and the tool facts above were checked against the official site before publishing.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>I opened five "seven deadly sins" tests and compared what they ask of you</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Mon, 23 Nov 2026 09:42:16 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/i-opened-five-seven-deadly-sins-tests-and-compared-what-they-ask-of-you-2ph1</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/i-opened-five-seven-deadly-sins-tests-and-compared-what-they-ask-of-you-2ph1</guid>
      <description>&lt;p&gt;In my last post I built a seven deadly sins quiz that shows all seven scores instead of crowning one sin. Before shipping it I did the unflattering thing and opened the other tests that show up for the same search, one by one, in a normal browser. This is what differs between them, in the six places that decide how the next five minutes of your life go.&lt;/p&gt;

&lt;p&gt;Full disclosure up front: one of the five is mine. It is the last row in every table below and gets judged by the same criteria as the others, including the places where it is the worse choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six checks
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Number of questions&lt;/strong&gt; - the length of the test you actually answer, not what the title says.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer scale&lt;/strong&gt; - two choices, five levels, or a set of scene answers to pick from.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What the result gives back&lt;/strong&gt; - one label, all seven scores, a written portrait.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Account or email&lt;/strong&gt; - what stands between you and the result.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Photos, files and permissions&lt;/strong&gt; - whether anything asks to look at your device or your pictures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost&lt;/strong&gt; - whether part of the result is held back for a payment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every page was opened on 18 November 2026 and read the way a visitor reads it. Quizzes get rewritten, so check before relying on a single claim.&lt;/p&gt;

&lt;h2&gt;
  
  
  Side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test&lt;/th&gt;
&lt;th&gt;Questions&lt;/th&gt;
&lt;th&gt;Answer scale&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Account to see it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;IDR Labs&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;td&gt;Two-point slider&lt;/td&gt;
&lt;td&gt;Written portrait of all seven&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Psychology.com&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;td&gt;0-4 per statement&lt;/td&gt;
&lt;td&gt;Seven bars, leading vice, optional report&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testmoji&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;Four scene answers&lt;/td&gt;
&lt;td&gt;One leading sin plus the other six&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Freudly&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;Five levels&lt;/td&gt;
&lt;td&gt;Seven banded scores, comparison figures&lt;/td&gt;
&lt;td&gt;Optional&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mine (Deadly Sins Quiz)&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;td&gt;0-4 per statement&lt;/td&gt;
&lt;td&gt;Seven bars, ties named together&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What the design choices tell you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Length is the biggest split.&lt;/strong&gt; Fourteen questions against eighty is nearly a six-fold difference in time for the same seven scores. Testmoji trades precision for a two-minute path to a label; Freudly spends ten minutes to put a band and national comparison figures on every score. The three 35-item tests sit in the middle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The answer scale changes what a score means.&lt;/strong&gt; IDR Labs uses a two-point slider, so each statement is a yes or a no. A five-level scale lets someone say "slightly" or "very", which is why three of the five chose it: two label the levels 0 to 4, Freudly words them from "not me at all" to "exactly me". Testmoji skips rating altogether - you pick which of four scenes sounds most like you, and the result comes from the choice, not the intensity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All five score every sin.&lt;/strong&gt; Nobody hides six scores behind one headline. Testmoji leads with one and prints the other six beside it; the rest give you the full spread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;None of them needs an account.&lt;/strong&gt; No email to start, no sign-up wall before the result. Psychology.com asks for an address only if you want an optional report as a PDF; Freudly offers an optional account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;None asks for a photo, a file, the camera or the microphone.&lt;/strong&gt; Worth saying out loud, because plenty of "which one are you" quizzes do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;None is a validated instrument, and each page says so.&lt;/strong&gt; The idea of measuring the seven sins has real research behind it - the Vices and Virtues Scale, published in 2014 - but a four-minute browser quiz is not that scale. A page that lists papers and names a reviewer has done more reading; it is still not a validation study.&lt;/p&gt;

&lt;h2&gt;
  
  
  One "quiz" is no longer a quiz
&lt;/h2&gt;

&lt;p&gt;There was a sixth listing. Its URL still appears in search results under a title promising a free 35-question test, but the page now serves an article about the sins with a single reflection prompt. Nothing is scored. Search titles lag behind pages, and a quiz is an easy thing to quietly replace with an article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why publish the comparison at all
&lt;/h2&gt;

&lt;p&gt;My test was built around three promises - all seven scores, no sign-up, no photo - and a comparison is the honest way to say where that makes it the wrong choice. If you want a label in the fewest steps, Testmoji is shorter. If you want to read about the tradition, IDR Labs goes deeper. If you want the constructs and the papers, Psychology.com lists them.&lt;/p&gt;

&lt;p&gt;I wrote all of that down instead of pretending otherwise. The full &lt;a href="https://deadlysinsquiz.com/compare" rel="noopener noreferrer"&gt;side-by-side comparison of five seven deadly sins tests&lt;/a&gt; has the detailed rows on permissions, cost and validation; the quiz itself is &lt;a href="https://deadlysinsquiz.com/" rel="noopener noreferrer"&gt;Deadly Sins Quiz&lt;/a&gt;, if you want to see all seven of your own scores.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>psychology</category>
      <category>ux</category>
    </item>
    <item>
      <title>Scoring all seven: a personality quiz that refuses to hand you just one label</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Wed, 18 Nov 2026 17:09:53 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/scoring-all-seven-a-personality-quiz-that-refuses-to-hand-you-just-one-label-h0o</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/scoring-all-seven-a-personality-quiz-that-refuses-to-hand-you-just-one-label-h0o</guid>
      <description>&lt;p&gt;Most personality quizzes are built to give you a sticker. You answer some questions, the page dramatic-reveals "You are the Visionary!", and that's the whole product. I kept wondering what would happen if a quiz refused to pick a winner — so I built one around the seven deadly sins, and it shows you all seven scores every time.&lt;/p&gt;

&lt;p&gt;Here's the thinking behind it, plus the history rabbit hole that made the theme fit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The theme is older than any modern personality framework
&lt;/h2&gt;

&lt;p&gt;The seven deadly sins are, in effect, the medieval West's trait model. The interesting part is how messy the path was: the 4th-century monk Evagrius Ponticus started with eight "thoughts", Gregory the Great later merged two and added one, and the modern seven only settled after centuries of edits. I collected the full timeline — including the "eight thoughts before seven sins" detour — on &lt;a href="https://deadlysinsquiz.com/origin" rel="noopener noreferrer"&gt;a page about the list in order and its meanings&lt;/a&gt;. Building a quiz on a framework that is itself a centuries-long revision was oddly reassuring: my own revisions were in good company.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seven axes, no forced winner
&lt;/h2&gt;

&lt;p&gt;The quiz asks 35 original statements — everyday situations, rated 0 to 4, no right answers. Each statement feeds more than one axis, so your pride score and your envy score can rise together, the way they do in real life.&lt;/p&gt;

&lt;p&gt;Two rules mattered more than the scoring itself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Every result shows all seven scores&lt;/strong&gt;, ranked but complete. You see your lowest tendency too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Equal scores stay equal.&lt;/strong&gt; If wrath and sloth tie at the top, the result says they tied. The quiz never invents a winner to make the result page feel more decisive than the data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That second rule sounds trivial and was not. Every dashboard I've ever seen wants to crown something. But the honest version — "your top two are tied" — turned out to be the detail people mention when they share their results.&lt;/p&gt;

&lt;h2&gt;
  
  
  No sign-up, no app, no paywall at the end
&lt;/h2&gt;

&lt;p&gt;One thing that annoys me about "free" quizzes: the free part ends at the paywall. This one is a single static page — works in any modern browser on a phone, no account, no download, nothing to install. You can retake it, and each result gets a shareable link if you want a friend to see your actual seven scores instead of a screenshot of one number.&lt;/p&gt;

&lt;h2&gt;
  
  
  I compared it against the alternatives — and published that too
&lt;/h2&gt;

&lt;p&gt;If you search for seven deadly sins tests you'll find quite a few, so I did the unflattering thing and documented them: what each one asks, how long it takes, whether it shows a full profile, and what's behind a sign-up. The &lt;a href="https://deadlysinsquiz.com/compare" rel="noopener noreferrer"&gt;comparison of seven deadly sins tests&lt;/a&gt; includes mine in the same table as the others, with the criteria written out so you can disagree with my weighting. It's the page I wish existed before I built this.&lt;/p&gt;

&lt;h2&gt;
  
  
  One more thing: most people can't name all seven
&lt;/h2&gt;

&lt;p&gt;For all the Renaissance paintings and meme references, when I ask friends, most get five or six and stall on envy or sloth. If you want to check yourself, &lt;a href="https://deadlysinsquiz.com/trivia" rel="noopener noreferrer"&gt;can you name all 7 deadly sins?&lt;/a&gt; is the two-minute version — it walks through the seven names before you take the full quiz.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The whole thing is free, about 3–5 minutes: &lt;a href="https://deadlysinsquiz.com/" rel="noopener noreferrer"&gt;Seven Deadly Sins Test&lt;/a&gt;. No account, works on your phone, and your result page shows all seven scores whether you share it or not.&lt;/p&gt;

&lt;p&gt;If you've built something similar — or you have opinions about whether quizzes should ever crown a single label — I'd genuinely like to hear how you handled it in the comments.&lt;/p&gt;

</description>
      <category>psychology</category>
      <category>webdev</category>
      <category>history</category>
    </item>
    <item>
      <title>Skip the microphone: turning a script into natural speech in five minutes</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Tue, 17 Nov 2026 04:45:33 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/skip-the-microphone-turning-a-script-into-natural-speech-in-five-minutes-53nj</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/skip-the-microphone-turning-a-script-into-natural-speech-in-five-minutes-53nj</guid>
      <description>&lt;p&gt;For demo videos, prototype narrations, or quick podcast intros, recording your own voice is usually the slowest part of the job. Browser-based text-to-speech has quietly gotten good enough that you can skip the microphone entirely — here's the workflow I use, and the five details that decide whether the result sounds natural or robotic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Keep the loop in the browser&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No installs, no account walls for a first try. I've been using &lt;a href="https://texttospeechlab.com/" rel="noopener noreferrer"&gt;TextToSpeechLab&lt;/a&gt; for this: paste text, pick one of 28 voices across 20 languages, listen immediately, download. You want to iterate on the script, not fight a UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Audition voices before committing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The same script read by two different voices feels like two different products. Two or three audition reads are usually enough to decide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mark up the delivery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pauses fix most "robotic" reads: where a human would breathe, insert a pause. If your tool supports inline speech tags — laughs, whispers, emphasis — use them sparingly. One per paragraph is plenty.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Read the script aloud once yourself&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you stumble over a sentence, the voice will too. Rewrite it shorter instead of fighting it. This is the cheapest quality pass there is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Listen to the export on a phone&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Problems invisible on laptop speakers jump out immediately on phone speakers or in a car.&lt;/p&gt;

&lt;p&gt;Total time for a 60-second script: about five minutes, start to finish, in a single browser tab. If you're wiring TTS into your own stack instead, most of the same rules apply — the delivery markup matters more than the voice list.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Turning a living-room photo into 'security footage' with the browser canvas</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Mon, 16 Nov 2026 19:36:23 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/turning-a-living-room-photo-into-security-footage-with-the-browser-canvas-364b</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/turning-a-living-room-photo-into-security-footage-with-the-browser-canvas-364b</guid>
      <description>&lt;p&gt;Some templates earn their keep in the pre-processing. Our latest one — a "Santa caught on camera" clip — started as a prompt experiment: ask a video model for 1998-CCTV-style footage of Santa mid-delivery in &lt;em&gt;your&lt;/em&gt; living room, and it politely ignores the style instructions. Art direction does not survive prompting; it has to be baked into the input image.&lt;/p&gt;

&lt;h2&gt;
  
  
  The grade happens in the browser
&lt;/h2&gt;

&lt;p&gt;The moment a photo is picked, we run it through a canvas pipeline before anything uploads:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;draw the photo and desaturate it to luminance-only,&lt;/li&gt;
&lt;li&gt;push the contrast up,&lt;/li&gt;
&lt;li&gt;lay down per-pixel noise for the grain,&lt;/li&gt;
&lt;li&gt;burn a soft vignette into the corners.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The graded JPEG — not the original — is what the video model receives. A side effect we like: the thumbnail in the picker is pixel-identical to the model's input, so there is no "why does my clip look like that" mystery later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two prompt lessons we kept
&lt;/h2&gt;

&lt;p&gt;You cannot prompt your way to a style; you can prompt your way to a line of dialogue. Write the line as spoken text and the model voices it — we verified transcriptions of names like "Leo" and "Aaliyah" survive the round trip. Write it as a whispered stage direction and you get no voice at all.&lt;/p&gt;

&lt;p&gt;Because the spoken line contains the child's name, the name gets validated before anything renders: letters, spaces, hyphens, apostrophes, commas, periods and ampersands, up to 30 characters and 4 words. An invalid name greys out the generate button — nobody spends a credit on a clip that cannot say "Merry Christmas, [name]!".&lt;/p&gt;

&lt;h2&gt;
  
  
  The result
&lt;/h2&gt;

&lt;p&gt;One room photo in, a short grainy clip out: Santa in the frame, the line spoken aloud, the whole thing looking like footage from a tape that has been in the attic since the nineties. It lives next to our &lt;a href="https://useairapvideo.com/santa-caught-on-camera" rel="noopener noreferrer"&gt;Santa caught on camera template&lt;/a&gt;, and the classic version — Santa on stage, rapping your message — is at &lt;a href="https://useairapvideo.com/personalized-santa-video" rel="noopener noreferrer"&gt;the personalized Santa video page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Everything audio in our templates is original (we never bundle copyrighted songs), there is a free 6-second preview per account, and a full video is $3.99 one time — no subscription.&lt;/p&gt;

&lt;p&gt;— AI Rap Video team&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The smallest feature we shipped started a war (the friendly kind)</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Fri, 06 Nov 2026 08:56:26 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/the-smallest-feature-we-shipped-started-a-war-the-friendly-kind-2hb8</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/the-smallest-feature-we-shipped-started-a-war-the-friendly-kind-2hb8</guid>
      <description>&lt;p&gt;Every product has one feature that unexpectedly becomes the reason people share it. For our AI rap video tool, it is not the lip-syncing or the stage templates — it is the roast generator, and the one-click handoff that turns a roast into a full diss track video.&lt;/p&gt;

&lt;p&gt;Here is how that handoff works, and what we learned watching people use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The roast generator is the on-ramp
&lt;/h2&gt;

&lt;p&gt;The roast generator is free and deliberately small: type a name (yours, a friend's, a GitHub bio), pick a tone — playful, savage, or rap-battle — and get a short roast written about the target. No account gymnastics, no watermarked teaser. It exists because asking strangers to upload photos and pay $3.99 before they understand the product was too big a first step.&lt;/p&gt;

&lt;p&gt;What surprised us: people did not want to just read the roast. They wanted to escalate it.&lt;/p&gt;

&lt;h2&gt;
  
  
  One click, from text to performed video
&lt;/h2&gt;

&lt;p&gt;So the roast page has a handoff: one button sends the roast text straight into the diss track generator as the lyrical brief. The video side writes the full bars around it, performs them with an AI rap voice over an original beat, and — if a photo is supplied — lip-syncs the target's face to every word. Twelve seconds later, the joke is a produced track.&lt;/p&gt;

&lt;p&gt;The design lesson: the funnel between "free text toy" and "paid video" works because there is exactly one click and zero re-entry. No copy-paste, no form, no re-typing the topic. Every extra field would have lost the people who make it to the video.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two things we keep saying no to
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Real song beats.&lt;/strong&gt; The obvious growth hack is letting videos ride on famous instrumentals. We keep refusing: every beat is composed per video, every lyric is generated, and nothing bundles copyrighted songs. There is a DMCA flow and an upload path for audio users own. It costs us some reach; it buys listings that survive platform moderation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-escalating roasts.&lt;/strong&gt; We do not make the savage mode crueler to drive shares. The roast stays at "friendgroup burn," not harassment. A diss track between friends is a format; a pile-on is not.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try the pair
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://useairapvideo.com/ai-rap-generator/diss-track" rel="noopener noreferrer"&gt;diss track generator&lt;/a&gt; and the free roast generator (&lt;a href="https://useairapvideo.com/ai-roast-generator" rel="noopener noreferrer"&gt;https://useairapvideo.com/ai-roast-generator&lt;/a&gt;) live on the same site, which also covers birthday, Christmas and two-person duo templates. Free 6-second preview per account; full 480p videos are $3.99 one time, no subscription.&lt;/p&gt;

&lt;p&gt;If you build free-to-paid products, the takeaway we would defend: give the toy away completely, then make the upgrade exactly one click.&lt;/p&gt;

&lt;p&gt;— AI Rap Video team&lt;/p&gt;

</description>
      <category>ai</category>
      <category>product</category>
    </item>
    <item>
      <title>What actually happens between “type a topic” and a lip-synced rap video</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Tue, 03 Nov 2026 16:58:36 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/what-actually-happens-between-type-a-topic-and-a-lip-synced-rap-video-22am</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/what-actually-happens-between-type-a-topic-and-a-lip-synced-rap-video-22am</guid>
      <description>&lt;p&gt;When we tell people we built a generator that turns a sentence — or a photo — into a 12-second rap performance, the follow-up question is always the same: "okay, but what is actually happening in there?"&lt;/p&gt;

&lt;p&gt;This post is the honest walkthrough of the pipeline behind AI Rap Video (&lt;a href="https://useairapvideo.com" rel="noopener noreferrer"&gt;https://useairapvideo.com&lt;/a&gt;), step by step, with the failure modes we hit while building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 — Lyrics from a topic
&lt;/h2&gt;

&lt;p&gt;Everything starts with text. The user gives a topic ("my coworker who microwaves fish"), optionally their own lyrics, and picks a stage template. A lyric model turns the topic into structured bars: rhyme pairs, a hook, and a length target that fits the video duration. The template matters here — a diss track needs punchlines, a birthday rap needs the recipient's name in the first two bars, so the prompt carries template constraints, not just the topic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 — A rap voice performs them
&lt;/h2&gt;

&lt;p&gt;The lyrics go to a rap-styled vocal model. This is not text-to-speech with a filter: delivery — where the flow sits relative to the beat, which syllables get stressed — is part of the generation. The same bars performed straight sound like a recital; performed with push-pull against the beat, they sound like a verse.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 — An original beat
&lt;/h2&gt;

&lt;p&gt;The beat is composed per video and matched to the vocal take's tempo. We made one deliberate product decision here: &lt;strong&gt;no copyrighted audio, ever.&lt;/strong&gt; No famous instrumentals, no "sounds like" beats. The audio is original by default, users can upload beats they own the rights to, and there is a DMCA takedown flow. It is more work than bundling known beats, but it is the only version of this product we were willing to ship.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4 — Lip sync from a photo
&lt;/h2&gt;

&lt;p&gt;If the user supplied a photo, a lip-sync model animates the face to the vocal: it extracts mouth-region landmarks, generates a mouth shape sequence aligned to phonemes, and composites it back. Front-facing, well-lit photos sync dramatically better than angled ones — the model needs to see the whole mouth. Two photos? The duo template maps each face to its own vocal part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5 — Render
&lt;/h2&gt;

&lt;p&gt;The vocal, beat, and animated video are composited and rendered as a 12-second MP4 (480p or 720p). Each render consumes credits from a one-time pack — there is no subscription, which users mention unprompted more than we expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch it end to end
&lt;/h2&gt;

&lt;p&gt;There are four full sample videos on the homepage at &lt;a href="https://useairapvideo.com" rel="noopener noreferrer"&gt;https://useairapvideo.com&lt;/a&gt; — diss track, birthday, Santa, and a two-person duo — if you want to see all five steps compressed into a dozen seconds each. The &lt;a href="https://useairapvideo.com/ai-rap-generator" rel="noopener noreferrer"&gt;rap generator&lt;/a&gt; itself runs free 6-second previews, one per account, if you would rather poke at it directly.&lt;/p&gt;

&lt;p&gt;Questions about any of the steps are welcome in the comments — especially on the lip-sync stage, which is where most of our iteration time went.&lt;/p&gt;

&lt;p&gt;— AI Rap Video team&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Grok TTS speech tags, tested: what &lt;loud&gt;, &lt;singing&gt; and [laugh] actually do</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Sun, 01 Nov 2026 03:02:49 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/grok-tts-speech-tags-tested-what-and-laugh-actually-do-1jda</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/grok-tts-speech-tags-tested-what-and-laugh-actually-do-1jda</guid>
      <description>&lt;p&gt;xAI's Grok text to speech API (&lt;code&gt;POST https://api.x.ai/v1/tts&lt;/code&gt;) has 28 built-in voices, 20 languages and a set of speech tags you put straight into the text. The docs list the tags; they don't say how much each one changes. I measured a couple.&lt;/p&gt;

&lt;h2&gt;
  
  
  The request
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.x.ai/v1/tts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Bearer &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;XAI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Stand back. &amp;lt;loud&amp;gt;This is not a drill.&amp;lt;/loud&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;voice_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eve&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output_format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;codec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mp3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;sample_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;bit_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;128000&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mp3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;arrayBuffer&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;language&lt;/code&gt; also takes &lt;code&gt;auto&lt;/code&gt;. Price is $15 per million characters (xAI pricing page, checked 2026-10-30).&lt;/p&gt;

&lt;h2&gt;
  
  
  Two kinds of tags
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inline&lt;/strong&gt; tags insert a sound where they sit: &lt;code&gt;[pause]&lt;/code&gt;, &lt;code&gt;[long-pause]&lt;/code&gt;, &lt;code&gt;[hum-tune]&lt;/code&gt;, &lt;code&gt;[laugh]&lt;/code&gt;, &lt;code&gt;[chuckle]&lt;/code&gt;, &lt;code&gt;[giggle]&lt;/code&gt;, &lt;code&gt;[cry]&lt;/code&gt;, &lt;code&gt;[tsk]&lt;/code&gt;, &lt;code&gt;[tongue-click]&lt;/code&gt;, &lt;code&gt;[lip-smack]&lt;/code&gt;, &lt;code&gt;[breath]&lt;/code&gt;, &lt;code&gt;[inhale]&lt;/code&gt;, &lt;code&gt;[exhale]&lt;/code&gt;, &lt;code&gt;[sigh]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wrapping&lt;/strong&gt; tags change how the enclosed phrase is read: &lt;code&gt;&amp;lt;soft&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;whisper&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;loud&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;build-intensity&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;decrease-intensity&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;higher-pitch&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;lower-pitch&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;slow&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;fast&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;sing-song&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;singing&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;emphasis&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What two of them measured
&lt;/h2&gt;

&lt;p&gt;Same sentence, voice Eve, English, one clip with and one without the tag. One clip each, so this is a quick check rather than a benchmark.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tag&lt;/th&gt;
&lt;th&gt;Length&lt;/th&gt;
&lt;th&gt;Loudness (RMS)&lt;/th&gt;
&lt;th&gt;Median pitch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;none → &lt;code&gt;&amp;lt;loud&amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;5.5 s → 5.5 s&lt;/td&gt;
&lt;td&gt;-20.7 → -20.9 dBFS&lt;/td&gt;
&lt;td&gt;195 → 253 Hz&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;none → &lt;code&gt;&amp;lt;singing&amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;6.5 s → 8.4 s&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;189 → 250 Hz&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So &lt;code&gt;&amp;lt;loud&amp;gt;&lt;/code&gt; is closer to "raised, urgent delivery" than a volume control: if you need a louder file, normalise it afterwards. &lt;code&gt;&amp;lt;singing&amp;gt;&lt;/code&gt; stretches the words into a melody, which also makes the clip longer (and, on a per-character price, not more expensive).&lt;/p&gt;

&lt;h2&gt;
  
  
  Trying tags without writing code
&lt;/h2&gt;

&lt;p&gt;If you want to hear the tags on all 28 voices before wiring up the API, I built a free front-end: &lt;a href="https://groktexttospeech.com/" rel="noopener noreferrer"&gt;Grok Text to Speech&lt;/a&gt;. The &lt;a href="https://groktexttospeech.com/grok-tts-speech-tags/" rel="noopener noreferrer"&gt;speech tag reference&lt;/a&gt; has a before/after sample for each group, and there are preset pages for &lt;a href="https://groktexttospeech.com/whisper-text-to-speech/" rel="noopener noreferrer"&gt;whisper&lt;/a&gt;, &lt;a href="https://groktexttospeech.com/shouting-text-to-speech/" rel="noopener noreferrer"&gt;shouting&lt;/a&gt; and &lt;a href="https://groktexttospeech.com/singing-text-to-speech/" rel="noopener noreferrer"&gt;singing&lt;/a&gt;. It's an independent project, not affiliated with xAI.&lt;/p&gt;

</description>
      <category>tts</category>
      <category>javascript</category>
      <category>ai</category>
      <category>api</category>
    </item>
    <item>
      <title>Restoring Japanese mojibake: brute-forcing encoding pairs with TextDecoder</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Tue, 20 Oct 2026 05:48:57 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/restoring-japanese-mojibake-brute-forcing-encoding-pairs-with-textdecoder-5hih</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/restoring-japanese-mojibake-brute-forcing-encoding-pairs-with-textdecoder-5hih</guid>
      <description>&lt;p&gt;Paste a Japanese email into the wrong decoder and &lt;code&gt;こんにちは&lt;/code&gt; comes back as&lt;br&gt;
&lt;code&gt;縺薙ｓ縺ｫ縺｡縺ｯ&lt;/code&gt;. Save the same word to a file and open it in a Western&lt;br&gt;
editor and you get &lt;code&gt;æ—¥æœ¬èªž&lt;/code&gt;. Annoying? Yes. Hopeless? No — in the&lt;br&gt;
overwhelming majority of cases &lt;strong&gt;the bytes are still there, untouched.&lt;/strong&gt;&lt;br&gt;
Mojibake is a decoding mistake, not corruption, and you can undo it with&lt;br&gt;
nothing but the &lt;code&gt;TextDecoder&lt;/code&gt; that is already built into your browser.&lt;/p&gt;

&lt;p&gt;This post walks through the whole restoration pipeline: the encoding pairs&lt;br&gt;
that actually matter, how to get the bytes back, what to do when&lt;br&gt;
&lt;code&gt;TextEncoder&lt;/code&gt; can't help you, how to rank the candidate readings, and the&lt;br&gt;
two nasty edge cases — the lone &lt;code&gt;縺・&lt;/code&gt; at the end of old emails, and text&lt;br&gt;
that was garbled twice.&lt;/p&gt;
&lt;h2&gt;
  
  
  Bytes in, wrong interpretation out
&lt;/h2&gt;

&lt;p&gt;Every case of classic mojibake follows the same pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Text is &lt;strong&gt;saved&lt;/strong&gt; as encoding A (bytes on disk / bytes in the email).&lt;/li&gt;
&lt;li&gt;Something &lt;strong&gt;reads&lt;/strong&gt; those bytes as encoding B.&lt;/li&gt;
&lt;li&gt;The reader prints whatever characters those bytes mean &lt;em&gt;in B&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Nothing destroyed the bytes. The UTF-8 bytes of &lt;code&gt;こんにちは&lt;/code&gt; are&lt;br&gt;
&lt;code&gt;E3 81 93 E3 82 93 E3 81 AB E3 81 A1 E3 81 AF&lt;/code&gt; — fifteen bytes. Read as&lt;br&gt;
Shift_JIS (1.5 bytes per kana character on average), they turn into eight&lt;br&gt;
different, perfectly valid characters: &lt;code&gt;縺薙ｓ縺ｫ縺｡縺ｯ&lt;/code&gt;. The information&lt;br&gt;
survived; only the interpretation is wrong.&lt;/p&gt;

&lt;p&gt;So restoration is a search problem: &lt;strong&gt;recover the bytes, re-read them with&lt;br&gt;
every plausible charset, and rank the readings by how much they look like&lt;br&gt;
real Japanese.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The nine pairs that matter
&lt;/h2&gt;

&lt;p&gt;Japan has more legacy encodings than anyone would like: UTF-8, Shift_JIS,&lt;br&gt;
EUC-JP, UTF-16 — plus Windows-1252/Latin-1, the fallback every Western&lt;br&gt;
tool reaches for. Going through who-saved-what and who-misread-it, nine&lt;br&gt;
pairings cover practically everything you will meet in the wild:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;saved as&lt;/th&gt;
&lt;th&gt;misread as&lt;/th&gt;
&lt;th&gt;typical scene&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;UTF-8&lt;/td&gt;
&lt;td&gt;Shift_JIS&lt;/td&gt;
&lt;td&gt;Excel or other Windows software opening a UTF-8 CSV&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UTF-8&lt;/td&gt;
&lt;td&gt;Windows-1252&lt;/td&gt;
&lt;td&gt;non-Japanese-aware services and APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UTF-8&lt;/td&gt;
&lt;td&gt;EUC-JP&lt;/td&gt;
&lt;td&gt;old Unix environments, EUC-JP-era web pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shift_JIS&lt;/td&gt;
&lt;td&gt;EUC-JP&lt;/td&gt;
&lt;td&gt;Shift_JIS files rendered on EUC-JP systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EUC-JP&lt;/td&gt;
&lt;td&gt;Shift_JIS&lt;/td&gt;
&lt;td&gt;old EUC-JP mail/pages viewed on Windows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shift_JIS&lt;/td&gt;
&lt;td&gt;Windows-1252&lt;/td&gt;
&lt;td&gt;Western tools opening Shift_JIS files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EUC-JP&lt;/td&gt;
&lt;td&gt;Windows-1252&lt;/td&gt;
&lt;td&gt;same, for EUC-JP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UTF-16LE&lt;/td&gt;
&lt;td&gt;Windows-1252&lt;/td&gt;
&lt;td&gt;UTF-16 files read as 1-byte text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UTF-16BE&lt;/td&gt;
&lt;td&gt;Windows-1252&lt;/td&gt;
&lt;td&gt;same, byte-swapped&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you only ever memorize one row, make it the first one — a UTF-8 CSV&lt;br&gt;
double-clicked open in Excel is probably the single most common way&lt;br&gt;
Japanese text gets mangled on earth.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: getting the bytes back
&lt;/h2&gt;

&lt;p&gt;When the text was misread through a &lt;strong&gt;single-byte&lt;/strong&gt; charset such as&lt;br&gt;
Windows-1252, the original bytes are trivially recoverable — every&lt;br&gt;
character you see &lt;em&gt;is&lt;/em&gt; one original byte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;garbled&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;charCodeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now throw every decoder at it. &lt;code&gt;TextDecoder&lt;/code&gt; accepts all the labels we&lt;br&gt;
need: &lt;code&gt;utf-8&lt;/code&gt;, &lt;code&gt;shift_jis&lt;/code&gt;, &lt;code&gt;euc-jp&lt;/code&gt;, &lt;code&gt;utf-16le&lt;/code&gt;, &lt;code&gt;utf-16be&lt;/code&gt;, and&lt;br&gt;
&lt;code&gt;windows-1252&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shift_jis&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;euc-jp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf-16le&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf-16be&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;windows-1252&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextDecoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// invalid sequences for this encoding&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: the TextEncoder problem
&lt;/h2&gt;

&lt;p&gt;The recipe above works when the &lt;em&gt;reading&lt;/em&gt; was wrong. But in the Japanese&lt;br&gt;
→ Japanese cases (saved as Shift_JIS, misread as EUC-JP — or the&lt;br&gt;
reverse), restoration needs the opposite move: take the characters you&lt;br&gt;
see and &lt;strong&gt;re-encode&lt;/strong&gt; them back through the wrong charset to recover the&lt;br&gt;
bytes.&lt;/p&gt;

&lt;p&gt;And here the platform says no: &lt;code&gt;TextEncoder&lt;/code&gt; only ever produces UTF-8.&lt;br&gt;
There is no &lt;code&gt;new TextEncoder("shift_jis")&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The workaround is to build the reverse mapping yourself. Decode &lt;strong&gt;every&lt;br&gt;
possible byte sequence&lt;/strong&gt; with &lt;code&gt;TextDecoder("shift_jis")&lt;/code&gt; once, and you&lt;br&gt;
have a complete byte → character table for Shift_JIS; invert it and you&lt;br&gt;
can map characters back to bytes. It sounds heavy — a 2-byte code point&lt;br&gt;
has 65,536 combinations — but the table is built lazily and the whole&lt;br&gt;
thing runs in milliseconds. This is also how you recover bytes from&lt;br&gt;
Shift_JIS-style mojibake where several characters were merged, not just&lt;br&gt;
re-mapped one-to-one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: which candidate is right?
&lt;/h2&gt;

&lt;p&gt;Brute force returns many "readable" results. The wrong ones tend to be&lt;br&gt;
assembled from rare characters. &lt;code&gt;縺&lt;/code&gt;, &lt;code&gt;繧&lt;/code&gt;, &lt;code&gt;繝&lt;/code&gt; — the first characters of&lt;br&gt;
classic UTF-8-as-Shift_JIS garbage — are all &lt;strong&gt;JIS level-2 kanji&lt;/strong&gt;,&lt;br&gt;
characters that appear almost never in daily Japanese. The correct&lt;br&gt;
reading, meanwhile, is made of level-1 characters and everyday kana.&lt;/p&gt;

&lt;p&gt;That gives you a cheap, dependency-free ranking function: score each&lt;br&gt;
candidate by how frequently its characters occur in normal Japanese&lt;br&gt;
text, adding weight for common kanji and kana, subtracting for JIS&lt;br&gt;
level-2 rarities. A frequency table built from a modest corpus is&lt;br&gt;
enough; the right reading almost always floats to the top with a visible&lt;br&gt;
margin.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lone 縺・ at the end
&lt;/h2&gt;

&lt;p&gt;Old Japanese mail software truncated messages at fixed &lt;strong&gt;byte&lt;/strong&gt; lengths —&lt;br&gt;
sometimes right in the middle of a multi-byte character. The victim is&lt;br&gt;
always the last character: its leading byte survived, the continuation&lt;br&gt;
bytes were cut. The result ends with something like &lt;code&gt;縺・&lt;/code&gt; and every&lt;br&gt;
decoder refuses it or prints a replacement mark.&lt;/p&gt;

&lt;p&gt;These bytes can be resurrected. A cut multi-byte character leaves a&lt;br&gt;
known fragment; enumerate the byte sequences that would continue it&lt;br&gt;
(there are only a handful of legal continuations), re-decode, and pick&lt;br&gt;
the completion that best fits the surrounding text. It is a guess in&lt;br&gt;
the strict sense — but an extremely well-educated one, and in practice&lt;br&gt;
it reads naturally in the overwhelming number of cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  When text was garbled twice
&lt;/h2&gt;

&lt;p&gt;Copy a mojibake sentence, save it in another tool, misread it again —&lt;br&gt;
now you have &lt;em&gt;double&lt;/em&gt; garbling, where the second wrong decoding was&lt;br&gt;
applied to the output of the first. The fix is what you would expect:&lt;br&gt;
run the whole pair search once, then run it &lt;strong&gt;again on the first&lt;br&gt;
round's output&lt;/strong&gt;. What you would not expect is the cost: the second&lt;br&gt;
pass multiplies the work ninefold, so a sane implementation runs it&lt;br&gt;
only on short texts — pasted sentences, never whole files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it together
&lt;/h2&gt;

&lt;p&gt;The nine pairs, the byte-recovery tricks, naturalness ranking, the&lt;br&gt;
trailing-character inference and the second pass all run in one page at&lt;br&gt;
&lt;a href="https://henkanya.com/" rel="noopener noreferrer"&gt;henkanya.com&lt;/a&gt; — free, no sign-up, and entirely&lt;br&gt;
in your browser: the text you paste never leaves your machine. It also&lt;br&gt;
handles the encodings that don't fit the brute-force model&lt;br&gt;
(&lt;code&gt;=?ISO-2022-JP?B?…?=&lt;/code&gt; mail headers, old JIS mail with lost ESC&lt;br&gt;
sequences, Unicode escapes, HTML numeric references) and converts CSV&lt;br&gt;
or text files to UTF-8 with BOM so that Excel opens them without&lt;br&gt;
decorating your data with mojibake of its own.&lt;/p&gt;

&lt;p&gt;If you want to see the pipeline fail — or better, save your afternoon —&lt;br&gt;
paste your favorite garbage string and check whether the top candidate&lt;br&gt;
is the sentence you remember.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>unicode</category>
      <category>i18n</category>
    </item>
    <item>
      <title>How I Keep a Fan Guide in Sync With a Viral Browser Game Using a GitHub Actions Cron</title>
      <dc:creator>ZHIWEI</dc:creator>
      <pubDate>Tue, 13 Oct 2026 05:54:04 +0000</pubDate>
      <link>https://dev.to/zhiwei_224e5e15600342dc0b/how-i-keep-a-fan-guide-in-sync-with-a-viral-browser-game-using-a-github-actions-cron-4ggd</link>
      <guid>https://dev.to/zhiwei_224e5e15600342dc0b/how-i-keep-a-fan-guide-in-sync-with-a-viral-browser-game-using-a-github-actions-cron-4ggd</guid>
      <description>&lt;p&gt;A Nigerian browser game called &lt;strong&gt;Lagos Life&lt;/strong&gt; launched at the start of October 2026 and went viral fast. I run an independent fan guide for it, and within a few days I hit the problem every guide writer for a live game hits: &lt;strong&gt;the game changes faster than I can edit pages.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Players elect a governor who sets a law that changes the economy. There's a new in-game headline every day, a daily gem hunt with a fresh clue, and the developers tweak job and business tables without notice. A hand-maintained page is stale within days.&lt;/p&gt;

&lt;p&gt;So I stopped editing by hand. This post walks through the small pipeline that now does it for me: a GitHub Actions cron that reads what the official site already serves to every visitor, writes a few JSON files, and rebuilds a static site only when something actually changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The guide is a &lt;strong&gt;prerendered static site&lt;/strong&gt; (TanStack Start) on &lt;strong&gt;Cloudflare Pages&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pages read their data from JSON files committed in the repo (&lt;code&gt;live-log.json&lt;/code&gt;, &lt;code&gt;jobs.json&lt;/code&gt;, …) at build time.&lt;/li&gt;
&lt;li&gt;One workflow runs &lt;strong&gt;every 3 hours&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch scripts ──▶ anything changed? ──no──▶ stop
                        │ yes
                        ▼
                 build ▶ deploy ▶ ping IndexNow ▶ commit the JSON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;17&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*/3&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*'&lt;/span&gt;   &lt;span class="c1"&gt;# minute 17, not 0: avoid the top-of-hour rush&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;concurrency&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;live-log&lt;/span&gt;
  &lt;span class="na"&gt;cancel-in-progress&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;  &lt;span class="c1"&gt;# never kill a run halfway through a deploy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Source 1: the public JSON the site already serves
&lt;/h2&gt;

&lt;p&gt;The official site calls a few JSON endpoints for logged-out visitors: the current governor and law, the daily headline, and the gem hunt. Reading those is the easy part — a plain &lt;code&gt;fetch&lt;/code&gt; with a timeout, a couple of retries, and a User-Agent that says who I am and where the data ends up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-guide live log (+https://example.com/updates/)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User-Agent&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`HTTP &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two decisions mattered more than the code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Store only what the page shows.&lt;/strong&gt; The governor endpoint also returns election candidates and player-written announcements. I never write those to disk. The log keeps the law id, when it was set, the daily date/weather/headline/tip, and the hunt's clue — nothing else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Append, don't overwrite.&lt;/strong&gt; A new law creates a new entry with a &lt;code&gt;firstSeen&lt;/code&gt; timestamp, so the page becomes a dated history instead of a snapshot. If only the term-end time moves, the last entry is updated in place.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The optional endpoint (the gem hunt) is wrapped in its own &lt;code&gt;catch&lt;/code&gt;, so if it breaks, the law and headline log still runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source 2: when there is no API — read the bundle
&lt;/h2&gt;

&lt;p&gt;Job tables and pay rules aren't exposed as JSON; they live in the game's client JavaScript. The game is a Next.js app, so the homepage HTML references chunks under &lt;code&gt;/_next/static/chunks/&lt;/code&gt;, and chunks reference more chunks.&lt;/p&gt;

&lt;p&gt;The script does a small breadth-first crawl: start from the chunk names in the homepage, fetch six at a time, queue any new chunk names found inside, and stop as soon as every value it needs has been found (hard cap: 400 chunks).&lt;/p&gt;

&lt;p&gt;Each value has its own &lt;strong&gt;finder&lt;/strong&gt;, a function that returns &lt;code&gt;null&lt;/code&gt; until it sees its pattern in some chunk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FINDERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;careers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;"CAREERS",0,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;starBonus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/"STAR_BONUS",0,&lt;/span&gt;&lt;span class="se"&gt;([\d&lt;/span&gt;&lt;span class="sr"&gt;.&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ...one finder per rule constant&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Minified variable names change on every build, so the patterns anchor on things that survive minification — &lt;strong&gt;string literals and object shapes&lt;/strong&gt; like &lt;code&gt;{id:"…",name:"…",levels:[{title:"…",pay:…}]}&lt;/code&gt; — never on short identifiers like &lt;code&gt;e&lt;/code&gt; or &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guard rails: fail loudly, keep the last good data
&lt;/h2&gt;

&lt;p&gt;A regex scraper against minified code &lt;em&gt;will&lt;/em&gt; break one day. The goal is that when it breaks, the site stays correct and I get told.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Validate before writing.&lt;/strong&gt; If fewer than 30 careers parse, or any career doesn't have five paid levels, or a workplace has no name, the script writes nothing and exits 1.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolate failures.&lt;/strong&gt; Each fetch script is its own workflow step with &lt;code&gt;continue-on-error: true&lt;/code&gt;, so a broken job-table parser never blocks the law log.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two dates, not one.&lt;/strong&gt; &lt;code&gt;checkedAt&lt;/code&gt; moves on every good read; &lt;code&gt;changedAt&lt;/code&gt; moves only when the table actually differs. The page shows both, so readers can tell "verified today" from "changed today".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be polite.&lt;/strong&gt; The bundle crawl runs at most once per Lagos day (WAT, UTC+1). If today's check already happened, it makes zero requests.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;WAT_MS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;WAT_MS&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;checkedAt&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// already checked today&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Commit only after a successful deploy
&lt;/h2&gt;

&lt;p&gt;This one took me a while to get right. If the workflow committed the new JSON &lt;em&gt;before&lt;/em&gt; deploying and the deploy then failed, the next run would see "no change" and the live site would stay stale forever.&lt;/p&gt;

&lt;p&gt;So the order is: &lt;strong&gt;fetch → build → deploy → commit&lt;/strong&gt;. The data file only lands in git once the site that shows it is live. A failed run leaves git untouched, and the next run three hours later simply tries again.&lt;/p&gt;

&lt;p&gt;The build step also greps the generated &lt;code&gt;sitemap.xml&lt;/code&gt; for the expected URLs before deploying — a cheap check that catches a build that "succeeded" but produced the wrong site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tell search engines only about pages that changed
&lt;/h2&gt;

&lt;p&gt;After a deploy, the workflow pings &lt;strong&gt;IndexNow&lt;/strong&gt; — but only for the pages whose content changed. A new check date alone rebuilds the jobs page without a ping; a new law pings only the updates page. Pinging unchanged URLs every three hours would just be noise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$LIVE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nv"&gt;paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/updates/"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$JOBS_TABLE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; changed &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nv"&gt;paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;paths&lt;/span&gt;:+&lt;span class="nv"&gt;$paths&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/jobs/"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What it produces
&lt;/h2&gt;

&lt;p&gt;Since 8 October the log has been filling itself: each law with the date it was first seen, every daily headline, every gem-hunt clue (clues only — no answers). That's the updates page of the guide:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;→ &lt;a href="https://lagoslifegames.com/updates/" rel="noopener noreferrer"&gt;Lagos Life Updates: This Week's Law, Governor &amp;amp; Gem Hunt&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The game itself is at &lt;a href="https://lagoslife.app/" rel="noopener noreferrer"&gt;lagoslife.app&lt;/a&gt;; my site is an independent fan guide, not affiliated with the developers, and everything it reads is what the official site already serves to any visitor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;For a fast-changing live game, a &lt;strong&gt;3-hourly cron + static rebuild&lt;/strong&gt; is plenty — no server, no database.&lt;/li&gt;
&lt;li&gt;Anchor bundle-scraping patterns on &lt;strong&gt;string literals and shapes&lt;/strong&gt;, and validate hard before writing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commit after deploy&lt;/strong&gt;, so a failed run is automatically retried.&lt;/li&gt;
&lt;li&gt;Store the &lt;strong&gt;minimum&lt;/strong&gt; — especially anything player-written or personal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've built something similar for another live game, I'd love to hear how you handle the parser breaking.&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
