• by Rendello on 11/25/2021, 1:29:33 AM

    For anyone looking to write their own Deflate/Gzip/Zlib, I would recommend looking at the little program called `infgen`:

    > infgen is a deflate stream disassembler. It will read a gzip, zlib, or raw deflate stream, and output a readable description of the contents.

    https://github.com/madler/infgen

  • by userbinator on 11/25/2021, 5:14:32 AM

    One of the mantras I used when I was a programming instructor was "How can you know what to tell the computer to do, if you can't do it yourself?" This is a great example of that.

    Don’t forget that the huffman codes are packed LSB to MSB, but are to be interpreted as an integer in big endian format. Why this insanity?

    Because that's what Phil Katz did. I vaguely remember reading about that years ago, and believe it had to do with how he implemented it; not as canonical table lookup, but as explicit tree-walking, since the former hadn't really been invented yet and the latter would fit within the memory constraints of a 16-bit system (DOS on a PC).

  • by bloak on 11/25/2021, 10:49:33 AM

    And here's a gzip quine for anyone who likes that sort of thing:

      ( echo H4sIAAAAAAAAA5Pv5mCIeLzKnIGZgYHh/38GEYbX/+WxiDl1 ;
        echo KB5hIIJ1TXfrBNeU3DznNGYG78SS1AKgEchsAEthdGVwAAAA ) |
      base64 -d | gunzip > quine.gz
      zcat quine.gz | diff - quine.gz

  • by ryan-duve on 11/25/2021, 12:28:16 AM

    This was a great read. I look forward to the Part II teased at the end. In addition to deep diving on the Huffman codes, I hope you find a way to include an explanation of when to read left-to-right vs right-to-left, which is what tripped me up the most in this article.

  • by oldpatricka on 11/25/2021, 5:47:02 AM

    I love this! Great post.