summaryrefslogtreecommitdiffstats
path: root/2026/info/babel-after.md
blob: 48d2820a31b25b95e81f0f20ed4f88851cbb3982 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!-- Automatically generated by emacsconf-publish-after-page -->


<div class="transcript transcript-mainVideo"><a name="babel-mainVideo-transcript"></a><h1>Transcript</h1>


<div class="transcript-heading">[[!template new="1" text="""Introduction""" start="00:00:00.480" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""Alright, we have a lot to get through and not a""" start="00:00:00.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""whole lot of time, so I'm just going to preface""" start="00:00:02.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the talk by saying all the materials I use will""" start="00:00:03.900" video="mainVideo-babel" id="subtitle"]]
[[!template text="""be available on the talk page at emacsconf\.org\.""" start="00:00:05.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I also encourage you to stop and pause the talk""" start="00:00:07.940" video="mainVideo-babel" id="subtitle"]]
[[!template text="""so you can try the demos at home, and of course""" start="00:00:10.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""you can ask questions after the talk\.""" start="00:00:11.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Alright, let's get into it!""" start="00:00:14.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Alright, so Org babel is a very powerful system for""" start="00:00:17.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""literate programming\.""" start="00:00:19.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""There is extensive language support,""" start="00:00:21.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we can make our code more flexible through the""" start="00:00:23.980" video="mainVideo-babel" id="subtitle"]]
[[!template text="""usage of header arguments and variables,""" start="00:00:25.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we can use noweb syntax to dovetail functions,""" start="00:00:27.780" video="mainVideo-babel" id="subtitle"]]
[[!template text="""even those written in different languages,""" start="00:00:30.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and we can also use TRAMP to execute source""" start="00:00:32.860" video="mainVideo-babel" id="subtitle"]]
[[!template text="""blocks on remote machines\.""" start="00:00:35.080" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""What happens when we want to use Org babel with a language that's not supported by default?""" start="00:00:37.540" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""What happens when we want to use Org babel with a""" start="00:00:37.540" video="mainVideo-babel" id="subtitle"]]
[[!template text="""language that's not supported by default?""" start="00:00:39.160" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Hmm, no <i>org-babel-execute</i> function for Zig\.""" start="00:00:41.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Well, we could write our own ob-zig\.el, but that""" start="00:00:44.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""would bring our \.emacs\.d 100 lines closer to""" start="00:00:46.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;Emacs bankruptcy&quot;,""" start="00:00:48.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and it would also add a dependency to this""" start="00:00:49.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Org mode document: if you don't have ob-zig,""" start="00:00:51.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""you can't execute the source block\.""" start="00:00:53.740" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So, in today's talk, I'm going to show you how to""" start="00:00:55.560" video="mainVideo-babel" id="subtitle"]]
[[!template text="""define an arbitrary &quot;runnable&quot;""" start="00:00:57.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""that not only allows you to recover the""" start="00:00:59.020" video="mainVideo-babel" id="subtitle"]]
[[!template text="""functionality of <i>org-babel-execute-src-block</i>,""" start="00:01:01.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""but do so much more by having an arbitrary""" start="00:01:03.540" video="mainVideo-babel" id="subtitle"]]
[[!template text="""function on some source code—""" start="00:01:05.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""that could be compiling and running, but it could""" start="00:01:06.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""also be other stuff\.""" start="00:01:08.360" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Version information""" start="00:01:10.280" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""So, before we get into things, I do just want to""" start="00:01:10.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""clarify that I'm using a pretty tricked out""" start="00:01:12.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""personal build of Emacs and also tecosaur's fork of""" start="00:01:13.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Org mode\.""" start="00:01:16.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""But everything I talk about in today's talk you""" start="00:01:17.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""can use in a version of Emacs from probably the""" start="00:01:19.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""past 5 years or so\.""" start="00:01:21.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So not to worry, you can run everything at home\.""" start="00:01:23.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(You will need some external packages like, for example, Zig\.)""" start="00:01:25.640" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""The technique""" start="00:01:29.420" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""Ok, so here's the technique: it's literally just""" start="00:01:29.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""one line of ELisp\.""" start="00:01:32.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I like to call this &quot;block-code&quot;\.""" start="00:01:33.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So, what's going on here?""" start="00:01:35.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""<i>org-babel-expand-noweb-references</i>, and""" start="00:01:36.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""then <i>org-babel-lob--src-info</i>\.\.\.""" start="00:01:39.160" video="mainVideo-babel" id="subtitle"]]
[[!template text="""all this is doing is taking the name of an""" start="00:01:40.700" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Org babel block, and it's returning the content of""" start="00:01:43.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the source code of that block\.""" start="00:01:46.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""We will use this using Org's CALL keyword:""" start="00:01:48.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we have some runnable code block, we use""" start="00:01:51.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;block-code&quot;, and then we pass in the name""" start="00:01:53.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""of the code block we want to execute\.""" start="00:01:54.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""That's all a little bit abstract, so I think it's""" start="00:01:57.100" video="mainVideo-babel" id="subtitle"]]
[[!template text="""easier to show than tell\.""" start="00:01:58.880" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Here I have some ELisp test block, just counts""" start="00:02:00.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the number of lines in my narrowed buffer\.""" start="00:02:02.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Obviously I can press <b>C-c C-c</b> like I just did,""" start="00:02:06.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""but for the sake of demonstration, let's use""" start="00:02:08.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""a runnable\.""" start="00:02:10.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So here I have &quot;eval&quot;, that just evaluates a string""" start="00:02:10.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""as an S-expression, and here I have &quot;eval&quot;,""" start="00:02:13.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;block-code&quot;, &quot;elisp-test&quot;\.""" start="00:02:16.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So I put my point over this line, I press <b>C-c C-c</b>,""" start="00:02:17.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and as you can see I get the same thing\.""" start="00:02:21.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So that might be a little underwhelming, we just""" start="00:02:23.220" video="mainVideo-babel" id="subtitle"]]
[[!template text="""accomplished the same thing as ob-elisp\.el""" start="00:02:25.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""but with extra steps\.""" start="00:02:27.500" video="mainVideo-babel" id="subtitle"]]
[[!template text="""But in the coming examples I'm going to show, I think""" start="00:02:28.740" video="mainVideo-babel" id="subtitle"]]
[[!template text="""you will find that &quot;block-code&quot; is small""" start="00:02:30.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""but mighty\.""" start="00:02:32.920" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Budget ob-LANG""" start="00:02:34.780" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""Ok, so let's return to the example of Zig from""" start="00:02:34.780" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the beginning\.""" start="00:02:37.220" video="mainVideo-babel" id="subtitle"]]
[[!template text="""As a reminder, we cannot use""" start="00:02:37.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""<i>org-babel-execute-src-block</i> on this\.""" start="00:02:39.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Down here I define a runnable which is only""" start="00:02:41.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""4 lines of code""" start="00:02:44.140" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(in fairness, Zig is pulling a lot of weight for us here),""" start="00:02:45.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and I'm defining this in Bash\.""" start="00:02:47.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""You can use things other than Bash and ELisp,""" start="00:02:48.940" video="mainVideo-babel" id="subtitle"]]
[[!template text="""anything supported by Org babel by default, but I""" start="00:02:52.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""would encourage you to use ELisp or Bash""" start="00:02:54.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""because it's the most portable\.""" start="00:02:56.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So we call this down here, and\.\.\.""" start="00:02:58.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""here we go, we get &quot;Hello, world!&quot;""" start="00:03:00.730" video="mainVideo-babel" id="subtitle"]]
[[!template text="""One thing I want to mention is that we're""" start="00:03:02.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""actually redirecting stderr to stdout, and that's""" start="00:03:03.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""not a generally desirable thing to do, that might""" start="00:03:06.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""actually be kind of annoying to do with a""" start="00:03:08.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""normal Org babel flow,""" start="00:03:10.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""but because this is an ad-hoc runnable—""" start="00:03:12.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it doesn't need to be the most general, it just""" start="00:03:14.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""needs to fit our use case—""" start="00:03:16.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we can just add this in\.""" start="00:03:18.150" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Again, that's kind of a recurring theme for this""" start="00:03:19.180" video="mainVideo-babel" id="subtitle"]]
[[!template text="""talk, molding Org babel to fit your use case,""" start="00:03:21.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""even if it's not the most general thing in the world\.""" start="00:03:24.520" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Library of Babel""" start="00:03:27.330" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""Alright, so the next thing I want to talk about""" start="00:03:27.330" video="mainVideo-babel" id="subtitle"]]
[[!template text="""is Library of Babel, and to do that I have some""" start="00:03:28.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""code blocks, these are actually from the Org""" start="00:03:31.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""document I use for job applications/cover letters""" start="00:03:32.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and stuff like that,""" start="00:03:34.780" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and this is a little more involved than""" start="00:03:36.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;block-code&quot;, but it's doing the same thing in spirit—""" start="00:03:38.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""you can see right here I've got the same thing in spirit\.""" start="00:03:40.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""But I'm doing some additional introspection using""" start="00:03:44.100" video="mainVideo-babel" id="subtitle"]]
[[!template text="""ELisp to pass variables to this inner code block,""" start="00:03:46.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and what I want to show here is""" start="00:03:51.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""—let me tangle this real quick—""" start="00:03:52.980" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I have some file example\.org,""" start="00:03:55.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""which has a block named &quot;lorem-letter&quot;, and here""" start="00:03:56.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""in my other file, org_babel_everywhere\.org, I can""" start="00:03:59.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""actually use &quot;lorem-letter&quot;, I can reference it""" start="00:04:02.880" video="mainVideo-babel" id="subtitle"]]
[[!template text="""by prepending the file name to it,""" start="00:04:06.020" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;lorem-letter:example\.org&quot;\.""" start="00:04:07.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So I press <b>C-c C-c</b> here\.\.\. and I open this up, and""" start="00:04:09.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we have some lorem ipsum stuff in the file\.""" start="00:04:13.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So this is a pretty cool technique, that I can""" start="00:04:17.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""use Org babel's Library of Babel functionality\.""" start="00:04:19.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I will say, there is a feature where you can add""" start="00:04:21.820" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Org files to your personal &quot;Library of Babel&quot;""" start="00:04:24.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and then reference them without prepending the filename\.""" start="00:04:25.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I'm personally not such a big fan of this because""" start="00:04:28.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it makes it harder for someone else to run the""" start="00:04:30.640" video="mainVideo-babel" id="subtitle"]]
[[!template text="""same Org document on their machine\.""" start="00:04:32.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""But maybe it could be useful if you have some""" start="00:04:34.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""company-wide Emacs config, that everyone has the""" start="00:04:36.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""same setup everywhere\.""" start="00:04:39.440" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Examples""" start="00:04:42.120" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""We'll get onto the examples\.""" start="00:04:42.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I just want to emphasize that all of these examples""" start="00:04:43.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""are real use cases I've actually used,""" start="00:04:45.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and none of them are contrived\.""" start="00:04:47.120" video="mainVideo-babel" id="subtitle"]]
[[!template text="""The first one is micro VMs, this is an excerpt""" start="00:04:49.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""from a kernel pwn writeup I made about a year ago\.""" start="00:04:51.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(I'm just switching the version of Zig that's in my <b>$PATH</b>\.)""" start="00:04:54.860" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So, this is some kernel exploit""" start="00:04:57.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(the code is not important, just the context is),""" start="00:05:00.640" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it's a vulnerable x86 Linux kernel module\.""" start="00:05:02.780" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So I'm going to call this runnable""" start="00:05:07.160" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;pawny-run-exploit&quot;\.""" start="00:05:09.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Ok, we have uid=1337, some stuff,""" start="00:05:10.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""then we get root, that's generally a good""" start="00:05:13.660" video="mainVideo-babel" id="subtitle"]]
[[!template text="""sign for kernel pwn\.""" start="00:05:14.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Just to prove there's no movie magic, let's add a""" start="00:05:16.980" video="mainVideo-babel" id="subtitle"]]
[[!template text="""compile error here\.""" start="00:05:19.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Ok, so we get the error in our *Org-Babel Error Output*""" start="00:05:21.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""buffer, just as we'd expect\.""" start="00:05:23.700" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And also, we can also add""" start="00:05:25.700" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;kernel base are belong to us&quot;\.""" start="00:05:27.710" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Run this again—""" start="00:05:32.020" video="mainVideo-babel" id="subtitle"]]
[[!template text="""sorry, still have &quot;foobar&quot; here—""" start="00:05:33.830" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and we will see output reflected here\.""" start="00:05:38.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So what's actually happening?""" start="00:05:41.940" video="mainVideo-babel" id="subtitle"]]
[[!template text="""For the sake of time, I'm going to give a very""" start="00:05:43.160" video="mainVideo-babel" id="subtitle"]]
[[!template text="""high level play-by-play\.""" start="00:05:45.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So &quot;pawny-compile-exploit&quot;, it's cross-compiling""" start="00:05:47.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""our block of code to x86_64-linux""" start="00:05:50.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(I'm currently on aarch64-darwin),""" start="00:05:53.750" video="mainVideo-babel" id="subtitle"]]
[[!template text="""then &quot;pawny-run-command&quot;:""" start="00:05:56.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""ok, so this is going to regenerate an initramfs,""" start="00:05:57.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it's going to include the exploit we just compiled,""" start="00:06:01.160" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it also, based on some Org babel variable,""" start="00:06:04.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it will change the init shell to be run""" start="00:06:06.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""as root or an unprivileged user, which is really""" start="00:06:09.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""useful for debugging a kernel exploit\.""" start="00:06:11.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Then we're going to run a QEMU micro VM over here,""" start="00:06:13.740" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and we're actually communicating bidirectionally with""" start="00:06:17.900" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the shell in the VM and the Bash process running""" start="00:06:20.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""this Org babel code block with the power of""" start="00:06:23.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Unix sockets and socat\.""" start="00:06:25.320" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And then we're sending some <b>$shellcmd</b>\.""" start="00:06:26.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And then down here, this is an ELisp block I'm using to""" start="00:06:29.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""clean up the output using Org babel's""" start="00:06:31.720" video="mainVideo-babel" id="subtitle"]]
[[!template text=""":post header argument\.""" start="00:06:33.620" video="mainVideo-babel" id="subtitle"]]
[[!template text="""That's just to get rid of ANSI control codes and""" start="00:06:34.820" video="mainVideo-babel" id="subtitle"]]
[[!template text="""boot logs and stuff like that\.""" start="00:06:36.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So, this is a pretty nice workflow!""" start="00:06:38.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I actually used this to solve this challenge, and""" start="00:06:40.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""we also get all the trimmings of Org mode:""" start="00:06:43.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I can use noweb syntax, I can reverse tangle and then I""" start="00:06:45.820" video="mainVideo-babel" id="subtitle"]]
[[!template text="""can use LSP in a proper zig-mode buffer,""" start="00:06:49.660" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I can also use Org export and I can export this code""" start="00:06:52.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and the results to a PDF or a website\.""" start="00:06:56.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I used ox-hugo to export this exact writeup""" start="00:07:00.580" video="mainVideo-babel" id="subtitle"]]
[[!template text="""to my website\.""" start="00:07:03.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Overall, just a really cool technique\.""" start="00:07:04.560" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And again, to remind you: I can send this Org""" start="00:07:06.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""document to you, and you can run the exact same""" start="00:07:09.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""thing on base Emacs""" start="00:07:10.620" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(with no extra ELisp packages)\.""" start="00:07:12.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""You will obviously need QEMU and Zig to run this""" start="00:07:13.840" video="mainVideo-babel" id="subtitle"]]
[[!template text="""stuff, but yeah, that's pretty cool\.""" start="00:07:16.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""For the next example, I thought if I can talk to""" start="00:07:20.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""a VM over socat, why not do the same thing using""" start="00:07:22.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""the rich functionality of Emacs core?""" start="00:07:25.840" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Serial""" start="00:07:27.560" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""So I made this little interactive serial REPL,""" start="00:07:27.560" video="mainVideo-babel" id="subtitle"]]
[[!template text="""which again, doesn't require any external functionality,""" start="00:07:30.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it's all in ELisp—30-odd lines of ELisp—""" start="00:07:32.340" video="mainVideo-babel" id="subtitle"]]
[[!template text="""which is pretty impressive for something like this\.""" start="00:07:36.150" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I actually have a board on my desk, I'm doing""" start="00:07:39.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""bring-up on this RISC-V board\.""" start="00:07:40.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So I'm going to CALL this runnable, and it will""" start="00:07:42.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""wait until it hits a U-Boot prompt\.\.\.""" start="00:07:46.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Let me turn on the board\.\.\.""" start="00:07:49.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""and there we go, we""" start="00:07:52.500" video="mainVideo-babel" id="subtitle"]]
[[!template text="""have in our buffer &quot;Pretty cool, huh?&quot;\.""" start="00:07:53.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I also added a feature""" start="00:07:56.260" video="mainVideo-babel" id="subtitle"]]
[[!template text="""to give me an interactive terminal—""" start="00:07:58.860" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it will open the serial device in a term-mode buffer""" start="00:08:01.200" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So, that's pretty neat\.""" start="00:08:05.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(I'll turn this off so the fan doesn't annoy me\.)""" start="00:08:08.860" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Again, I just want to emphasize, this doesn't""" start="00:08:14.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""have to be the most general runnable of all time,""" start="00:08:16.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it really just has to fit my use case\.""" start="00:08:18.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I actually did use this to bring up this RISC-V""" start="00:08:19.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""board, it was really useful because""" start="00:08:22.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""when you're debugging a kernel panic, you don't have a""" start="00:08:23.780" video="mainVideo-babel" id="subtitle"]]
[[!template text="""userspace and therefore no TRAMP\.""" start="00:08:25.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Ok, the last example I want to talk about is""" start="00:08:27.800" video="mainVideo-babel" id="subtitle"]]
[[!template text="""about higher order functions\.""" start="00:08:29.560" video="mainVideo-babel" id="subtitle"]]
[[!template text="""If we're passing around code blocks as values,""" start="00:08:30.600" video="mainVideo-babel" id="subtitle"]]
[[!template text="""naturally you might think of something like map""" start="00:08:32.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""as a higher order function\.""" start="00:08:34.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""The details I'm going to gloss over because we're""" start="00:08:36.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""short on time, but down here I have this &quot;map&quot;\.""" start="00:08:40.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I'm mapping the above code block over my 3""" start="00:08:43.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""most recent TRAMP machines\.""" start="00:08:45.680" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So it's going to open this stuff\.\.\.""" start="00:08:49.280" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it's taking a little bit to think\.\.\.""" start="00:08:51.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I will emphasize, the things you pass in, it's""" start="00:08:53.920" video="mainVideo-babel" id="subtitle"]]
[[!template text="""just a list-of-lists where each child list is the""" start="00:08:56.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""list of header arguments you pass to the""" start="00:08:58.440" video="mainVideo-babel" id="subtitle"]]
[[!template text="""source block\.""" start="00:08:59.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So here I'm mapping over :dir, but you could just as""" start="00:09:00.740" video="mainVideo-babel" id="subtitle"]]
[[!template text="""easily map over :results, :var, whatever\.""" start="00:09:03.380" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And then I have some :post header argument to""" start="00:09:08.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""make the table look nice\.""" start="00:09:10.540" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Parallel map""" start="00:09:12.880" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""I want to briefly talk about &quot;parallel map&quot;,""" start="00:09:12.880" video="mainVideo-babel" id="subtitle"]]
[[!template text="""a little experiment I did to try and use Emacs's""" start="00:09:14.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""multithreading feature to speed up map\.""" start="00:09:16.520" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Unfortunately, it only works with ELisp,""" start="00:09:18.980" video="mainVideo-babel" id="subtitle"]]
[[!template text="""it doesn't work with any external processes\.""" start="00:09:20.620" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Probably not too useful, but maybe someone out""" start="00:09:22.400" video="mainVideo-babel" id="subtitle"]]
[[!template text="""there will find it interesting\.""" start="00:09:24.280" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Tagle map""" start="00:09:26.700" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""The last thing I want to talk about is &quot;tangle map&quot;\.""" start="00:09:26.700" video="mainVideo-babel" id="subtitle"]]
[[!template text="""This is essentially mapping a cat runnable over a""" start="00:09:29.720" video="mainVideo-babel" id="subtitle"]]
[[!template text="""file, but you can use this in conjunction with""" start="00:09:33.240" video="mainVideo-babel" id="subtitle"]]
[[!template text="""&quot;map&quot; to get a kind of devops workflow\.""" start="00:09:35.740" video="mainVideo-babel" id="subtitle"]]
[[!template text="""(I have to type in my auth-source password for my password-store password\.)""" start="00:09:42.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I'm tangling this to /var/run, so that requires root,""" start="00:09:47.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""which is why I need to add my password\.""" start="00:09:49.360" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Just to prove that's actually there\.\.\.""" start="00:09:51.060" video="mainVideo-babel" id="subtitle"]]
[[!template text="""So yeah, that's another pretty interesting""" start="00:10:04.420" video="mainVideo-babel" id="subtitle"]]
[[!template text="""thing you can do\.""" start="00:10:06.080" video="mainVideo-babel" id="subtitle"]]
[[!template text="""And then if we're talking about map, of course we have fold\.""" start="00:10:07.340" video="mainVideo-babel" id="subtitle"]]
[[!template text="""I guess I did not load ob-python, but that's not""" start="00:10:13.140" video="mainVideo-babel" id="subtitle"]]
[[!template text="""too important\.""" start="00:10:16.000" video="mainVideo-babel" id="subtitle"]]
[[!template text="""But fold works the same way as map, pretty much\.""" start="00:10:16.480" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Maybe you could fold a code block multiple times""" start="00:10:20.500" video="mainVideo-babel" id="subtitle"]]
[[!template text="""to take some benchmarking statistics\.""" start="00:10:23.240" video="mainVideo-babel" id="subtitle"]]

<div class="transcript-heading">[[!template new="1" text="""Conclusion""" start="00:10:26.040" video="mainVideo-babel" id="subtitle"]]</div>[[!template new="1" text="""So that brings me to the end of my talk\.""" start="00:10:26.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""If you take away one thing, I just want to""" start="00:10:27.880" video="mainVideo-babel" id="subtitle"]]
[[!template text="""emphasize that you can use a tiny bit of ELisp""" start="00:10:29.540" video="mainVideo-babel" id="subtitle"]]
[[!template text="""to augment the already very powerful capabilities of""" start="00:10:31.540" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Org babel\.""" start="00:10:33.960" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Whether your document is a research paper, blog post,""" start="00:10:34.760" video="mainVideo-babel" id="subtitle"]]
[[!template text="""homework assignment, whatever: I encourage""" start="00:10:37.040" video="mainVideo-babel" id="subtitle"]]
[[!template text="""you to get creative and bend Emacs to your will\.""" start="00:10:38.880" video="mainVideo-babel" id="subtitle"]]
[[!template text="""Happy hacking!""" start="00:10:41.880" video="mainVideo-babel" id="subtitle"]]

</div>

Captioner: George Huebner

Questions or comments? Please e-mail [george@feyor.sh](mailto:george@feyor.sh?subject=Comment%20for%20EmacsConf%202023%20babel%3A%20Org%20Babel%20everywhere)


<!-- End of emacsconf-publish-after-page -->