From 8baff7beaf0e052f8369cb3dcf477b454744a567 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 18 Mar 2021 23:52:45 -0400 Subject: Update transcript for #25 --- 2020/info/25.md | 181 ++++- 2020/organizers-notebook.org | 6 +- ...-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt | 757 --------------------- ...feedback-counsel-jq--zen-monk-alain-m-lafon.vtt | 553 +++++++++++++++ 4 files changed, 735 insertions(+), 762 deletions(-) delete mode 100644 2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt create mode 100644 2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.vtt diff --git a/2020/info/25.md b/2020/info/25.md index 090cb22e..4e49cdc6 100644 --- a/2020/info/25.md +++ b/2020/info/25.md @@ -1,8 +1,9 @@ # Traverse complex JSON structures with live feedback Zen Monk Alain M. Lafon -[[!template id=vid src="https://mirror.csclub.uwaterloo.ca/emacsconf/2020/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.webm"]] -[Download compressed .webm video (15.8M)](https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon--vp9-q56-video-original-audio.webm) +[[!template vidid="mainVideo" id=vid src="https://mirror.csclub.uwaterloo.ca/emacsconf/2020/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.webm" subtitles="/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.vtt"]] +[Download compressed .webm video (15.8M)](https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon--vp9-q56-video-original-audio.webm) +[View transcript](#transcript) If you are working with complex nested JSON structures, you are probably familiar with jq which is like sed for JSON data and great at @@ -69,3 +70,179 @@ queries in jq should be valid in jq. Hence, I'm inclined to say - counsel-jq: . - organice: . - Entire presentation inside Emacs, with a count down reminder. + + +# Transcript + +[[!template new="1" text="Hello, everyone, and welcome to this short lightning talk:" start="00:00:00.799" video="mainVideo" id=subtitle]] +[[!template text=""Traverse Complex JSON Structures with Live Feedback."" start="00:00:05.520" video="mainVideo" id=subtitle]] +[[!template text="This is a pre-recorded talk and part of the EmacsConf 2020 schedule." start="00:00:09.519" video="mainVideo" id=subtitle]] +[[!template text="This is what we're going to do." start="00:00:18.000" video="mainVideo" id=subtitle]] +[[!template text="I'll make a quick introduction to the topic at hand." start="00:00:19.439" video="mainVideo" id=subtitle]] +[[!template text="I'll give you a demonstration of some tools," start="00:00:22.320" video="mainVideo" id=subtitle]] +[[!template text="and then we'll leave you with the links to said tools." start="00:00:24.400" video="mainVideo" id=subtitle]] +[[!template new="1" text="Before that, just a little bit about me." start="00:00:29.199" video="mainVideo" id=subtitle]] +[[!template text="I am the CEO and co-founder of a company based in the Swiss mountains called 200ok.ch." start="00:00:31.679" video="mainVideo" id=subtitle]] +[[!template text="We are a product incubator and service consultancy," start="00:00:40.399" video="mainVideo" id=subtitle]] +[[!template text="but we like to spend most or at least as much time as we can" start="00:00:44.879" video="mainVideo" id=subtitle]] +[[!template text="building free software." start="00:00:50.000" video="mainVideo" id=subtitle]] +[[!template text="I'm also an ordained Zen monk and abbot of the Lambda Zen temple." start="00:00:52.719" video="mainVideo" id=subtitle]] +[[!template text="You can reach me anytime on questions regarding Emacs, for example," start="00:00:56.879" video="mainVideo" id=subtitle]] +[[!template text="at alain@200ok.ch." start="00:01:04.159" video="mainVideo" id=subtitle]] +[[!template new="1" text="But back to the topic at hand." start="00:01:07.200" video="mainVideo" id=subtitle]] +[[!template text="The proposition is as following:" start="00:01:09.439" video="mainVideo" id=subtitle]] +[[!template text="most work on the computer is based on either" start="00:01:11.760" video="mainVideo" id=subtitle]] +[[!template text="text processing or text consumption." start="00:01:14.000" video="mainVideo" id=subtitle]] +[[!template text="And very often, the text which you need to process is in a structured format," start="00:01:16.479" video="mainVideo" id=subtitle]] +[[!template text="for example, in JSON." start="00:01:22.799" video="mainVideo" id=subtitle]] +[[!template text="That might even be if your job is not programming per se." start="00:01:24.560" video="mainVideo" id=subtitle]] +[[!template text="Reading through such a bigger chunk of JSON can be non-trivial, however," start="00:01:28.560" video="mainVideo" id=subtitle]] +[[!template text="while just reading and understanding it" start="00:01:33.119" video="mainVideo" id=subtitle]] +[[!template text="will be essential to getting your job done." start="00:01:36.479" video="mainVideo" id=subtitle]] +[[!template new="1" text="So let's quickly check out an example JSON file." start="00:01:40.320" video="mainVideo" id=subtitle]] +[[!template text="This is from the Github API," start="00:01:44.479" video="mainVideo" id=subtitle]] +[[!template text="which is a request--sorry, the response to a request" start="00:01:47.200" video="mainVideo" id=subtitle]] +[[!template text="for a specific issue on the github API." start="00:01:52.079" video="mainVideo" id=subtitle]] +[[!template text="So let's quickly check that one out." start="00:01:54.640" video="mainVideo" id=subtitle]] +[[!template text="Okay. So here it is open, and we can already see" start="00:01:58.799" video="mainVideo" id=subtitle]] +[[!template text="that there is lots of stuff going on here." start="00:02:01.920" video="mainVideo" id=subtitle]] +[[!template text="It's 200 lines." start="00:02:05.439" video="mainVideo" id=subtitle]] +[[!template text="It's not going to be very easy" start="00:02:07.360" video="mainVideo" id=subtitle]] +[[!template text="just to find out what are the top level things in here," start="00:02:09.200" video="mainVideo" id=subtitle]] +[[!template text="what are the top level attributes." start="00:02:11.840" video="mainVideo" id=subtitle]] +[[!template text="Of course I can do this, and maybe do it by hand, but that doesn't scale." start="00:02:13.360" video="mainVideo" id=subtitle]] +[[!template text="I can use cool Emacs facilities like the hideshow-mode" start="00:02:17.840" video="mainVideo" id=subtitle]] +[[!template text="and try to fold all the things that are top level," start="00:02:21.599" video="mainVideo" id=subtitle]] +[[!template text="but that also doesn't really scale." start="00:02:24.720" video="mainVideo" id=subtitle]] +[[!template text="There must be a better way." start="00:02:27.200" video="mainVideo" id=subtitle]] +[[!template text="Of course there is. There is prior art." start="00:02:29.360" video="mainVideo" id=subtitle]] +[[!template new="1" text="There is a tool called jq." start="00:02:32.000" video="mainVideo" id=subtitle]] +[[!template text="I'm going to quote the USP (unique selling proposition) from their website:" start="00:02:34.080" video="mainVideo" id=subtitle]] +[[!template text="jq is like sed for JSON data." start="00:02:37.760" video="mainVideo" id=subtitle]] +[[!template text="you can use it to slice and filter and map and transform structured data" start="00:02:42.000" video="mainVideo" id=subtitle]] +[[!template text="with the same ease that" start="00:02:46.319" video="mainVideo" id=subtitle]] +[[!template text="sed, awk, grep, and friends let you play with text." start="00:02:47.840" video="mainVideo" id=subtitle]] +[[!template text="Let me give you a quick demonstration of it." start="00:02:54.000" video="mainVideo" id=subtitle]] +[[!template text="By the way, it's written in portable C." start="00:02:56.879" video="mainVideo" id=subtitle]] +[[!template text="It has zero runtime dependency, so it's very easy to get started with it" start="00:02:59.040" video="mainVideo" id=subtitle]] +[[!template text="and use it on pretty much any UNIX-based computer." start="00:03:03.519" video="mainVideo" id=subtitle]] +[[!template text="Sorry, no, Linux-based computer, apologies." start="00:03:09.840" video="mainVideo" id=subtitle]] +[[!template new="1" text="Okay, so let's explore a JSON file with it." start="00:03:14.000" video="mainVideo" id=subtitle]] +[[!template text="It's a command line tool," start="00:03:18.720" video="mainVideo" id=subtitle]] +[[!template text="and it has a very simple command line syntax." start="00:03:20.000" video="mainVideo" id=subtitle]] +[[!template text="So you call the binary and then you give it a query and a file," start="00:03:24.000" video="mainVideo" id=subtitle]] +[[!template text="and then it will return its answer." start="00:03:29.840" video="mainVideo" id=subtitle]] +[[!template text="So, for example, if I want the top level keys," start="00:03:32.560" video="mainVideo" id=subtitle]] +[[!template text="I will just say jq keys the file" start="00:03:35.440" video="mainVideo" id=subtitle]] +[[!template text="and it will return the keys." start="00:03:38.000" video="mainVideo" id=subtitle]] +[[!template text="Simple as that. So let's check this out in a real shell." start="00:03:39.840" video="mainVideo" id=subtitle]] +[[!template text="Here I am in eshell." start="00:03:44.400" video="mainVideo" id=subtitle]] +[[!template text="Let's run jq keys on the Github issue comment." start="00:03:46.879" video="mainVideo" id=subtitle]] +[[!template text="We can see that we have actually received a list back here" start="00:03:51.440" video="mainVideo" id=subtitle]] +[[!template text="with the top-level things." start="00:03:58.799" video="mainVideo" id=subtitle]] +[[!template text="So this issue... It looks very interesting." start="00:04:00.319" video="mainVideo" id=subtitle]] +[[!template text="Let's ask it to give me more information on this issue." start="00:04:02.879" video="mainVideo" id=subtitle]] +[[!template text="Then it's hairy again. That's a lot of stuff." start="00:04:07.360" video="mainVideo" id=subtitle]] +[[!template new="1" text="I mean, lucky for us, we are in Emacs here," start="00:04:11.360" video="mainVideo" id=subtitle]] +[[!template text="so we can use nice shortcuts." start="00:04:14.560" video="mainVideo" id=subtitle]] +[[!template text="We can copy this. We can go in here, just select that," start="00:04:16.720" video="mainVideo" id=subtitle]] +[[!template text="get that out or something like this." start="00:04:22.000" video="mainVideo" id=subtitle]] +[[!template text="But still, this is not really the best way to do that, right?" start="00:04:24.160" video="mainVideo" id=subtitle]] +[[!template text="it gets kind of tedious." start="00:04:32.320" video="mainVideo" id=subtitle]] +[[!template text="At this point the output can be humongous." start="00:04:34.080" video="mainVideo" id=subtitle]] +[[!template text="The shell is not really the best place to read through such big output." start="00:04:37.680" video="mainVideo" id=subtitle]] +[[!template text="I mean, eshell is probably one of the better shells for this," start="00:04:41.919" video="mainVideo" id=subtitle]] +[[!template text="because it's just a regular Emacs buffer," start="00:04:45.759" video="mainVideo" id=subtitle]] +[[!template text="but still, it's not really the best tool." start="00:04:47.919" video="mainVideo" id=subtitle]] +[[!template text="I need to repeat the command all the time" start="00:04:50.720" video="mainVideo" id=subtitle]] +[[!template text="until I finally build the right query." start="00:04:53.680" video="mainVideo" id=subtitle]] +[[!template text="And all the time, I lose my focus," start="00:04:56.000" video="mainVideo" id=subtitle]] +[[!template text="I lose what I'm currently looking at." start="00:04:59.840" video="mainVideo" id=subtitle]] +[[!template text="I'm seeing the new result." start="00:05:02.800" video="mainVideo" id=subtitle]] +[[!template new="1" text="It would be so much nicer to have live feedback." start="00:05:05.520" video="mainVideo" id=subtitle]] +[[!template text="When working with Emacs, we're quite used to that." start="00:05:08.160" video="mainVideo" id=subtitle]] +[[!template text="So there should be an option." start="00:05:10.720" video="mainVideo" id=subtitle]] +[[!template text="And of course there is. It's Emacs, right," start="00:05:12.320" video="mainVideo" id=subtitle]] +[[!template text="so you can do anything." start="00:05:15.120" video="mainVideo" id=subtitle]] +[[!template new="1" text="There is various good tools for completion in Emacs." start="00:05:17.759" video="mainVideo" id=subtitle]] +[[!template text="I used ivy for this." start="00:05:22.960" video="mainVideo" id=subtitle]] +[[!template text="I'm going to quote the USP for ivy." start="00:05:26.000" video="mainVideo" id=subtitle]] +[[!template text="ivy is a generic completion mechanism for Emacs." start="00:05:29.039" video="mainVideo" id=subtitle]] +[[!template text="While it operates similarly to other completion schemes such as icomplete mode," start="00:05:32.639" video="mainVideo" id=subtitle]] +[[!template text="ivy aims to be more efficient, smaller, simpler, and smoother to use," start="00:05:37.919" video="mainVideo" id=subtitle]] +[[!template text="yet highly customizable." start="00:05:42.160" video="mainVideo" id=subtitle]] +[[!template text="And that's true." start="00:05:45.199" video="mainVideo" id=subtitle]] +[[!template new="1" text="One of the cool things of ivy" start="00:05:46.479" video="mainVideo" id=subtitle]] +[[!template text="compared to other completion mechanisms in Emacs" start="00:05:49.440" video="mainVideo" id=subtitle]] +[[!template text="is that it can be used on dynamic data." start="00:05:54.320" video="mainVideo" id=subtitle]] +[[!template text="So usually completion works on a static input." start="00:05:59.120" video="mainVideo" id=subtitle]] +[[!template text="For example, you're in a buffer, a text buffer," start="00:06:02.400" video="mainVideo" id=subtitle]] +[[!template text="and you use isearch maybe with ido-mode," start="00:06:05.360" video="mainVideo" id=subtitle]] +[[!template text="and you find your results. That's all nice." start="00:06:09.600" video="mainVideo" id=subtitle]] +[[!template text="However, if I want to search on dynamic data," start="00:06:13.360" video="mainVideo" id=subtitle]] +[[!template text="that doesn't work." start="00:06:19.600" video="mainVideo" id=subtitle]] +[[!template text="So whenever I type in my query for jq," start="00:06:20.720" video="mainVideo" id=subtitle]] +[[!template text="I actually need to call the jq binary," start="00:06:24.880" video="mainVideo" id=subtitle]] +[[!template text="and it will give a different result set back." start="00:06:28.000" video="mainVideo" id=subtitle]] +[[!template text="So it's a really dynamic mechanism that we need here." start="00:06:30.720" video="mainVideo" id=subtitle]] +[[!template text="It's much more like a search engine." start="00:06:36.160" video="mainVideo" id=subtitle]] +[[!template new="1" text="ivy luckily has something built in," start="00:06:38.240" video="mainVideo" id=subtitle]] +[[!template text="and it's called counsel." start="00:06:41.440" video="mainVideo" id=subtitle]] +[[!template text="So I used counsel and jq and combined them," start="00:06:43.520" video="mainVideo" id=subtitle]] +[[!template text="and built a new package" start="00:06:47.360" video="mainVideo" id=subtitle]] +[[!template text="with which we can use Emacs and jq" start="00:06:49.199" video="mainVideo" id=subtitle]] +[[!template text="to have live feedback." start="00:06:52.960" video="mainVideo" id=subtitle]] +[[!template text="It's very easy to use." start="00:06:56.000" video="mainVideo" id=subtitle]] +[[!template text="So you just call counsel-jq" start="00:06:57.759" video="mainVideo" id=subtitle]] +[[!template text="on a buffer containing JSON." start="00:06:59.840" video="mainVideo" id=subtitle]] +[[!template text="For example, the one we have here." start="00:07:02.160" video="mainVideo" id=subtitle]] +[[!template text="Let's call counsel-jq on it," start="00:07:04.319" video="mainVideo" id=subtitle]] +[[!template text="and we already get a default query," start="00:07:06.800" video="mainVideo" id=subtitle]] +[[!template text="the dot query, which just gives us the same file." start="00:07:10.080" video="mainVideo" id=subtitle]] +[[!template text="But now we can change it." start="00:07:14.639" video="mainVideo" id=subtitle]] +[[!template text="For example, find all the keys in here." start="00:07:16.240" video="mainVideo" id=subtitle]] +[[!template text="And then we see I had this issue." start="00:07:18.639" video="mainVideo" id=subtitle]] +[[!template text="This was the one that we were interested in." start="00:07:20.319" video="mainVideo" id=subtitle]] +[[!template text="So let's find more information on the issue." start="00:07:22.800" video="mainVideo" id=subtitle]] +[[!template text="What keys does it have actually have?" start="00:07:25.599" video="mainVideo" id=subtitle]] +[[!template text="It has assignees. That interests me." start="00:07:28.720" video="mainVideo" id=subtitle]] +[[!template text="So let's check out the assignees in here." start="00:07:31.680" video="mainVideo" id=subtitle]] +[[!template text="There's two of them, but I'm only interested in the first one." start="00:07:34.800" video="mainVideo" id=subtitle]] +[[!template text="I'm making stuff up as I go here, of course." start="00:07:39.759" video="mainVideo" id=subtitle]] +[[!template text="Whenever I hit enter, I get a new buffer" start="00:07:43.599" video="mainVideo" id=subtitle]] +[[!template text="which just shows me this particular result" start="00:07:47.039" video="mainVideo" id=subtitle]] +[[!template text="for the particular query that I entered." start="00:07:52.639" video="mainVideo" id=subtitle]] +[[!template new="1" text="So let me do that again." start="00:07:55.599" video="mainVideo" id=subtitle]] +[[!template text="We are in here. We are looking at a JSON file." start="00:07:57.680" video="mainVideo" id=subtitle]] +[[!template text="This can be very, very big." start="00:08:04.000" video="mainVideo" id=subtitle]] +[[!template text="Doesn't also need to be a file." start="00:08:05.840" video="mainVideo" id=subtitle]] +[[!template text="Just needs to be a buffer." start="00:08:07.280" video="mainVideo" id=subtitle]] +[[!template text="You call counsel-jq on it," start="00:08:09.520" video="mainVideo" id=subtitle]] +[[!template text="and you can do any kind of query on it." start="00:08:11.360" video="mainVideo" id=subtitle]] +[[!template text="For example, let's see if there is a URL here." start="00:08:14.319" video="mainVideo" id=subtitle]] +[[!template text="Yes, there's a URL." start="00:08:18.080" video="mainVideo" id=subtitle]] +[[!template text="Let's see if there's a repository here." start="00:08:19.440" video="mainVideo" id=subtitle]] +[[!template text="Repository. No, there isn't." start="00:08:22.827" video="mainVideo" id=subtitle]] +[[!template text="What was it called? Issue. Keys. Repository URL, it was called." start="00:08:24.639" video="mainVideo" id=subtitle]] +[[!template text="So let's see issue repository URL," start="00:08:33.440" video="mainVideo" id=subtitle]] +[[!template text="and then we see." start="00:08:38.240" video="mainVideo" id=subtitle]] +[[!template text="So apparently this issue comment is for a repository called organice." start="00:08:39.519" video="mainVideo" id=subtitle]] +[[!template text="I wonder what that might be." start="00:08:44.800" video="mainVideo" id=subtitle]] +[[!template new="1" text="Okay. So that was a very short introduction to counsel-jq." start="00:08:47.839" video="mainVideo" id=subtitle]] +[[!template text="You can see the timer here." start="00:08:52.640" video="mainVideo" id=subtitle]] +[[!template text="I only have one minute left to go, so I'm going to leave" start="00:08:54.240" video="mainVideo" id=subtitle]] +[[!template text="with a very, very short introduction to the counsel-jq code." start="00:08:57.440" video="mainVideo" id=subtitle]] +[[!template text="It's not even 60 lines of elisp," start="00:09:02.880" video="mainVideo" id=subtitle]] +[[!template text="so building something like this is very, very easy." start="00:09:06.000" video="mainVideo" id=subtitle]] +[[!template text="I would encourage you to go and read through the code in your own time," start="00:09:09.600" video="mainVideo" id=subtitle]] +[[!template text="if you're interested in building something like this." start="00:09:14.560" video="mainVideo" id=subtitle]] +[[!template text="If you're interested in just using jq or you're done," start="00:09:17.519" video="mainVideo" id=subtitle]] +[[!template text="these are the links to all the tools." start="00:09:22.720" video="mainVideo" id=subtitle]] +[[!template text="counsel-jq, of course, is readily available on MELPA." start="00:09:24.320" video="mainVideo" id=subtitle]] +[[!template text="Also developed under the AGPL license on Github." start="00:09:28.240" video="mainVideo" id=subtitle]] +[[!template text="And this organice thing, by the way, it's" start="00:09:32.959" video="mainVideo" id=subtitle]] +[[!template text="Org Mode for mobile and desktop browsers." start="00:09:36.080" video="mainVideo" id=subtitle]] +[[!template text="Also a great free software tool maybe that interests you." start="00:09:38.560" video="mainVideo" id=subtitle]] +[[!template text="Thank you for listening. Have a great time." start="00:09:43.120" video="mainVideo" id=subtitle]] +[[!template text="10 seconds left. I am going to stop this now." start="00:09:46.240" video="mainVideo" id=subtitle]] +[[!template text="Enjoy EmacsConf. Have a great day." start="00:09:49.360" video="mainVideo" id=subtitle]] diff --git a/2020/organizers-notebook.org b/2020/organizers-notebook.org index 1c54e0de..924dd736 100644 --- a/2020/organizers-notebook.org +++ b/2020/organizers-notebook.org @@ -52,10 +52,10 @@ I modified the =subed= package to work with VTT files. The modified version is a - [X] sachac [[./subtitles/emacsconf-2020--22-powering-up-special-blocks--musa-al-hassy-autogen.vtt]] - [ ] [[./subtitles/emacsconf-2020--23-incremental-parsing-with-emacs-tree-sitter--questions--tuan-anh-nguyen-autogen.vtt]] - [X] sachac [[./subtitles/emacsconf-2020--23-incremental-parsing-with-emacs-tree-sitter--tuan-anh-nguyen-autogen.vtt]] -- [ ] sachac [[./subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt]] -- [ ] [[./subtitles/emacsconf-2020--26-emacs-as-a-highschooler-how-it-changed-my-life--pierce-wang-autogen.vtt]] +- [X] sachac [[./subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt]] +- [ ] sachac [[./subtitles/emacsconf-2020--26-emacs-as-a-highschooler-how-it-changed-my-life--pierce-wang-autogen.vtt]] - [ ] [[./subtitles/emacsconf-2020--26-emacs-as-a-highschooler-how-it-changed-my-life--questions--pierce-wang-autogen.vtt]] -- [ ] [[./subtitles/emacsconf-2020--27-state-of-retro-gaming-in-emacs-chip8--vasilij-wasamasa-schneidermann-autogen.vtt]] +- [ ] sachac [[./subtitles/emacsconf-2020--27-state-of-retro-gaming-in-emacs-chip8--vasilij-wasamasa-schneidermann-autogen.vtt]] - [ ] [[./subtitles/emacsconf-2020--28-welcome-to-the-dungeon--erik-elmshauser-corwin-brust-autogen.vtt]] - [ ] [[./subtitles/emacsconf-2020--30-a-tour-of-vterm--gabriele-bozzola-sbozzolo-autogen.vtt]] - [ ] [[./subtitles/emacsconf-2020--30-a-tour-of-vterm--questions--gabriele-bozzola-sbozzolo-autogen.vtt]] diff --git a/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt b/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt deleted file mode 100644 index e7eada5b..00000000 --- a/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon-autogen.vtt +++ /dev/null @@ -1,757 +0,0 @@ -WEBVTT - -00:00:00.799 --> 00:00:04.000 -hello everyone and welcome to this short - -00:00:04.000 --> 00:00:05.520 -lightning talk - -00:00:05.520 --> 00:00:08.160 -traverse complex json structures with - -00:00:08.160 --> 00:00:09.519 -live feedback - -00:00:09.519 --> 00:00:13.040 -this is a pre-recorded talk and part of - -00:00:13.040 --> 00:00:18.000 -the e-max conf 2020 schedule - -00:00:18.000 --> 00:00:19.920 -this is what we're going to do I'll make - -00:00:19.920 --> 00:00:21.840 -a quick introduction to the topic at - -00:00:21.840 --> 00:00:22.320 -hand - -00:00:22.320 --> 00:00:23.920 -I'll give you a demonstration of some - -00:00:23.920 --> 00:00:25.760 -tools and then we'll leave you - -00:00:25.760 --> 00:00:29.199 -with the links to set tools - -00:00:29.199 --> 00:00:31.920 -before that just a little bit about me I - -00:00:31.920 --> 00:00:32.399 -am the - -00:00:32.399 --> 00:00:36.079 -ceo and co-founder of a company - -00:00:36.079 --> 00:00:39.520 -based in the swiss mountains called 200 - -00:00:39.520 --> 00:00:40.399 -okay - -00:00:40.399 --> 00:00:43.600 -we are a product incubator and - -00:00:43.600 --> 00:00:46.160 -service consultancy but we like to spend - -00:00:46.160 --> 00:00:47.200 -most or at least - -00:00:47.200 --> 00:00:50.719 -as much time as we can building free - -00:00:50.719 --> 00:00:52.719 -software - -00:00:52.719 --> 00:00:55.520 -I'm also an ordained zen monk and abbott - -00:00:55.520 --> 00:00:56.879 -of the lambda zen temple - -00:00:56.879 --> 00:01:00.160 -you can reach me anytime on questions - -00:01:00.160 --> 00:01:01.359 -regarding Emacs - -00:01:01.359 --> 00:01:05.860 -for example at ala at 200ok.ch - -00:01:05.860 --> 00:01:07.200 -[Music] - -00:01:07.200 --> 00:01:09.600 -but back to the topic at hand the - -00:01:09.600 --> 00:01:11.760 -proposition is as following - -00:01:11.760 --> 00:01:13.680 -most work on the computer is based on - -00:01:13.680 --> 00:01:15.520 -either text processing or text - -00:01:15.520 --> 00:01:16.479 -consumption - -00:01:16.479 --> 00:01:19.920 -and very often the text which you need - -00:01:19.920 --> 00:01:20.880 -to process - -00:01:20.880 --> 00:01:23.520 -is in a structured format for example in - -00:01:23.520 --> 00:01:24.560 -json - -00:01:24.560 --> 00:01:26.640 -that might even be if your job is not - -00:01:26.640 --> 00:01:28.560 -programming per se - -00:01:28.560 --> 00:01:30.400 -and reading through such a bigger chunk - -00:01:30.400 --> 00:01:33.119 -of json can be non-trivial however - -00:01:33.119 --> 00:01:36.479 -while just reading and understanding it - -00:01:36.479 --> 00:01:39.119 -will be essential to getting your job - -00:01:39.119 --> 00:01:40.320 -done - -00:01:40.320 --> 00:01:43.680 -so let's quickly check out an example - -00:01:43.680 --> 00:01:47.200 -json file this is from the github api - -00:01:47.200 --> 00:01:50.560 -where which is a request sorry the - -00:01:50.560 --> 00:01:53.119 -response to a request for a specific - -00:01:53.119 --> 00:01:55.280 -issue on the github api so let's - -00:01:55.280 --> 00:01:58.799 -quickly check that one out - -00:01:58.799 --> 00:02:01.280 -okay so here it is open and we can - -00:02:01.280 --> 00:02:03.280 -already see that there is lots of stuff - -00:02:03.280 --> 00:02:05.439 -going on here - -00:02:05.439 --> 00:02:08.319 -it's uh 200 lines it's not going to be - -00:02:08.319 --> 00:02:10.319 -very easy just just to find out what are - -00:02:10.319 --> 00:02:12.160 -the top level things in here what are - -00:02:12.160 --> 00:02:13.920 -the top level attributes of course I can - -00:02:13.920 --> 00:02:14.560 -do this - -00:02:14.560 --> 00:02:16.480 -and maybe it would by hand but that - -00:02:16.480 --> 00:02:17.840 -doesn't scale - -00:02:17.840 --> 00:02:20.560 -I can use cool Emacs facilities like the - -00:02:20.560 --> 00:02:22.560 -height show mode and try to - -00:02:22.560 --> 00:02:24.720 -fold all the things that are top level - -00:02:24.720 --> 00:02:27.200 -but that also doesn't really scale - -00:02:27.200 --> 00:02:29.760 -there must be a better way and of course - -00:02:29.760 --> 00:02:32.000 -there is there is prior art - -00:02:32.000 --> 00:02:34.959 -there is a tool called jq I'm going to - -00:02:34.959 --> 00:02:36.080 -quote the usp - -00:02:36.080 --> 00:02:39.120 -from their website jq is like - -00:02:39.120 --> 00:02:42.959 -sed said for json data you can use it to - -00:02:42.959 --> 00:02:44.720 -slice and filter and map - -00:02:44.720 --> 00:02:46.720 -and transform structured data with the - -00:02:46.720 --> 00:02:47.840 -same ease that - -00:02:47.840 --> 00:02:51.519 -z awk grep and friends let you play with - -00:02:51.519 --> 00:02:54.000 -text - -00:02:54.000 --> 00:02:56.160 -let me give you a quick demonstration of - -00:02:56.160 --> 00:02:57.519 -it by the way - -00:02:57.519 --> 00:02:59.680 -it's written in portable c it has zero - -00:02:59.680 --> 00:03:01.920 -runtime dependency so it's very easy - -00:03:01.920 --> 00:03:04.959 -to get started with it and use it on - -00:03:04.959 --> 00:03:09.040 -pretty much any unix-based - -00:03:09.040 --> 00:03:12.800 -computer sorry no linux based computer - -00:03:12.800 --> 00:03:16.159 -apologies okay so let's explore a - -00:03:16.159 --> 00:03:19.599 -json file with it it's a command line - -00:03:19.599 --> 00:03:21.120 -tool and it has a very - -00:03:21.120 --> 00:03:24.640 -simple command line syntax so you - -00:03:24.640 --> 00:03:26.799 -call the binary and then you give it a - -00:03:26.799 --> 00:03:27.840 -query - -00:03:27.840 --> 00:03:31.680 -and a file and then we'll return - -00:03:31.680 --> 00:03:33.840 -its answer so for example if I want the - -00:03:33.840 --> 00:03:35.440 -top level keys - -00:03:35.440 --> 00:03:38.319 -I will just say jq keys the file and it - -00:03:38.319 --> 00:03:39.840 -will return the keys - -00:03:39.840 --> 00:03:42.319 -simple as that so let's check this out - -00:03:42.319 --> 00:03:43.519 -in a real - -00:03:43.519 --> 00:03:46.879 -shell here I am in eshel - -00:03:46.879 --> 00:03:50.080 -let's run jq keys on the github - -00:03:50.080 --> 00:03:53.200 -issue comment and we can see - -00:03:53.200 --> 00:03:56.959 -that we have actually received a list - -00:03:56.959 --> 00:04:00.000 -back here with the top level - -00:04:00.000 --> 00:04:02.000 -things okay so this issue it looks very - -00:04:02.000 --> 00:04:04.319 -very interesting so let's uh ask it to - -00:04:04.319 --> 00:04:06.239 -give me more information on this - -00:04:06.239 --> 00:04:10.080 -issue then it's hairy again that's a lot - -00:04:10.080 --> 00:04:11.360 -of stuff - -00:04:11.360 --> 00:04:14.319 -I mean lucky for for us we are in Emacs - -00:04:14.319 --> 00:04:17.759 -here so we can use nice shortcuts we can - -00:04:17.759 --> 00:04:21.040 -copy this we go can go in here just - -00:04:21.040 --> 00:04:22.000 -select that - -00:04:22.000 --> 00:04:24.400 -get that out or something like this but - -00:04:24.400 --> 00:04:25.600 -still - -00:04:25.600 --> 00:04:28.320 -this is not really it's not really the - -00:04:28.320 --> 00:04:29.600 -best way - -00:04:29.600 --> 00:04:34.080 -to do that right it gets kind of tedious - -00:04:34.080 --> 00:04:36.639 -at this point the output can be - -00:04:36.639 --> 00:04:37.680 -humongous - -00:04:37.680 --> 00:04:39.360 -the shell is not really the best place - -00:04:39.360 --> 00:04:42.479 -to read through such big output I mean e - -00:04:42.479 --> 00:04:43.600 -shell is - -00:04:43.600 --> 00:04:45.440 -probably one of the better shells for - -00:04:45.440 --> 00:04:47.440 -this because it's just a regular Emacs - -00:04:47.440 --> 00:04:48.560 -buffer but still - -00:04:48.560 --> 00:04:51.199 -it's not really the best tool and I need - -00:04:51.199 --> 00:04:52.720 -to repeat the command - -00:04:52.720 --> 00:04:55.280 -all the time until I finally build the - -00:04:55.280 --> 00:04:56.000 -right query - -00:04:56.000 --> 00:04:59.120 -and all the time I use I lose my - -00:04:59.120 --> 00:05:02.080 -focus I lose what I'm currently looking - -00:05:02.080 --> 00:05:02.800 -at - -00:05:02.800 --> 00:05:06.080 -I'm seeing the new result it would be so - -00:05:06.080 --> 00:05:08.160 -much nicer to have live feedback - -00:05:08.160 --> 00:05:10.080 -and when working with Emacs we're quite - -00:05:10.080 --> 00:05:11.600 -used to that so there should be an - -00:05:11.600 --> 00:05:12.320 -option - -00:05:12.320 --> 00:05:15.120 -and of course there is it's Emacs right - -00:05:15.120 --> 00:05:17.759 -so you can do anything - -00:05:17.759 --> 00:05:20.880 -there is various good tools for - -00:05:20.880 --> 00:05:22.960 -completion in Emacs - -00:05:22.960 --> 00:05:26.000 -I used ivy for this - -00:05:26.000 --> 00:05:29.039 -I'm going to code the usp for ivy - -00:05:29.039 --> 00:05:31.840 -iv is a generic completion mechanism for - -00:05:31.840 --> 00:05:32.639 -Emacs - -00:05:32.639 --> 00:05:34.639 -while it operates similarly to other - -00:05:34.639 --> 00:05:35.919 -completion schemes - -00:05:35.919 --> 00:05:38.960 -such as icomplete mode iv aims to be - -00:05:38.960 --> 00:05:40.400 -more efficient smaller - -00:05:40.400 --> 00:05:43.120 -simpler and smoother to use yet highly - -00:05:43.120 --> 00:05:45.199 -customizable - -00:05:45.199 --> 00:05:47.840 -and that's true one of the cool things - -00:05:47.840 --> 00:05:49.440 -of iv - -00:05:49.440 --> 00:05:52.479 -compared to other completion mechanisms - -00:05:52.479 --> 00:05:54.320 -in Emacs - -00:05:54.320 --> 00:05:58.160 -is that it can be used on dynamic - -00:05:58.160 --> 00:06:01.600 -data so usually completion works on a - -00:06:01.600 --> 00:06:03.520 -static input for example you're in a - -00:06:03.520 --> 00:06:05.360 -buffer a text buffer - -00:06:05.360 --> 00:06:08.800 -and you use I search maybe with idle - -00:06:08.800 --> 00:06:09.600 -mode - -00:06:09.600 --> 00:06:12.400 -and you find your results that's all - -00:06:12.400 --> 00:06:13.360 -nice - -00:06:13.360 --> 00:06:16.960 -however if I - -00:06:16.960 --> 00:06:19.840 -want to search on dynamic data that - -00:06:19.840 --> 00:06:20.720 -doesn't work - -00:06:20.720 --> 00:06:23.759 -so whenever I type in my query - -00:06:23.759 --> 00:06:27.039 -for jq I actually need to call the jq - -00:06:27.039 --> 00:06:28.000 -binary - -00:06:28.000 --> 00:06:30.160 -and it will give a different result set - -00:06:30.160 --> 00:06:32.840 -back so it's a really - -00:06:32.840 --> 00:06:36.319 -dynamic mechanism that we need here it's - -00:06:36.319 --> 00:06:38.240 -much more like a search engine - -00:06:38.240 --> 00:06:41.440 -and ivy luckily has something built in - -00:06:41.440 --> 00:06:42.560 -and it's called - -00:06:42.560 --> 00:06:46.000 -console so I used council and jq - -00:06:46.000 --> 00:06:48.160 -and combined them and build a new - -00:06:48.160 --> 00:06:49.199 -package - -00:06:49.199 --> 00:06:52.960 -with which we can use Emacs and jq - -00:06:52.960 --> 00:06:56.000 -to have live feedback - -00:06:56.000 --> 00:06:58.800 -it's very easy to use so you just call - -00:06:58.800 --> 00:06:59.840 -console.jq - -00:06:59.840 --> 00:07:02.800 -on a buffer containing json for example - -00:07:02.800 --> 00:07:04.319 -the one we have here - -00:07:04.319 --> 00:07:07.280 -let's call console.jq on it and we - -00:07:07.280 --> 00:07:08.319 -already - -00:07:08.319 --> 00:07:11.280 -get a default query the dot query which - -00:07:11.280 --> 00:07:13.039 -just gives us - -00:07:13.039 --> 00:07:16.080 -the same file but now we can change it - -00:07:16.080 --> 00:07:17.280 -and for example - -00:07:17.280 --> 00:07:19.039 -find all the keys in here and then we - -00:07:19.039 --> 00:07:21.039 -see I had this issue this was the one - -00:07:21.039 --> 00:07:22.800 -that we were interested in - -00:07:22.800 --> 00:07:24.639 -so let's find more information on the - -00:07:24.639 --> 00:07:26.479 -issue what - -00:07:26.479 --> 00:07:28.800 -keys does it have actually have uh it - -00:07:28.800 --> 00:07:31.680 -has assignees that that interests me - -00:07:31.680 --> 00:07:34.800 -so let's check out the assignees in here - -00:07:34.800 --> 00:07:37.039 -there's two of them but I'm only - -00:07:37.039 --> 00:07:39.759 -interested in the first one - -00:07:39.759 --> 00:07:42.000 -I'm making stuff up as I go here of - -00:07:42.000 --> 00:07:43.599 -course - -00:07:43.599 --> 00:07:46.000 -and whenever I hit enter I get a new - -00:07:46.000 --> 00:07:47.039 -buffer - -00:07:47.039 --> 00:07:50.160 -which just shows me this - -00:07:50.160 --> 00:07:53.520 -particular result for the particular - -00:07:53.520 --> 00:07:55.599 -query that I entered - -00:07:55.599 --> 00:07:59.199 -so let me do that again we are in here - -00:07:59.199 --> 00:08:03.199 -we are looking at a - -00:08:03.199 --> 00:08:05.840 -json file this can be very very big - -00:08:05.840 --> 00:08:07.520 -doesn't also need to be a file just - -00:08:07.520 --> 00:08:09.520 -needs to be a buffer - -00:08:09.520 --> 00:08:12.160 -you call console.jq on it and you can do - -00:08:12.160 --> 00:08:13.599 -any kind of - -00:08:13.599 --> 00:08:16.479 -query on it for example let's see if - -00:08:16.479 --> 00:08:18.080 -there is a url here - -00:08:18.080 --> 00:08:20.319 -yes there's a url let's see if there's a - -00:08:20.319 --> 00:08:23.759 -repository here repository - -00:08:23.759 --> 00:08:26.879 -no there isn't what was it called issue - -00:08:26.879 --> 00:08:33.440 -keys repository url it was called okay - -00:08:33.440 --> 00:08:36.640 -so let's see issue pause - -00:08:36.640 --> 00:08:40.240 -url and then we see so - -00:08:40.240 --> 00:08:42.959 -apparently this issue command is for a - -00:08:42.959 --> 00:08:44.159 -repository called - -00:08:44.159 --> 00:08:47.839 -organize I wonder what that might be - -00:08:47.839 --> 00:08:50.320 -okay so that was a very short - -00:08:50.320 --> 00:08:52.640 -introduction to console jq - -00:08:52.640 --> 00:08:54.800 -you can see the timer here I only have - -00:08:54.800 --> 00:08:56.800 -one minute left to go so I'm going to - -00:08:56.800 --> 00:08:57.440 -leave - -00:08:57.440 --> 00:08:59.760 -with a very very short introduction to - -00:08:59.760 --> 00:09:01.519 -the console gq - -00:09:01.519 --> 00:09:05.040 -code it's not even 60 lines - -00:09:05.040 --> 00:09:07.519 -of e-lisp so building something like - -00:09:07.519 --> 00:09:09.600 -this is very very easy - -00:09:09.600 --> 00:09:12.800 -I would encourage you to go and read - -00:09:12.800 --> 00:09:14.560 -through the code in your own time - -00:09:14.560 --> 00:09:16.160 -if you're interested in building - -00:09:16.160 --> 00:09:18.320 -something like this if you're interested - -00:09:18.320 --> 00:09:19.600 -in just using - -00:09:19.600 --> 00:09:22.720 -jq or you're done - -00:09:22.720 --> 00:09:24.320 -these are the links to all the tools - -00:09:24.320 --> 00:09:25.839 -console.jq of course - -00:09:25.839 --> 00:09:28.800 -is readily available on melpah also - -00:09:28.800 --> 00:09:29.519 -developed - -00:09:29.519 --> 00:09:32.959 -under the agpl license on github - -00:09:32.959 --> 00:09:36.080 -and disorganized thing by the way it's - -00:09:36.080 --> 00:09:37.839 -orig mode for mobile and desktop - -00:09:37.839 --> 00:09:39.839 -browsers also a great - -00:09:39.839 --> 00:09:42.399 -free software tool maybe that interests - -00:09:42.399 --> 00:09:43.120 -you - -00:09:43.120 --> 00:09:46.240 -thank you for listening have great time - -00:09:46.240 --> 00:09:48.800 -10 seconds left I am going to stop this - -00:09:48.800 --> 00:09:49.360 -now - -00:09:49.360 --> 00:09:53.920 -enjoy EmacsConf have a great day diff --git a/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.vtt b/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.vtt new file mode 100644 index 00000000..c453575d --- /dev/null +++ b/2020/subtitles/emacsconf-2020--25-traverse-complex-json-structures-with-live-feedback-counsel-jq--zen-monk-alain-m-lafon.vtt @@ -0,0 +1,553 @@ +WEBVTT + +00:00:00.799 --> 00:00:05.520 +Hello, everyone, and welcome to this +short lightning talk: + +00:00:05.520 --> 00:00:09.519 +"Traverse Complex JSON Structures with +Live Feedback." + +00:00:09.519 --> 00:00:18.000 +This is a pre-recorded talk and part of +the EmacsConf 2020 schedule. + +00:00:18.000 --> 00:00:19.439 +This is what we're going to do. + +00:00:19.439 --> 00:00:22.320 +I'll make a quick introduction to the +topic at hand. + +00:00:22.320 --> 00:00:24.400 +I'll give you a demonstration of some +tools, + +00:00:24.400 --> 00:00:29.199 +and then we'll leave you +with the links to said tools. + +00:00:29.199 --> 00:00:31.679 +Before that, just a little bit about me. + +00:00:31.679 --> 00:00:40.399 +I am the CEO and co-founder of a company +based in the Swiss mountains called 200ok.ch. + +00:00:40.399 --> 00:00:44.879 +We are a product incubator and +service consultancy, + +00:00:44.879 --> 00:00:50.000 +but we like to spend most or at least as +much time as we can + +00:00:50.000 --> 00:00:52.719 +building free software. + +00:00:52.719 --> 00:00:56.879 +I'm also an ordained Zen monk and abbot +of the Lambda Zen temple. + +00:00:56.879 --> 00:01:04.159 +You can reach me anytime on questions +regarding Emacs, for example, + +00:01:04.159 --> 00:01:07.200 +at alain@200ok.ch. + +00:01:07.200 --> 00:01:09.439 +But back to the topic at hand. + +00:01:09.439 --> 00:01:11.760 +The proposition is as following: + +00:01:11.760 --> 00:01:14.000 +most work on the computer is based on +either + +00:01:14.000 --> 00:01:16.479 +text processing or text consumption. + +00:01:16.479 --> 00:01:22.799 +And very often, the text which you need +to process is in a structured format, + +00:01:22.799 --> 00:01:24.560 +for example, in JSON. + +00:01:24.560 --> 00:01:28.560 +That might even be if your job is not +programming per se. + +00:01:28.560 --> 00:01:33.119 +Reading through such a bigger chunk of +JSON can be non-trivial, however, + +00:01:33.119 --> 00:01:36.479 +while just reading and understanding it + +00:01:36.479 --> 00:01:40.320 +will be essential to getting your job +done. + +00:01:40.320 --> 00:01:44.479 +So let's quickly check out an example +JSON file. + +00:01:44.479 --> 00:01:47.200 +This is from the Github API, + +00:01:47.200 --> 00:01:52.079 +which is a request--sorry, the +response to a request + +00:01:52.079 --> 00:01:54.640 +for a specific issue on the github API. + +00:01:54.640 --> 00:01:58.799 +So let's quickly check that one out. + +00:01:58.799 --> 00:02:01.920 +Okay. So here it is open, and we can +already see + +00:02:01.920 --> 00:02:05.439 +that there is lots of stuff +going on here. + +00:02:05.439 --> 00:02:07.360 +It's 200 lines. + +00:02:07.360 --> 00:02:09.200 +It's not going to be very easy + +00:02:09.200 --> 00:02:11.840 +just to find out what are the top level +things in here, + +00:02:11.840 --> 00:02:13.360 +what are the top level attributes. + +00:02:13.360 --> 00:02:17.840 +Of course I can do this, and maybe do it +by hand, but that doesn't scale. + +00:02:17.840 --> 00:02:21.599 +I can use cool Emacs facilities like the +hideshow-mode + +00:02:21.599 --> 00:02:24.720 +and try to fold all the things that are +top level, + +00:02:24.720 --> 00:02:27.200 +but that also doesn't really scale. + +00:02:27.200 --> 00:02:29.360 +There must be a better way. + +00:02:29.360 --> 00:02:32.000 +Of course there is. There is prior art. + +00:02:32.000 --> 00:02:34.080 +There is a tool called jq. + +00:02:34.080 --> 00:02:37.760 +I'm going to quote the USP (unique selling proposition) from their website: + +00:02:37.760 --> 00:02:42.000 +jq is like sed for JSON data. + +00:02:42.000 --> 00:02:46.319 +you can use it to slice and filter and +map and transform structured data + +00:02:46.319 --> 00:02:47.840 +with the same ease that + +00:02:47.840 --> 00:02:54.000 +sed, awk, grep, and friends let you +play with text. + +00:02:54.000 --> 00:02:56.879 +Let me give you a quick demonstration of +it. + +00:02:56.879 --> 00:02:59.040 +By the way, it's written in portable C. + +00:02:59.040 --> 00:03:03.519 +It has zero runtime dependency, so it's +very easy to get started with it + +00:03:03.519 --> 00:03:09.840 +and use it on pretty much any UNIX-based +computer. + +00:03:09.840 --> 00:03:14.000 +Sorry, no, Linux-based computer, +apologies. + +00:03:14.000 --> 00:03:18.720 +Okay, so let's explore a +JSON file with it. + +00:03:18.720 --> 00:03:20.000 +It's a command line tool, + +00:03:20.000 --> 00:03:24.000 +and it has a very simple command +line syntax. + +00:03:24.000 --> 00:03:29.840 +So you call the binary and then you give +it a query and a file, + +00:03:29.840 --> 00:03:32.560 +and then it will return its answer. + +00:03:32.560 --> 00:03:35.440 +So, for example, if I want the top +level keys, + +00:03:35.440 --> 00:03:38.000 +I will just say jq keys the file + +00:03:38.000 --> 00:03:39.840 +and it will return the keys. + +00:03:39.840 --> 00:03:44.400 +Simple as that. So let's check this out +in a real shell. + +00:03:44.400 --> 00:03:46.879 +Here I am in eshell. + +00:03:46.879 --> 00:03:51.440 +Let's run jq keys on the Github issue comment. + +00:03:51.440 --> 00:03:58.799 +We can see that we have actually +received a list back here + +00:03:58.799 --> 00:04:00.319 +with the top-level things. + +00:04:00.319 --> 00:04:02.879 +So this issue... It looks very interesting. + +00:04:02.879 --> 00:04:07.360 +Let's ask it to give me more information on this issue. + +00:04:07.360 --> 00:04:11.360 +Then it's hairy again. That's a lot of stuff. + +00:04:11.360 --> 00:04:14.560 +I mean, lucky for us, we are in Emacs here, + +00:04:14.560 --> 00:04:16.720 +so we can use nice shortcuts. + +00:04:16.720 --> 00:04:22.000 +We can copy this. We can go in here, just select that, + +00:04:22.000 --> 00:04:24.160 +get that out or something like this. + +00:04:24.160 --> 00:04:32.320 +But still, this is not really the best way to do that, right? + +00:04:32.320 --> 00:04:34.080 +it gets kind of tedious. + +00:04:34.080 --> 00:04:37.680 +At this point the output can be humongous. + +00:04:37.680 --> 00:04:41.919 +The shell is not really the best place to read through such big output. + +00:04:41.919 --> 00:04:45.759 +I mean, eshell is probably one of the better shells for this, + +00:04:45.759 --> 00:04:47.919 +because it's just a regular Emacs buffer, + +00:04:47.919 --> 00:04:50.720 +but still, it's not really the best tool. + +00:04:50.720 --> 00:04:53.680 +I need to repeat the command all the time + +00:04:53.680 --> 00:04:56.000 +until I finally build the right query. + +00:04:56.000 --> 00:04:59.840 +And all the time, I lose my focus, + +00:04:59.840 --> 00:05:02.800 +I lose what I'm currently looking at. + +00:05:02.800 --> 00:05:05.520 +I'm seeing the new result. + +00:05:05.520 --> 00:05:08.160 +It would be so much nicer to have live feedback. + +00:05:08.160 --> 00:05:10.720 +When working with Emacs, we're quite used to that. + +00:05:10.720 --> 00:05:12.320 +So there should be an option. + +00:05:12.320 --> 00:05:15.120 +And of course there is. It's Emacs, right, + +00:05:15.120 --> 00:05:17.759 +so you can do anything. + +00:05:17.759 --> 00:05:22.960 +There is various good tools for completion in Emacs. + +00:05:22.960 --> 00:05:26.000 +I used ivy for this. + +00:05:26.000 --> 00:05:29.039 +I'm going to quote the USP for ivy. + +00:05:29.039 --> 00:05:32.639 +ivy is a generic completion mechanism for Emacs. + +00:05:32.639 --> 00:05:37.919 +While it operates similarly to other completion schemes such as icomplete mode, + +00:05:37.919 --> 00:05:42.160 +ivy aims to be more efficient, smaller, simpler, and smoother to use, + +00:05:42.160 --> 00:05:45.199 +yet highly customizable. + +00:05:45.199 --> 00:05:46.479 +And that's true. + +00:05:46.479 --> 00:05:49.440 +One of the cool things of ivy + +00:05:49.440 --> 00:05:54.320 +compared to other completion mechanisms in Emacs + +00:05:54.320 --> 00:05:59.120 +is that it can be used on dynamic data. + +00:05:59.120 --> 00:06:02.400 +So usually completion works on a static input. + +00:06:02.400 --> 00:06:05.360 +For example, you're in a buffer, a text buffer, + +00:06:05.360 --> 00:06:09.600 +and you use isearch maybe with ido-mode, + +00:06:09.600 --> 00:06:13.360 +and you find your results. That's all nice. + +00:06:13.360 --> 00:06:19.600 +However, if I want to search on dynamic data, + +00:06:19.600 --> 00:06:20.720 +that doesn't work. + +00:06:20.720 --> 00:06:24.880 +So whenever I type in my query for jq, + +00:06:24.880 --> 00:06:28.000 +I actually need to call the jq binary, + +00:06:28.000 --> 00:06:30.720 +and it will give a different result set back. + +00:06:30.720 --> 00:06:36.160 +So it's a really dynamic mechanism that we need here. + +00:06:36.160 --> 00:06:38.240 +It's much more like a search engine. + +00:06:38.240 --> 00:06:41.440 +ivy luckily has something built in, + +00:06:41.440 --> 00:06:43.520 +and it's called counsel. + +00:06:43.520 --> 00:06:47.360 +So I used counsel and jq and combined them, + +00:06:47.360 --> 00:06:49.199 +and built a new package + +00:06:49.199 --> 00:06:52.960 +with which we can use Emacs and jq + +00:06:52.960 --> 00:06:56.000 +to have live feedback. + +00:06:56.000 --> 00:06:57.759 +It's very easy to use. + +00:06:57.759 --> 00:06:59.840 +So you just call counsel-jq + +00:06:59.840 --> 00:07:02.160 +on a buffer containing JSON. + +00:07:02.160 --> 00:07:04.319 +For example, the one we have here. + +00:07:04.319 --> 00:07:06.800 +Let's call counsel-jq on it, + +00:07:06.800 --> 00:07:10.080 +and we already get a default query, + +00:07:10.080 --> 00:07:14.639 +the dot query, which just gives us the same file. + +00:07:14.639 --> 00:07:16.240 +But now we can change it. + +00:07:16.240 --> 00:07:18.639 +For example, find all the keys in here. + +00:07:18.639 --> 00:07:20.319 +And then we see I had this issue. + +00:07:20.319 --> 00:07:22.800 +This was the one that we were interested in. + +00:07:22.800 --> 00:07:25.599 +So let's find more information on the issue. + +00:07:25.599 --> 00:07:28.720 +What keys does it have actually have? + +00:07:28.720 --> 00:07:31.680 +It has assignees. That interests me. + +00:07:31.680 --> 00:07:34.800 +So let's check out the assignees in here. + +00:07:34.800 --> 00:07:39.759 +There's two of them, but I'm only interested in the first one. + +00:07:39.759 --> 00:07:43.599 +I'm making stuff up as I go here, of course. + +00:07:43.599 --> 00:07:47.039 +Whenever I hit enter, I get a new buffer + +00:07:47.039 --> 00:07:52.639 +which just shows me this particular result + +00:07:52.639 --> 00:07:55.599 +for the particular query that I entered. + +00:07:55.599 --> 00:07:57.680 +So let me do that again. + +00:07:57.680 --> 00:08:04.000 +We are in here. We are looking at a JSON file. + +00:08:04.000 --> 00:08:05.840 +This can be very, very big. + +00:08:05.840 --> 00:08:07.280 +Doesn't also need to be a file. + +00:08:07.280 --> 00:08:09.520 +Just needs to be a buffer. + +00:08:09.520 --> 00:08:11.360 +You call counsel-jq on it, + +00:08:11.360 --> 00:08:14.319 +and you can do any kind of query on it. + +00:08:14.319 --> 00:08:18.080 +For example, let's see if there is a URL here. + +00:08:18.080 --> 00:08:19.440 +Yes, there's a URL. + +00:08:19.440 --> 00:08:22.827 +Let's see if there's a repository here. + +00:08:22.827 --> 00:08:24.639 +Repository. No, there isn't. + +00:08:24.639 --> 00:08:33.440 +What was it called? Issue. Keys. Repository URL, it was called. + +00:08:33.440 --> 00:08:38.240 +So let's see issue repository URL, + +00:08:38.240 --> 00:08:39.519 +and then we see. + +00:08:39.519 --> 00:08:44.800 +So apparently this issue comment is for a repository called organice. + +00:08:44.800 --> 00:08:47.839 +I wonder what that might be. + +00:08:47.839 --> 00:08:52.640 +Okay. So that was a very short introduction to counsel-jq. + +00:08:52.640 --> 00:08:54.240 +You can see the timer here. + +00:08:54.240 --> 00:08:57.440 +I only have one minute left to go, so I'm going to leave + +00:08:57.440 --> 00:09:02.880 +with a very, very short introduction to the counsel-jq code. + +00:09:02.880 --> 00:09:06.000 +It's not even 60 lines of elisp, + +00:09:06.000 --> 00:09:09.600 +so building something like this is very, very easy. + +00:09:09.600 --> 00:09:14.560 +I would encourage you to go and read through the code in your own time, + +00:09:14.560 --> 00:09:17.519 +if you're interested in building something like this. + +00:09:17.519 --> 00:09:22.720 +If you're interested in just using jq or you're done, + +00:09:22.720 --> 00:09:24.320 +these are the links to all the tools. + +00:09:24.320 --> 00:09:28.240 +counsel-jq, of course, is readily available on MELPA. + +00:09:28.240 --> 00:09:32.959 +Also developed under the AGPL license on Github. + +00:09:32.959 --> 00:09:36.080 +And this organice thing, by the way, it's + +00:09:36.080 --> 00:09:38.560 +Org Mode for mobile and desktop browsers. + +00:09:38.560 --> 00:09:43.120 +Also a great free software tool maybe that interests you. + +00:09:43.120 --> 00:09:46.240 +Thank you for listening. Have a great time. + +00:09:46.240 --> 00:09:49.360 +10 seconds left. I am going to stop this now. + +00:09:49.360 --> 00:09:53.920 +Enjoy EmacsConf. Have a great day. -- cgit v1.2.3