blog.8-p.info

Due to random debugging at work, I have read RFC 1952, aka GZIP file format specification version 4.3.

I thought GZIP was just a compression-only file format. It would be some magic bytes + a compressed byte stream. But it is not.

First, it could have the original file name, and macOS’s gzip (Apple gzip 287.100.2) by default includes that.

% touch hello
% gzip hello
% hexdump -C hello.gz
00000000  1f 8b 08 08 36 bc c9 5f  00 03 68 65 6c 6c 6f 00  |....6.._..hello.|
00000010  03 00 00 00 00 00 00 00  00 00                    |..........|
0000001a
%

Second, it has one byte for OS. Note that the gzip file above claims “Unix”, even my OS is macOS. Well, macOS is one of the UNIX certified products

         OS (Operating System)
            This identifies the type of file system on which compression
            took place.  This may be useful in determining end-of-line
            convention for text files.  The currently defined values are
            as follows:
                 0 - FAT filesystem (MS-DOS, OS/2, NT/Win32)
                 1 - Amiga
                 2 - VMS (or OpenVMS)
                 3 - Unix
                 4 - VM/CMS
                 5 - Atari TOS
                 6 - HPFS filesystem (OS/2, NT)
                 7 - Macintosh
                 8 - Z-System
                 9 - CP/M
                10 - TOPS-20
                11 - NTFS filesystem (NT)
                12 - QDOS
                13 - Acorn RISCOS
               255 - unknown

Not all GZIP implementations honor the OS byte. For example, Go’s compress/gzip always uses 255.

M5Stack

Nov 25, 2020

M5Stack is a series of ESP32-based development kits. ESP32 is a cheap SoC microcontroller, similar to Arduino. The CPU architecture is Xtensa, which hasn’t been supported by LLVM upstream yet.

One of the biggest benefits of ESP32 is that it supports Wi-Fi. There are a lot of interesting development kits from micro:bit to PyBadge, but supporting Wi-FI is exceptional. In fact, other kits in similar size often use ESP32 as a way to connect the internet.

Compared to other ESP32-based development kits, M5Stack series is enclosed in a small plastic case, which would be good for making small toys for kids.

I bought few in this Black Friday. They may be coming from China and would take weeks.

Update 2020-12-11

I have placed the order in November 24th and received the package today. So it took 17 days.

My kid always asks me to fix toys. The 99% of “fix” is just swapping AA/AAA batteries, but the 1% needs some soldering.

Last weekend, I have fixed one electronic pen. My kid broke that slightly. My wife got another broken one from her friend. And I combined them to make a working one!

Repairing things is something I’d like to teach my kids, including basic soldering. That makes me wondering my computer choice. I like Apple products, but they are not designed for repairing or even opening inside. Apple laptops have been having RAM that is soldered. The latest M1 MacBook is going further by putting memory on the SoC. iPhone 12 needs Apple’s proprietary, cloud-linked System Configuration app to fully repair cameras and screens.

There are benefits of doing that. I don’t think Apple is a pure-evil. But I’m unsure that I can agree with their trade-offs. Thinner, faster laptops without repairability! Is that something what I wanted?

There is a Rust channel in Amazon and I’ve learned about aHash recently.

aHash implements a hash function based on AES (Advanced Encryption Standard). Since modern x86 CPUs have specialized instructions for processing AES, called AES-NI, aHash is faster than other hashing algorithms.

Hashbrown, Rust’s standard HashMap implementation has been using aHash as its default since v0.5.1.

However, note that Rust’s standard HashMap is using SipHash as its hashing function.

This is the 70th post of my #100DaysToOffload challenge. Now I can see the goal!

The last 10 posts were mostly tech-focused. While I’ve watched the presidential election in the States, I didn’t write about it. I don’t want to write about it.

Not talking about politics could be a privilege. I can agree that tech is and always will be political.

But I don’t want to talk about politics here, at this time.