summaryrefslogtreecommitdiffstats
path: root/_site/log
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-12-24 19:21:25 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-12-25 17:25:16 +0800
commit51f8430027ceaf7590d826221230cbe2fc1af2ec (patch)
treee0940b013f8edebbdf70c04f0bd1c722e9ed5f56 /_site/log
parentabf2ae336b780ac206e3f5d55b608703c9d807d5 (diff)
downloadwww-51f8430027ceaf7590d826221230cbe2fc1af2ec.tar.gz
Change to log/journal style.
Diffstat (limited to '_site/log')
-rw-r--r--_site/log/index.html4
-rw-r--r--_site/log/matrix-digital-rain/index.html162
-rw-r--r--_site/log/matrix-digital-rain/katakana.pngbin133709 -> 0 bytes
-rw-r--r--_site/log/matrix-digital-rain/source.tar.gzbin3602 -> 0 bytes
-rw-r--r--_site/log/suckless-software/index.html124
5 files changed, 79 insertions, 211 deletions
diff --git a/_site/log/index.html b/_site/log/index.html
index 4296fb7..c3c652a 100644
--- a/_site/log/index.html
+++ b/_site/log/index.html
@@ -46,7 +46,7 @@
<tr>
<td class="posts-td posts-td-link">
- <a href="/log/matrix-digital-rain/" class="link-decor-none">Recreating the Matrix rain with ANSI escape sequences</a>
+ <a href="/log/matrix-digital-rain/" class="link-decor-none">Matrix Rain: 2025 refactor</a>
</td>
<td class="posts-td posts-td-time">
<span class="post-meta">
@@ -59,7 +59,7 @@
<tr>
<td class="posts-td posts-td-link">
- <a href="/log/suckless-software/" class="link-decor-none">How to manage Suckless software installations</a>
+ <a href="/log/suckless-software/" class="link-decor-none">Suckless upgrade workflow</a>
</td>
<td class="posts-td posts-td-time">
<span class="post-meta">
diff --git a/_site/log/matrix-digital-rain/index.html b/_site/log/matrix-digital-rain/index.html
index 659922d..f47ac5e 100644
--- a/_site/log/matrix-digital-rain/index.html
+++ b/_site/log/matrix-digital-rain/index.html
@@ -2,12 +2,12 @@
<html>
<head>
<meta charset="utf-8">
- <title>Recreating the Matrix rain with ANSI escape sequences</title>
+ <title>Matrix Rain: 2025 refactor</title>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Recreating the Matrix rain with ANSI escape sequences</title>
+ <title>Matrix Rain: 2025 refactor</title>
<link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/skeleton.css">
</head>
@@ -41,141 +41,45 @@
<main>
<div class="container">
<div class="container-2">
- <h2 class="center" id="title">RECREATING THE MATRIX RAIN WITH ANSI ESCAPE SEQUENCES</h2>
+ <h2 class="center" id="title">MATRIX RAIN: 2025 REFACTOR</h2>
<h6 class="center">21 DECEMBER 2025</h5>
<br>
- <div class="twocol justify"><p>My 2022 implementation of the Matrix rain had too many loose ends. Unicode
-support was inflexible: the character set had to be a single contiguous block
-with no way to mix ASCII with something like Katakana; Phosphor decay level was
-stored in a dedicated array–still don’t understand why I did that when I had
-already used bit-packing for the RGB channels; The algorithm was difficult to
-decipher. The 2022 version worked, but that’s not the same thing as correct.</p>
-
-<p>I began by placing the decay factor in the LSB of the 4-byte RGB value. The PD
-value plays a somewhat analogous role to an alpha channel in that both
-influence transparency. However, they work very differently. So, I avoided
-labelling it A so as not to cause confusion:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>enum {
- R, /* Red */
- G, /* Green */
- B, /* Blue */
- PD /* Phosphor decay level */
-};
-
-typedef union color_tag {
- uint32_t value;
- unsigned char color[4];
-} color;
-</code></pre></div></div>
-
-<p>The decision to use union over more portable bit twiddling was made three years
-ago, as I recall, for readability. Seeing as all my systems are little-endian,
-this is unlikely to cause any trouble. Besides, if union is never to be used,
-why is it in the language anyway?</p>
-
-<p>The blend() function, which emulates the dim afterglow of Phosphor by eroding
-the RGB channels towards the background, with minor refactoring, remains as
-elegant as it did three years ago:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#define DECAY_MPLIER 2
-
-static inline void blend(matrix *mat,
- size_t row, size_t col)
-{
- unsigned char *color;
-
- color = mat-&gt;rgb[index(mat, row, col)].color;
- color[R] = color[R] - (color[R] - RGB_BG_RED) / DECAY_MPLIER;
- color[G] = color[G] - (color[G] - RGB_BG_GRN) / DECAY_MPLIER;
- color[B] = color[B] - (color[B] - RGB_BG_BLU) / DECAY_MPLIER;
-}
-</code></pre></div></div>
-
-<p>While the memory inefficiency of Phosphor decay was a technical oversight I
-hadn’t noticed, the limitation around mixing nonadjacent Unicode blocks was a
-nagging concern even three years ago. So, a fix was long overdue.</p>
-
-<p>In the new version, I introduced an array that enables a user to add as
-many Unicode blocks as they want. The insert_code() function picks a block
-from it at random, and then picks a character from that block at random:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#define UNICODE(min, max) (((uint64_t)max &lt;&lt; 32) | min)
-
-static uint64_t glyphs[] = {
- UNICODE(0x0021, 0x007E), /* ASCII */
- UNICODE(0xFF65, 0xFF9F), /* Half-width Katakana */
-};
-
-static uint8_t glyphlen = (sizeof glyphs) / (sizeof glyphs[0]);
-
-static inline void insert_code(matrix *mat,
- size_t row, size_t col)
-{
- uint64_t block;
- uint32_t unicode_min, unicode_max;
-
- block = glyphs[(rand() % glyphlen)];
- unicode_min = (uint32_t)block;
- unicode_max = (uint32_t)(block &gt;&gt; 32);
-
- mat-&gt;code[index(mat, row, col)] = rand()
- % (unicode_max - unicode_min)
- + unicode_min;
-}
-</code></pre></div></div>
-
-<p>The Unicode blocks are stored in 8-byte containers: the low four bytes form the
-first codepoint and the high four bytes the last. Here, I chose bitwise
-operations over unions because, first and foremost, the operations themselves
-are trivial and idiomatic, and the UNICODE() macro simplifies the management of
-charsets.</p>
-
-<p>The init_term() function is the arbiter of this zero-dependency software. It
-prepares the graphical environment so that I can interact with it via ANSI
-escape codes instead of unnecessary layers of abstraction:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>static inline int init_term(const struct winsize *ws)
-{
- struct termios ta;
-
- if (tcgetattr(STDIN_FILENO, &amp;ta) == 0) {
- ta.c_lflag &amp;= ~ECHO;
- if (tcsetattr(STDIN_FILENO, TCSANOW, &amp;ta) == 0) {
- wprintf(L"\x1b[48;2;%d;%d;%dm",
- RGB_BG_RED, RGB_BG_GRN, RGB_BG_BLU);
- wprintf(L"%s", ANSI_FONT_BOLD);
- wprintf(L"%s", ANSI_CRSR_HIDE);
- wprintf(L"%s", ANSI_CRSR_RESET);
- wprintf(L"%s", ANSI_SCRN_CLEAR);
- setvbuf(stdout, 0, _IOFBF, 0);
- ioctl(STDOUT_FILENO, TIOCGWINSZ, ws);
- return 1;
- }
- }
- return 0;
-}
-</code></pre></div></div>
-
-<p>insert_code() seeds the Matrix, blend() creates the old monochrome CRT display
-nostalgia, and ANSI control sequences paint the screen. The result is a digital
-rain that captures the original Matrix aesthetic with high visual fidelity:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cc -O3 main.c -o matrix
-$ ./matrix
-</code></pre></div></div>
+ <div class="twocol justify"><p>Fixed the Unicode issue finally. Can now mix ASCII + Katakana.</p>
+
+<p>Took me 2 hours to decipher how this even works. For future me: mat.col[]
+stores shuffled column indices, mat.row[] tracks last updated row per column.
+shuffle() randomizes the working set, index i (line 333) and lines 364-370 draw
+one column at a time, swap() rotates columns in and out. That’s the rain.</p>
+
+<p>Moved Phosphor decay level into the LSB of the RGB union - should’ve done this
+in 2022 instead of separate array. WTF was I thinking?</p>
+
+<p>Keeping the RGB/PD union as it is. I know the ‘portability’ nerds hate it, but
+I’m on a little-endian machine, and I’m the only one reading this. It’s
+cleaner.</p>
+
+<p>New charset array works. UNICODE(min, max) macro packs the range into uint64.
+insert_code() picks random block, unpacks it, and picks random char. Elegant.</p>
+
+<p>Looks a lot like the original now:</p>
<video style="max-width:100%;" controls="" poster="poster.png">
<source src="matrix.mp4" type="video/mp4" />
</video>
-<p>There was no cause to measure the program’s performance characteristics
-precisely; it’s gentle on the CPU. On my ThinkPad T490 running OpenBSD, which
-has a resolution of 1920x1080, it uses about 2-3% of the CPU, with occasional
-jumps of up to about 8%; the cores remain silent, the fans don’t whir, the rain
-falls in quiet.</p>
+<p>Using half-width Katakana (U+FF61-U+FF9F) because full-width characters break
+columns.</p>
+
+<p>blend() is still good, left it alone.</p>
+
+<p>Tossed the license and automake cruft. Just <code class="language-plaintext highlighter-rouge">cc -O3 main.c -o matrix</code>. Don’t
+need the ceremony.</p>
+
+<p>Performance regressions: none. Runs like a charm on the T490. 2% CPU. No
+whirring fans.</p>
-<p>Files: <a href="source.tar.gz">source.tar.gz</a></p>
+<p>Commit:
+<a href="https://git.asciimx.com/matrix-digital-rain/commit/?id=03f8d87ba7c2e46bd3f3cc4c772fb3a2ac740c92">03f8d87</a></p>
</div>
<p class="post-author right">by W. D. Sadeep Madurange</p>
diff --git a/_site/log/matrix-digital-rain/katakana.png b/_site/log/matrix-digital-rain/katakana.png
deleted file mode 100644
index b9df873..0000000
--- a/_site/log/matrix-digital-rain/katakana.png
+++ /dev/null
Binary files differ
diff --git a/_site/log/matrix-digital-rain/source.tar.gz b/_site/log/matrix-digital-rain/source.tar.gz
deleted file mode 100644
index 5a69236..0000000
--- a/_site/log/matrix-digital-rain/source.tar.gz
+++ /dev/null
Binary files differ
diff --git a/_site/log/suckless-software/index.html b/_site/log/suckless-software/index.html
index f9e10e4..48ddee1 100644
--- a/_site/log/suckless-software/index.html
+++ b/_site/log/suckless-software/index.html
@@ -2,12 +2,12 @@
<html>
<head>
<meta charset="utf-8">
- <title>How to manage Suckless software installations</title>
+ <title>Suckless upgrade workflow</title>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>How to manage Suckless software installations</title>
+ <title>Suckless upgrade workflow</title>
<link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/skeleton.css">
</head>
@@ -41,86 +41,50 @@
<main>
<div class="container">
<div class="container-2">
- <h2 class="center" id="title">HOW TO MANAGE SUCKLESS SOFTWARE INSTALLATIONS</h2>
+ <h2 class="center" id="title">SUCKLESS UPGRADE WORKFLOW</h2>
<h6 class="center">30 NOVEMBER 2025</h5>
<br>
- <div class="twocol justify"><p>Since <a href="https://suckless.org/" class="external" target="_blank" rel="noopener noreferrer">suckless</a> software requires users to modify the
-source code and recompile to customize, I need a way to maintain patches over
-the long term while retaining the ability to upgrade the software as new
-versions are released.</p>
-
-<h2 id="initial-setup">Initial setup</h2>
-
-<p>When using a suckless program, I usually begin by cloning the project and
-setting the remote push URL to my own git repository:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone git://git.suckless.org/dwm
-git reset --hard &lt;tag&gt;
-git remote set-url --push origin git@git.asciimx.com:/repos/dwm
-</code></pre></div></div>
-
-<p>This way, I can pull updates from the upstream project whenever I want, while
-committing my changes to my git repository. The git reset command aligns my
-branch head with a stable release before applying patches or installing the
-software.</p>
-
-<p>If all I want to do is reconfigure the software (e.g., change key bindings),
-which is what I need most of the time, the recommended approach is to modify
-the config.h file. If the config.h isn’t yet in the project, the
-<code class="language-plaintext highlighter-rouge">make clean &lt;target&gt;</code> command will generate it from the defaults and compile
-the software. The <code class="language-plaintext highlighter-rouge">&lt;target&gt;</code> is the name of the application (e.g., dwm) found
-in the Makefile. I modify the resulting config.h file and run <code class="language-plaintext highlighter-rouge">make clean
-install</code> to install the software before committing and pushing my changes to
-the git repo.</p>
-
-<h2 id="dwm-and-slstatus">dwm and slstatus</h2>
-
-<p>Since dwm and slstatus are always running, <code class="language-plaintext highlighter-rouge">make install</code> will likely fail for
-them. The operating system may prevent the installer from replacing running
-executables with new ones. Hence, we must first stop the running instances of
-these programs (in my case, using Mod + Shift + q). Then, switch to a tty
-(Ctrl + Alt + F1), log in, and change the directory to where dwm/slstatus is.
-We can run <code class="language-plaintext highlighter-rouge">make install</code> to install the software and switch back to the
-graphical session (Ctrl + Alt + F5).</p>
-
-<p>The key combinations for switching to the tty and back may differ across
-systems. The ones listed above are for OpenBSD.</p>
-
-<h2 id="subsequent-upgrades">Subsequent upgrades</h2>
-
-<p>When suckless releases a new version, I run <code class="language-plaintext highlighter-rouge">git pull --rebase</code> to fetch the
-upstream changes and rebase my patches on top of them. Because I tend to use
-stable versions, I perform another interactive rebase to drop the commits
-between the latest stable version tag and my patch before installing the
-software.</p>
-
-<p>Commit log before upgrading:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dt236 My patch.
-3fkdf Version 6.5.
-</code></pre></div></div>
-
-<p>Commit log after pulling:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>w467d My patch.
-gh25g A commit.
-g525g Another commit.
-3fkdf Version 6.6.
-vd425 Old commit.
-q12vu Another old commit.
-3fkdf Version 6.5.
-</code></pre></div></div>
-
-<p>Commit log after the interactive rebase:</p>
-
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>h57jh My patch.
-3fkdf Version 6.6.
-vd425 Old commit.
-q12vu Another old commit.
-3fkdf Version 6.5.
-</code></pre></div></div>
-
-<p>And finally, I commit and push all the changes to my git repository.</p>
+ <div class="twocol justify"><p>Workflow for managing suckless patches across upgrades:</p>
+
+<p>Initial setup:</p>
+<ul>
+ <li>Clone from suckless</li>
+ <li>Reset to stable tag</li>
+ <li>Set push URL to my repo (git.asciimx.com)</li>
+ <li>Pull from upstream, push to mine</li>
+</ul>
+
+<p>Config changes only:</p>
+<ul>
+ <li>Edit config.h (or let make generate it)</li>
+ <li>make clean install</li>
+ <li>Commit, push</li>
+</ul>
+
+<p>dwm/slstatus installs:</p>
+<ul>
+ <li>Can’t replace running binaries</li>
+ <li>Kill dwm (Mod+Shift+q)</li>
+ <li>Switch to tty (Ctrl+Alt+F1 on OpenBSD)</li>
+ <li>make install</li>
+ <li>Back to X (Ctrl+Alt+F5)</li>
+</ul>
+
+<p>Upgrades:</p>
+<ul>
+ <li>git pull –rebase</li>
+ <li>git rebase -i to drop commits between my patch and new stable</li>
+ <li>Keep only: my patches + new stable tag + old history</li>
+ <li>Install, commit, push</li>
+</ul>
+
+<p>Example:</p>
+
+<p>Before: [my patch] -&gt; [6.5] <br />
+After pull: [my patch] -&gt; [random commits] -&gt; [6.6] -&gt; [old stuff] -&gt; [6.5] <br />
+After rebase: [my patch] -&gt; [6.6] -&gt; [old stuff] -&gt; [6.5]</p>
+
+<p>Note: This keeps patch history clean while staying current.</p>
</div>
<p class="post-author right">by W. D. Sadeep Madurange</p>