domingo, 21 de febrero de 2021

2 emacs lisp curiosities

So some guy wrote a story about emacs being used in some air traffic control system, because elisp. :) And another user (unrelated) showed off this amazing cl-loop in emacs. 

 2 elispy things that got me smiling this weekend :)


"When all you have is a Lisp ...

...everything looks like a recursive merge of trees"


It's been a little more than a month at Metabase, and doing Clojure is giving me again those deep recursive thoughts of seeing every problem as a recursive merge of trees.


I've looked at this python deep merge of dictionaries I used for some project at my previous $JOB.

And there are DSLs everywhere (sometimes, more than I think are needed).

And there's Specter, and Meander (https://www.reddit.com/r/Clojure/comments/loz77v/just_came_across_specter_mind_blown/ ) that use the code-is-data approach.

And just getting familiar with edn, that even it is very simple and minimal. It is malleable enough to be processed. 

I'm also working on a clojure version of gojira, that of course uses some tree merging.

sábado, 30 de enero de 2021

Shell Oneliner Compression

I'm back to Lisp. Now, Clojure. For real. But this post is about zsh

Part of my relearning of clojure is to read and watch everything clojure that crosses my path. And I discovered https://github.com/clojure-cookbook/clojure-cookbook , which seems super useful.  But I have too many open tabs and books already. So I thought I'd do a 'Tip Of The Day' like thing, and I'd pop a different page every day.

 Relevant files have .asciidoc  extension. And the ones with content start with a number. The other ones are index pages or headers/footers.

Here's a version of what I typed. and it worked (at the second try!)


random-clojure() {
   e $(ls ~/clojure-cookbook/**/*asciidoc(.) | awk -F/ '$NF ~ /^[0-9]/' | shuf -n1 | xargs realpath)
}

Quite a lot of things going on there, so I'm gonna explain the oneliner, because there's a lot of compression there.


  • e. e is my shellscript that opens files in emacs, moving to the line, and massaging input. in this case, it's the same as emacs, vi, $EDITOR.
  • ~/clojure-cookbook/**/*asciidoc(.). This one expands recursively files that contain 'asciidoc'. excluding directories. '**/' means 'recursively' in zsh, and the '(.)' globbing is for files only.
  • awk. '-F/' makes slash a field separator. Then, we pick the latest field, and we regex match it with '/^[0-9]/', beginning with a number. Cool!
  • shuf -n1 picks a line at random
  • xargs realpath. As we'll be running this function from all kinds of directories, expand the file path to an absolute path. as realpath asks for a parameter, we either nest the whole thing or use the xargs trick.

 

While writing this, I noticed that the whole thing is much simpler than that:

 e $(ls ~/clojure-cookbook/**/[0-9]*asciidoc(.)|shuf -n1| xargs realpath)

Master-ing git

 


miércoles, 23 de diciembre de 2020

org, roam, zettelkasten links.

Here we have a couple of links talking about the new wave on PIM, bookmarking, concept-linking.

It used to be the case that each one of us had a smilar but not quite the same system. But it seems that zettelkasten, and roam are getting some gravitational pull so people are joining them.

Usual links are org-roam, zettelkasten, and another link to zettelkasten-in-plain-org

martes, 8 de diciembre de 2020

N Good Javascript Tutorials

There's so much about javascript on the web that it's always been hard (for me) to find good resources.  But I think I found these N tutorials that are pretty good.

Good tutorials are hard to find and keeping the good links is important. I'm keeping also this docker tutorial. I just wish I've had it 3 years ago.