Evan Moses

My blog and projects

  • Emacs Tidbit: rectangle-number-lines

    Emacs has so many little features that do exactly what you need in very specific circumstances. Here’s one that I just found out about: rectangle-number-lines. I had some lines and I wanted to insert line-numbers for reference. I wanted this arguments list: [ team8721038424565681034 user fdff6f87-d876-4558-8d12-19e039e5a880 a foo secret alsothis b e46e2d16-b3ba-4f84-826f-5e3031465e21 ] To be this arguments list: [ 1 team8721038424565681034 2 user 3 fdff6f87-d876-4558-8d12-19e039e5a880 4 a 5 foo 6 secret 7 alsothis 8 b 9 e46e2d16-b3ba-4f84-826f-5e3031465e21 ] I started thinking about kmacros, which I rarely use but have an incrementing counter you can use for this, but I started googling and lo and behold I found a Stack Overflow post with the answer.

    Read more…
  • No I don't want 2, Emacs

    This blog, and the vast majority of the code I write, is written in Emacs with evil (a vim emulation mode). I have a nasty habit of mashing :w2<ret> when I really was trying to save the current buffer with :w<ret> . :w2 writes the current buffer to a new file called 2, which I don’t believe I have ever done on purpose. So, I added this little gem to my .

    Read more…
  • Representing State as interfaces in Go

    I made up a neat little pattern in Go the other day. It’s a way to represent a state change in a system by exposing different APIs for different states, while only holding state in a single underlying struct. I’m sure I’m not the first person to invent this, and it may already a name, so please let me know if you know of one [Update: apg on Lobsters pointed out the name “typestate”, which I like].

    Read more…
  • Building a custom Emacs auth-source

    My employer, Okta, has recently been making security improvements to how we access all sorts of internal systems. As part of that hardening, we’ve been disallowed from using SSH keys and long-lived GitHub tokens to access our code on GitHub. In place of that, we’ve now got an internal tool that grants us short-lived tokens on demand, after SSOing (through Okta of course). This is a good idea even if it adds a little friction, and means that if you gain access to my machine somehow you won’t automatically have my privileges to access our code base.

    Read more…