← Mon, Nov 9 digest

The Qlobe: Rotating Quine (2010)

read article ↗ hn thread ↗

Yusuke Endoh created a Ruby quine that renders an ASCII globe rotating 45 degrees each time it is executed.

read it Examining the clever source code provides a fascinating look into creative programming and data encoding.

summary

Yusuke Endoh designed a Ruby quine that outputs its own modified source code while simultaneously rendering an ASCII-art globe that rotates 45 degrees with each execution. The program packs compressed bitmap data inside strings and decodes it to calculate a 3D projection based on the rotation state. Running the script eight successive times completes a full 360-degree rotation back to the start.

key points

  1. The program is a fully functional quine that changes its internal state and output on every run.
  2. It uses zlib and string manipulation to unpack and render a 3D ASCII projection of a globe.
  3. Passing a custom integer command-line argument allows changing the rotation step size.

who should read it

Ruby developers and creative coders interested in quines and esoteric programming techniques.

discussion warm

consensus

Commenters express deep fascination with the complexity of the rotating quine and note that it still executes successfully on modern Ruby versions.

best comment by omoikane ↗

> even if it doesn't work in modern ruby

Seems to work just fine with ruby 4.0.7

> Please read the source code :-)

- %q quotes a string literal, so if you extract all the characters between the two '~' and put that in another ruby file, you can get syntax highlighting for most of the code.

- Lines 1..10 contains encoded data (quoted inside %!!).

- Lines 10..13 cleans up the data before passing it to zlib to decompress.

- Lines 14..17 decodes the data.

- Rest of the lines draws the globe.

Provides a helpful breakdown of the code structure, explaining how it handles data compression, string parsing, and rendering.

Generated by an LLM from the article and thread. Check the sources before relying on it.