martes, 11 de octubre de 2022

Oral History of Dan Ingalls

Dan Ingalls and Brian Kernighan are the few people that I can listen for N hours straight, no x2, just x1, and just listen and be in awe.

 

There's this new interview to him, and I think it's amazing. Nothing to do with Alan's talks. The speed, the body language... many different things, and equally amazing.

https://www.youtube.com/watch?v=EMwHeqQZgFw

 

Btw, at 2:30 is when he talks about Steve Job's demo.

Also, 2:45 or so, squeak implementation and portability, blowing your mind.

jueves, 6 de octubre de 2022

jq assignment of multiple fields

Jq has become the de-facto json console tool. Apart from slicing and dicing your jsons, one can do things like assigning new fields to it, or modifying existing ones.

As I explain in my scripting field guide, changing epoch times to a readable timestamp can be done like:

echo '{"date":1643192480}' | jq '.date|=todateiso8601' #  {"date": "2022-01-26T10:22:48Z"}

 

To assign multiple fields in jq, you must interleave '|' inbetween, effectively piping the result to the next assignment.

And here's the bash snippet of the day:

join_by() { local IFS="$1"; shift; echo "$*"; }
pretty_dates() {
  jq "$(join_by "|" ${@/%/|=todateiso8601})"

`curl http://..... | pretty_dates .start_date .end_date` will build the proper assignments and use jq so that we get a nicely formatted json output.

Again, for small helpers like these, a bit of advanced bash can get you very very far.

 

The explanation of the weird line is: from the default (${@}) params as an array, append every element (/%/) with |=todateiso8601). That, joined by |. And that becomes the "filter" to jq.