December 14, 2022

Named let in Clojure

As you might (or might not) know, Clojure does not have support for named let expressions. Those who used (or still using) Scheme knows that named let is a cool construct to express recursion cleanly, and to be precise, the only way to do iteration in Scheme.

So, how are they used in Scheme? Here is one example you can test in Racket or Guile:

(define lst '(1 2 3 4 5))

(let loop ((lst lst))
  (when (not (null? lst))
    (display (car lst))
    (newline)
    (loop (cdr lst))))
Continue reading →

December 1, 2022

Faster man pages rendering

If you try to open rclone or gcc man pages with Emacs, you'd be surprised how unpleasant that experience can be. Those pages are over 30K lines and Emacs will became unresponsive easily. For how long will depend on your CPU.

To speed up things, setting Man-fontify-manpage-flag to nil can alleviate this problem - it will disable highlighting of a man page and buffer can be somehow usable. Surprisingly, running woman, an alternative man pager written in elisp, will render the rclone man page faster, but it will leave a lot of garbage around.

The fastest option for me was running a shell command man <page> | col -b and reading that output directly as plain text in the Emacs buffer.

Continue reading →

January 12, 2021

Edit files in (remote) Docker containers

I always had problems remembering Docker commands: to run a shell in a container, should I use docker run or docker exec? Wait, I probably need to "attach" the terminal to the running container. No problem, let's try docker attach. Ooops...

These commands initially made no much sense to me - run and exec sounds like an alias to me and attach; well, Docker authors clearly had the idea that attaching to container and attaching shell input (typing commands inside container shell) are entirely unrelated things.

Because of this, I kept personal docker.org file with all the notes how I'm going to start a container, run something in it, and so on.

Continue reading →