|
Running executable notes from http://angg.twu.net/ with find-angg and find-wget
This video explains how people can run my executable notes without downloading anything by (re)defining the
functions "find-angg" and "find-es" in the right way.
If you can only watch one minute from it, then watch the demo
of Maxima that starts at 15:14.
To watch the minute in which I explain how the
redefinion works, go to 11:30.
You can read the subtitles of the video here.
If you like to watch videos with subtitles in high
speed, then run the two "wget"s below to download a local copy
and the "mpv" to play it:
To make a long story short, on my machine these
sexps
open this section of my notes on Maxima.
The sexps above are equivalent to this one,
(find-fline "~/e/maxima.e" "«2021-2-C3-diag-nums»")
|
that opens the file ~/e/maxima.e and goes to the section
"2021-2-C3-diag-nums" in it, by searching for the first occurrence of
the string "«2021-2-C3-diag-nums»" - an anchor - in that file. I
upload to http://angg.twu.net/e/ pratically all the files with
executable notes that are in the directory ~/e/ of my machine, and so
you can access the copy of my file ~/e/maxima.e in http://angg.twu.net/e/ using a browser, or using the functions find-wget or find-wgeta of eev, that "download a URL to stdout"
and show the output of that in a temporary buffer.
The main theme of the video is that we can run `M-x
find-angg-es-links', or this sexp,
to redefine find-angg and find-es to make them use find-wgeta.
This is explained in the video starting at 11:30; if we run `M-x
find-angg-es-links' we get a temporary buffer with lots of
instructions and two executable blocks, and the first one
of them (re)defines find-angg and find-es in a way that only works on
my machine, and the second one (re)defines find-angg and find-es in
way that uses find-wgeta.
Some of my executable notes need very little setup to run. In all
the examples of the video I use the same block of executable notes,
that only needs Maxima installed - so the setup is just this (on
Debian):
sudo apt-get install maxima
|
To watch the video in .mp4 click on the first thumbnail below.
To watch the minute in which I explain the redefinitions, click on the second thumbnail.
To watch a demo of eepitch-maxima, click on the third thumbnail.
Index of the video (elisp here, full subtitles below, or in in this other page):
0:00
0:21 http://angg.twu.net/eev-find-angg.html
0:39 the image is the cover of my favorite CD
0:56 http://angg.twu.net/e/
1:24 .e and .e.html
2:52 if I open a .e in the browser
3:19 if we download a copy of a .e with wget
3:29 run wget in way that sends the page to stdout
3:47 (find-wget "http://angg.twu.net/e/maxima.e")
3:52 the buffer name is "*wget: URL*"
3:56 this doesn't show the command-line arguments of wget
4:07 you can see that the «»s and the •s look right
4:24 (find-fline "~/e/maxima.e")
5:02 these three sexps are more or less equivalent
5:12 when we call find-angg and find-es with extra args
5:29 if we run find-fline with an extra argument
5:52 if we run find-angg with an extra argument
6:12 it searches for the first occurrence of that anchor
6:30 it points to this example here
6:38 if we type f8 here several times
7:10 then I'm going to run plot2d
7:20 and here I'm going to run plot3d
7:36 these files are on my machine
7:40 but you can use this long URL
8:06 the #2021-2-C3-diag-nums points to this anchor
8:22 (find-wget "...e.html")
8:33 then wget downloads the html file
8:48 (find-wgeta "...e")
9:03 the "a" in "find-wgeta" means
9:10 to look for the first occurrence of this anchor
9:30 note that this is a temporary buffer
9:41 by typing f8 several times
9:50 if I type f8s here, in this temporary buffer
10:20 these are my notes on a specific thing
10:40 this is what I meant by the title
10:54 Let me now show something else.
11:02 I showed that when we run find-angg
11:11 and this thing looks for the first anchor
11:30 But here is a trick.
11:30 (find-angg-es-links)
11:32 if you're not on my machine
11:40 a temporary buffer with lots of instructions
11:49 this first block explains
12:14 this second block explains
12:24 this progn will redefine find-angg and find-es
12:32 in ways that use find-wgeta to download
12:44 and if there are extra arguments
12:59 let me explain what I mean by other strings
13:10 if I add this "Sejam" to the sexp
13:35 Anyway, let me go back.
13:41 if we run this progn in the second block
14:05 if we run this it redefines find-angg and find-es
14:12 now find-angg runs find-wgeta to download
14:30 this is a temporary buffer
14:47 searches for this anchor here
14:57 this find-es doesn the same thing
15:14 and we can run this eepitch-maxima (again)
15:37 My notes are very hyperlinked
16:04 you'll be able to use them outside of my machine
16:14 because you'll replace find-angg and find-es
16:26 in this way you can follow links like this
16:32 for example, if we're chatting on IRC
17:00 this is an easy way to run examples
17:07 In many cases my executable notes
17:07 do not need any installation
17:18 this case only needs Maxima
Here are the full subtitles:
00:00 Hi! My name is Eduardo Ochs...
00:02 I'm the author of an Emacs package called
00:04 eev, and the main idea behind eev is that
00:08 you can save executable notes
00:11 for everything that you do
00:13 and you can share these notes with
00:14 other people... possibly by
00:17 putting your notes on the web.
00:21 All the material about this video
00:24 is going to be in this page here,
00:27 and the title of this video is:
00:29 "Running executable notes from
00:31 [my home page, which is this one]
00:33 with `find-angg' and `find-wget'.
00:37 Let me explain what this means.
00:39 Oh, by the way, by the way -
00:41 this image is totally unrelated
00:44 to the presentation, it is just
00:46 one of my favorite CDs ever.
00:49 Let me use a smaller font here.
00:51 These are the things
00:53 that I'm going to present.
00:56 I put all my executable notes on the web.
01:00 Practically everything - I mean, there's
01:03 just a couple of files that I don't put there.
01:06 Most of my notes are in these files with
01:09 .e at the end, in this directory here...
01:12 if we visit this directory -
01:16 let's wait one second, because it needs
01:18 to open Google Chrome...
01:20 We see that it contains many, many,
01:22 many files...
01:24 some of them end with just .e, and
01:28 some of them end with .e.html,
01:31 and the ones with .e.html are
01:35 converted versions....
01:37 We can see this header here,
01:39 that explains that this is
01:41 an htmlized version...
01:44 and here you have a link to the original
01:47 version without the .html...
01:50 and here you have a very messy page
01:53 explaining the conversion rules.
01:57 One second, let me go back...
02:04 So, I'm going to show how to execute
02:14 executable notes from my site, and I'm
02:17 going to use one specific example that
02:19 is in my notes about Maxima.
02:22 Maxima is a program for
02:26 doing symbolic computation, and
02:28 numeric computation, and graphics, and
02:30 lots of things from Mathematics,
02:33 and my day job is as a teacher of
02:37 Mathematics, and so I've been using
02:39 Maxima a lot...
02:41 I started using it a few months ago
02:45 and I'm finding it really fascinating.
02:51 So, my notes are in this file here...
02:57 if we open it in the browser we are
03:00 going to see that it has
03:01 some strange characters here...
03:05 my site doesn't even recognize that this
03:08 thing is UTF-8, and so some characters
03:12 look really wrong...
03:15 but if we run... if we download
03:19 a copy of this with wget
03:22 everything looks right...
03:28 Actually I'm going to do something
03:29 different - I'm going to run wget to
03:35 download a copy of this thing
03:38 in a way that sends the output to
03:41 the standard output, and I'm going to put
03:43 this output in a temporary buffer.
03:47 So, this sexp does that...
03:50 it takes a few seconds,
03:52 and then it downloads this file here -
03:54 you can see here the command - more or
03:57 less the command that was run...
03:59 this is an abbreviation, because it
04:02 doesn't say exactly the command line
04:04 arguments that were used...
04:07 but you can see that
04:10 these characters appear right,
04:13 the red stars also appear
04:16 in the right way, and so on...
04:20 and note that when I'm in my machine I
04:28 can access the local copy of this file
04:30 with this sexp here...
04:35 this other sexp here is an abbreviation
04:37 for the previous one...
04:40 so this one essentially runs the same thing,
04:42 it adds a "~/" to the beginning...
04:47 and this third one is an abbreviation
04:50 for this one... it takes this string,
04:52 and it adds a "~/e/"
04:58 to the beginning, and a ".e" to the end.
05:01 So all these three are more or less
05:04 equivalent, but there's a detail here.
05:09 When we call these two sexps here
05:12 with other arguments these arguments are
05:19 interpreted as the tags in anchors.
05:22 So, if I run this...
05:27 if I run just this -
05:30 let me make a copy here -
05:32 if I run just this...
05:34 this argument here says that
05:38 we need to start at the beginning of the
05:40 file and then look for the first
05:41 occurrence of this string,
05:44 and it is here on line 112...
05:50 and if we run this other sexp here,
05:54 with `find-angg'...
05:59 this thing here is converted to an anchor,
06:03 with these characters here
06:06 at the beginning and at the end...
06:10 and this sexp searches for the first
06:12 occurrence of that anchor in the file -
06:15 so it goes to this section here.
06:18 And this is the example that I'm going
06:21 to show in a few seconds.
06:25 This other one is equivalent, it's an
06:27 even shorter form of this one...
06:32 so it points to this example here...
06:35 and let me show what this example does.
06:38 If we type `f8' here several times
06:41 the `f8's on the lines that start with red
06:44 stars will set up a target buffer here,
06:47 running Maxima...
06:51 here we just got a new
06:54 Maxima session, here...
06:57 and the `f8's on lines that do not
06:59 start with red stars
07:01 will send these lines to Maxima,
07:03 and Maxima will run each of them.
07:06 So: here I'm doing some tests, then I'm
07:09 going to define a few functions...
07:11 then I'm going to run plot2d,
07:14 that shows a two-dimensional plot
07:17 of one of the functions that I've
07:19 defined... and then here I run plot3d,
07:23 that runs...
07:25 that displays a 3D plot that I can
07:30 rotate in several ways.
07:35 So: these files are on my machine,
07:40 and in principle if you want to find
07:44 these notes at the internet you need to
07:47 visit this thing here on the browser...
07:51 note that this anchor here...
07:54 ah, sorry...
07:55 this anchor here is in green, which is a
07:59 convention that I use to indicate that
08:02 this thing here was converted to an
08:04 anchor...
08:05 so, this "#2021-2-C3-diag-nums" etc
08:14 points exactly to this anchor...
08:17
08:22 If we run either this or this...
08:28 this `find-wget' here, or the second one...
08:31 we get...
08:34 the wget downloads the html file,
08:39 which is not exactly what we want,
08:41 because it has these headers here...
08:43 it has some things that for humans
08:45 are usually garbage...
08:49 but if I run this `find-wgeta' here
08:52 it will download the
08:56 copy of this thing here, which is the
08:58 version without the .html, the version
09:00 that is not converted to html...
09:03 and the `a' here means to...
09:07 look in this temporary buffer -
09:10 in the temporary buffer with the output
09:11 of wget - for the first occurrence of this
09:14 anchor here...
09:16 so let's test...
09:19 It opens the output of wget, blah blah
09:22 blah, of this file with maxima.e at
09:25 the end, not maxima.e.html, and it
09:28 opens this section here...
09:31 note that this is a temporary buffer,
09:34 we haven't downloaded a copy
09:37 of this maxima.e...
09:41 but even with this being a temporary
09:44 buffer we can execute these things
09:47 by just typing `f8' several times...
09:50 so if I type `f8's here...
09:52 - in this temporary buffer!!!
09:55 this is not a file!!!... -
09:57 the first three `f8's
10:00 create a Maxima session here, and then
10:04 the other `f8's send commands here...
10:07 and this command here shows a nice 2D plot,
10:13 and this one shows a very nice 3D plot.
10:17
10:20 So these are my notes on a specific
10:24 thing on Maxima, a demo of
10:28 how a function looks...
10:31 and you can run this demo without
10:37 having to to download this file,
10:40 and this is what I mean with the title...
10:45 this is a way to run my executable notes
10:47 from my site
10:50 with `find-wget'.
10:54 Let me now show something else.
10:59 I showed that when I run this
11:02 I run something that opens the
11:06 local copy of this file...
11:08 it opens this file here -
11:10 and when I run this thing here I open
11:13 this local file and I look for
11:16 the first anchor with this thing
11:19 between the double angle brackets...
11:29 But here is a trick.
11:31 if you are not on my machine you can use
11:34 this thing, (find-angg-es-links),
11:37 to make `find-angg' behave in another way.
11:41 This thing here will create a temporary
11:43 buffer with lots of instructions and
11:46 executable things...
11:48 and this first block
11:50 explains that this `progn' here
11:56 is how I define `find-angg' and `find-es'
12:00 on my machine to point to local files...
12:06 and here's a comment about how this
12:08 thing searches for anchors, and so on...
12:14 and this second section here
12:19 explains that in this `progn' here...
12:23 I mean, sorry...
12:25 if we run this `progn' here it will
12:28 redefine `find-angg' and `find-es'
12:31 in ways that use `find-wgeta'
12:34 to download these files with wget
12:37 into temporary buffers...
12:40 and if there are extra arguments
12:48 here, like anchors, and other
12:51 strings, and so on...
12:53 this function will search for that
12:55 anchor and the other strings after that.
12:59 Let me first explain what I mean by
13:02 other strings... If I execute this
13:05 the `find-wgeta' searches for this anchor,
13:10 and if I add this to the sexp...
13:15 this is a word in Portuguese, "Sejam"...
13:18 it means "let"... then this sexp here will
13:22 first search for an anchor with this name
13:28 and then for the first occurrence
13:30 of the word "Sejam" after that...
13:32 so it goes to this position.
13:34
13:36 Anyway, let me go back.
13:39 We were here, and the thing is that
13:42 if we run this `progn' here
13:44 it will run these two `defun's,
13:46 that will redefine `find-angg' and `find-es'
13:50 in a certain way, and after running
13:52 these `defun's, `find-angg'
13:55 will run `find-wgeta' with the right arguments,
14:00 and `find-es' will run `find-wgeta' with the
14:03 right arguments...
14:06 so if we run this
14:08 we redefine `find-angg' and `find-es'...
14:12 and now if we run, for example,
14:15 this sexp here, it will run wget,
14:19 it will download this URL here,
14:25 and spit the output to the
14:28 standard output, and `find-wget'
14:31 will show that in the temporary
14:33 buffer, and in this case this thing will
14:35 search for the first occurrence of this
14:38 anchor in this file.
14:40 So: this is a temporary buffer with a copy
14:43 of this file from my site...
14:46 and this `find-angg' searches for
14:51 this anchor here...
14:56 and this `find-es' here does the same
15:00 thing, it's just a bit shorter...
15:04 so it runs `find-wget' in a
15:07 certain way and searches for
15:09 this anchor here...
15:14 and then we can run this thing here...
15:16 let me run it again just because it's
15:19 nice -
15:21 Here we have a 2D plot, and here we
15:24 have our 3D plot, that we can rotate
15:29 in very nice ways, blah blah blah...
15:32
15:37 So... my notes are very hyperlinked,
15:43 with lots of links like this one,
15:46 that points to
15:47 another file in this directory here...
15:52 and to a certain section... oops,
15:56 usually to sections in these files,
15:58 using anchors...
16:00 and if you run this block here
16:08 you'll be able to use these things
16:10 even without being in my machine,
16:14 because you'll replace the definitions of
16:16 `find-angg' and `find-es' by things that
16:21 download local copies and show them in
16:23 temporary buffers...
16:25 and in this way
16:28 you can follow links like this,
16:30 to examples, and...
16:32 for example, if you're chatting
16:35 with me on IRC I can just send you a
16:38 link like this, to show, for example,
16:40 how I do something in Maxima...
16:44 and you can run this to
16:47 download the local copy, show it in a
16:49 temporary buffer, and then you can
16:51 execute this to run the example.
16:59 So this is an easy way to run examples
17:04 without having to download anything,
17:07 and in many cases my
17:11 executable notes do not need any
17:13 installation,
17:15 they just need you to have
17:17 some program installed...
17:18 in this case you just need to
17:20 have Maxima installed -
17:22 usually something like this will do
17:24 the job: "sudo apt-get install maxima"
17:28 this will probably install everything
17:31 that you need to run this specific example.
17:35 Yeah, so that's it! That's what I
17:38 wanted to show... this page does not exist
17:40 yet, but it's going to exist in,
17:42 I guess, one hour or so...
17:45 and there you're going to
17:47 have notes like this and you'll
17:50 be able to try some sexps like this, and
17:53 see if you can run the examples...
17:55 and that's it! That's what I wanted to
17:57 show. Bye! =)
|