Using GPG for symmetric file encoding and decoding

Motivation

I have a project on github and I want to add a simple Makefile for deployment. But I want to be sure that nobody will see its contents because I don't want to expose irrelevant details of how do I host it. On the other hand I want this file to be there, because I want to be able to deploy from different machines.

Solution (encryption)

The solution is simple: I'm going to encrypt Makefile with gpg, put original file into .gitignore and that's it.

So, first let's encrypt the file with a symmetric key:

gpg --armor -c Makefile

The command above will create a Makefile.asc file. I prefer having a plain-text file instead of binary thus I --armor it. And to use passphrase based symmetric encryption I'm using -c (or --symmetric).

Now I can put original Makefile to .gitignore:

echo '/Makefile' >> .gitignore

Decryption

How do I use it on a new machine? Simple:

gpg --output Makefile -d Makefile.asc

That's it, now I have an ignored Makefile which I can use for deployment via make.

In case you have pinentry related errors you may fix those by changing gpg-agent config:

# consult your distro docs for a proper solution
echo pinentry-program /usr/bin/pinentry-curses > ~/.gnupg/gpg-agent.conf
systemct --user restart gpg-agent

Limitations

Obviously one have to remember to do the procedure every time Makefile is changed. Though it's not a big issue in my simple case as I don't change it that often.

Using fill-column-indicator for Characters Per Line limit

I prefer limiting characters per line for my code, and I'm not alone. I'm getting natural limit by always using Emacs in the 2 column mode (C-x 3).

If you want to get a proper visual advice, you can use fill-column. Normally fill-column is consulted when Emacs wants to reformat text in a paragraph, for example if one press M-q or (fill-paragraph). But we can also use it to solve our task. Notice the light-grey vertical line: fill-column-indicator

And here is the code, which should be self explanatory.

(defun my-toggle-fill-column-indicator ()
  "Toggle displaying of fill column indicator."
  (interactive)
  (if display-fill-column-indicator
      (setq display-fill-column-indicator nil)
    (setq display-fill-column-indicator t)
    (setq display-fill-column-indicator-character ?\N{U+2506})))

You can of course M-x customize-variable fill-column or setq it. Or just run M-x set-fill-column to interactively change it on the fly.

If you wish you can enable it for any programming mode:

(add-hook 'prog-mode-hook #'my-toggle-fill-column-indicator)

And finally here some options for styling indicator itself:

;; ┊
(setq-default display-fill-column-indicator-character ?\N{U+2506})

;; ┆
(setq-default display-fill-column-indicator-character ?\N{U+250A})

;; ╎
(setq-default display-fill-column-indicator-character ?\N{U+254E})

;; face customization:
(customize-face 'fill-column-indicator)
;; or put something like this in your theme
'(fill-column-indicator ((t (:foreground "#4e4e4e"))))

NOTE: display-fill-column-indicator is available since Emacs 27.1 You may use fill-column-indicator package, though I haven't tried it myself.

Hi there!

Welcome to by shiny new blog!

This is a test header

This page is used here for tests

And some more

To just move content a bit more.

And this is a subheading

  • Bold and Italic

Common Lisp: динамические (специальные) переменные

Вместо тысячи слов:

package main

import (
	"log"
)

var global = 1

func main() {
        log.Println("Global before", global)
        func() {
                global := 2
                log.Println("Global in closure", global)
                test()
        }()
        log.Println("Global after", global)
}

func test() {
        log.Println("Global in test", global)
}

// Global before 1
// Global in closure 2
// Global in test 1
// Global after 1

(defparameter *global* 1)

(defun main ()
  (format t "Global before ~a~%" *global*)
  (funcall (lambda ()
             (let ((*global* 2))
               (format t "Global in closure ~a~%" *global*)
               (test))))
  (format t "Global after ~a~%" *global*))

(defun test ()
  (format t "Global in test ~a~%" *global*))

(main)

;; Global before 1
;; Global in closure 2
;; Global in test 2
;; Global after 1