miércoles, 31 de marzo de 2021

Interesting new-old takes on git

 It seems there are a few things going on lately on the git subspace.

 

For one, ppl are talking about the mail flow vs Pull Request flow. It's interesting how people go back and forth on those: https://blog.brixit.nl/git-email-flow-versus-github-flow/

 Here's an interesting take at git flows again. Git plan focuses on writing the commit message before doing the commits. Maybe it's something to fix the issue/pr dicothomy?: https://github.com/synek/git-plan

And a bonus of HN thread with some git helpers using fzf: https://news.ycombinator.com/item?id=26634419

jueves, 4 de marzo de 2021

a few cli tools

 New job, new tooling, and reinventing the same trick again and again :)


This time, a few things on console stuff:

  • https://github.com/okbob/pspg
  • https://github.com/rcoh/angle-grinder
  • https://github.com/jpmens/jo


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