Mike Gerwitz

Free Software Hacker+Activist

aboutsummaryrefslogtreecommitdiffstats
blob: 6916c384a9ad7b690ecc011384648d3d3e81ee7c (plain)
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
#+startup: beamer
#+TITLE: Computational Symbiosis: Methods That Meld Mind and Machine
#+AUTHOR: Mike Gerwitz
#+EMAIL: mtg@gnu.org
#+DATE: LibrePlanet 2019
#+BEAMER_HEADER: \title{Computational Symbiosis}
#+BEAMER_HEADER: \subtitle{Methods That Meld Mind and Machine}
#+OPTIONS: H:3 num:nil toc:nil p:nil todo:nil stat:nil
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [presentation]
#+BEAMER_THEME: Madrid
#+BEAMER_COLOR_THEME: beetle
#+BEAMER_HEADER: \input{slides-preamble.tex}
#+TODO: DEVOID(v) LACKING(l) RAW(r) DRAFT(d) AUGMENT(A) REVIEWED(R) | READY(,) REHEARSED(.)
#+COLUMNS: %40ITEM %10DURATION{:} %8TODO %BEAMER_ENV(ENVIRONMENT)

* About                                                            :noexport:
This file represents the source code for the slides for my LibrePlanet 2019
talk, as well as the notes containing the text I originally intended to
say.  There are a few things to note:

- The notes are not /necessarily/ an intended transcript.  As it tends to
  be, when I'm in the moment, I may decide to do things slightly differently
  and adapt to the audience.  I may also forget something and end up having
  to restructure what I was going to say.

- This notes have not been updated to include what I did actually say.  I
  hope to provide a transcript in the future.

- The checklists contain my original intent for this talk; I didn't purge
  what I didn't get to.  The talk was simplified quite a bit from what I was
  originally planning on presenting just in case the audience wasn't
  technical, but I didn't want to simplify it too much in case the audience
  was full of hackers.

- See [[*Exporting]] for information on how to build the slides.

* Project Notes                                                    :noexport:
** Core Guidelines
- Blur distinction between user and programmer.
- Use only examples that non-programmers could come up with and understand.
- GUIs /are/ sometimes the most efficient means of melding mind and machine.
  - De-emphasize doing everything on a terminal just because its "cool".

** Concepts [15/27]
- [ ] =/sys= and such
- [ ] Automating multi-step workflows with GNU Make
- [X] Concurrency ([[*Program Composition]])
- [X] Connecting graphical and command line (X11 integration) [4/4]
  - [X] Clipboard (image) ([[*More Examples]])
  - [X] Clipboard (text) ([[*Program Composition]])
  - [X] X11 commands
  - [X] Interesting example idea: =import=, =tesseract ss.png - | xsel -ib=
        so that you can select an area of text on the screen and perform
        OCR, then have the result on your clipboard ([[*More Examples]])
    - I've never done this, but it goes to show how trivial it is to
      create something that is seemingly novel.
- [ ] Discoverability
  - Example: I used GIMP for editing some images for this talk because I
    thought it'd be faster to discover how to that way vs. ImageMagick docs.
- [ ] Editor should keep up with your thoughts
  - Emphasize muscle memory
- [-] Efficiency gains of light use of keybindings [2/3]
  - [X] Seldom change ([[*Browser Topics][Browser Topics]])
  - [X] Some are universal (between programs) ([[*Browser Topics][Browser Topics]])
  - [ ] Some context-sensitive and Just Work without having to hunt through
        context-specific menus
- [ ] Emphasize free software community and how OS is built by so many
      contributors
  - Symbiosis is not only with machine, but community
- [X] Globbing
- [X] GnuPG and smart cards ([[*More Examples]])
- [X] Incremental, iterative, interactive development ([[*Program Composition]])
- [X] Looping ([[*Perspective Topics][Perspective Topics]])
- [ ] McIlroy and Knuth
- [X] Mouse has dependency on positioning of UI elements ([[*Browser Topics][Browser Topics]])
  - Changes over time, subject to user/system preferences, etc
- [ ] Multiplexing with GNU Screen
- [X] Output redirection ([[*A New Perspective]])
- [ ] Phone as an example of a device that best works with touch and GUIs
      and sacrifices practical freedom.
  - Requires specialized knowledge and is inconvenient to work with.
- [X] Pipelines instead of intermediate files ([[*Perspective Topics][Perspective Topics]]).
- [X] Practically exercising software freedom [2/2]
  - [X] Users need to be able to convey their thoughts to the computer
      without being programmers
  - [X] Concise primitives / building blocks
- [ ] Readline (history and editing) [0/2]
  - [ ] Develop as you go, perhaps just referencing history early on
  - [ ] Transfer commands from history into scripts and aliases for re-use
- [X] Regular expressions ([[*Perspective Topics][Perspective Topics]])
- [X] Remote commands via SSH
- [X] Text as a universal interface
  - [X] All programs can work with one-another ([[*Perspective Topics][Perspective Topics]])
  - [X] Can replace any part of the process with a human---no difference
        between input from a program vs. from a keyboard. ([[*Browser Topics][Browser Topics]])
- [X] The Unix Philosophy ([[*Perspective Topics][Perspective Topics]])
- [X] Using keybindings in a GUI with no mouse ([[*Browser Topics][Browser Topics]])
  - Including transferring data between programs
- [ ] Using macros to script keypresses (Vim)
- [ ] Version control

** Programs [0/4]
- [-] Coreutils / Common [12/15]
  - [X] =cut=
  - [ ] =column=
  - [ ] =diff=
  - [X] =echo=
  - [X] =find=
  - [X] =gpg=
  - [X] =grep=
  - [ ] =make= / Makefiles
  - [X] =man= and =info=
  - [X] =sort=
  - [X] =ssh=
  - [X] =uniq=
  - [X] =watch=
  - [X] =wc=
  - [X] =wget= / =curl=
- [-] Miscellaneous [5/8]
  - [ ] =awk=
  - [X] =cowsay= / =figlet=
  - [ ] =dict=
  - [X] =espeak=
  - [ ] =git=
  - [X] =mail=
  - [X] =torify=
  - [X] =sed=
- [-] X11 / Graphical [3/5]
  - [X] =convert=
  - [ ] =i3= / =xmonad= / etc
  - [X] =import=
  - [ ] =setxkbmap=
  - [X] =xclip= / =xsel=
- [ ] Editors / Multiplexing [0/4]
  - [ ] =emacs=
  - [ ] =nano=
  - [ ] =vim=
  - [ ] =screen=

* REHEARSED Slides [5/5]
:PROPERTIES:
:ID:       slides
:END:
** Summary                                                        :noexport:
#+BEGIN: columnview :hlines 2 :maxlevel 3 :indent t :id slides
  | ITEM                                                  | DURATION | TODO      | ENVIRONMENT |
  |-------------------------------------------------------+----------+-----------+-------------|
  | Slides                                                |  0:39:53 | REHEARSED |             |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  Summary                                           |          |           |             |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  Introduction                                      |  0:01:24 | REHEARSED |             |
  | \_    Spoken Intro                                    |  0:00:25 | REHEARSED | note        |
  | \_    Choreographed Workflows                         | 00:00:20 | REHEARSED | fullframe   |
  | \_    Practical Freedom                               |  0:00:40 | REHEARSED | fullframe   |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  Practical Example: Web Browser                    |  0:06:34 | REHEARSED |             |
  | \_    Browser Topics                                  |          |           |             |
  | \_    Example: Web Browser                            |  0:00:10 | REHEARSED | frame       |
  | \_    Finding Text (Mouse-Driven GUI Interaction)     |  0:01:00 | REHEARSED | frame       |
  | \_    GUIs Change Over Time                           |  0:00:45 | REHEARSED | frame       |
  | \_    Muscle Memory                                   |  0:00:40 | REHEARSED | fullframe   |
  | \_    A Research Task                                 |  0:00:20 | REHEARSED | fullframe   |
  | \_    Executing the Research Task                     |  0:02:05 | REHEARSED | frame       |
  | \_    GUIs of a Feather                               |  0:00:35 | REHEARSED | fullframe   |
  | \_    Macro-Like Keyboard Instructions                |  0:01:00 | REHEARSED | fullframe   |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  A New Perspective                                 |  0:12:48 | REHEARSED |             |
  | \_    Perspective Topics                              |          |           |             |
  | \_    Secrets?                                        |  0:00:55 | REHEARSED | fullframe   |
  | \_    Lifting the Curtain                             |  0:00:35 | REHEARSED | frame       |
  | \_    Text                                            |  0:00:35 | REHEARSED | fullframe   |
  | \_    Text is a Universal Interface                   |  0:01:10 | REHEARSED | fullframe   |
  | \_    The Shell Command Prompt                        |  0:00:55 | REHEARSED | frame       |
  | \_    Eliminating the Web Browser                     |  0:01:04 | REHEARSED | frame       |
  | \_    Browser vs. =wget= Comparison                   |  0:00:20 | REHEARSED | frame       |
  | \_    Finding Text on the Command Line                |  0:01:00 | REHEARSED | frame       |
  | \_    A More Gentle Reply                             |  0:01:00 | REHEARSED | frame       |
  | \_    Writing to Files (Redirection)                  |  0:00:55 | REHEARSED | frame       |
  | \_    Starting Our List                               |  0:01:00 | REHEARSED | fullframe   |
  | \_    Command Refactoring                             |  0:02:05 | REHEARSED | fullframe   |
  | \_    Again: Text is a Universal Interface            |  0:00:20 | REHEARSED | againframe  |
  | \_    Pipelines                                       |  0:00:15 | REHEARSED | fullframe   |
  | \_    Summary of the Unix Philosophy                  |  0:00:40 | REHEARSED | fullframe   |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  Program Composition                               |  0:09:15 | REHEARSED |             |
  | \_    Composition Topics                              |          |           |             |
  | \_    LP Sessions                                     |  0:02:30 | REHEARSED | fullframe   |
  | \_    Interactive, Incremental, Iterative Development |  0:01:10 | REHEARSED | fullframe   |
  | \_    Discovering URLs                                |  0:02:15 | REHEARSED | fullframe   |
  | \_    Go Grab a Coffee                                |  0:00:15 | REHEARSED | fullframe   |
  | \_    Async Processes                                 |  0:00:45 | REHEARSED | fullframe   |
  | \_    Executable Shell Script and Concurrency         |  0:01:30 | REHEARSED | fullframe   |
  | \_    Execution Time                                  |  0:00:50 | REHEARSED | frame       |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  More Examples                                     |  0:09:52 | REHEARSED |             |
  | \_    More Example Topics                             |          |           |             |
  | \_    Resize Images                                   |  0:00:30 | REHEARSED | frame       |
  | \_    Password Generation                             |  0:00:45 | REHEARSED | frame       |
  | \_    Password Manager                                |  0:01:39 | REHEARSED | frame       |
  | \_    Remote Password Manager With 2FA                |  0:01:30 | REHEARSED | frame       |
  | \_    Taking Screenshots                              |  0:00:35 | REHEARSED | frame       |
  | \_    Screenshot OCR                                  |  0:01:00 | REHEARSED | frame       |
  | \_    Full Circle                                     |  0:02:24 | REHEARSED | fullframe   |
  | \_    Getting Help                                    |  0:01:30 | REHEARSED | frame       |
  |-------------------------------------------------------+----------+-----------+-------------|
  | \_  Thank You                                         | 00:00:01 |           | fullframe   |
#+END:

** REHEARSED Introduction [3/3]
*** REHEARSED Spoken Intro                                         :B_note:
:PROPERTIES:
:BEAMER_env: note
:DURATION: 0:00:25
:END:

Hello, everyone!

My name is Mike Gerwitz.
I am a free software hacker and activist with a focus on user privacy and
  security.
I'm also a GNU Maintainer and volunteer.
I have about twenty years of programming experience,
  half of that professionally.

And I've been a computer user for longer.
So I've been around long enough to see a decent evolution in how we interact
  with machines.


*** REHEARSED Choreographed Workflows                         :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:DURATION: 00:00:20
:END:

#+BEAMER: \fullslidetext
Choreographed Workflows

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:END:

What we have tended toward over the years are interfaces that try to cater
  to as many people as possible by providing carefully choreographed
  workflows that think /for/ you.
And I don't deny that this has been a useful method for making computers
  accessible to huge numbers of people.
But it's important to understand where this trend falls short.


*** REHEARSED Practical Freedom                               :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Practical Freedom

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:40
:END:

This is a talk about /practical/ freedoms---an
  issue separate from but /requiring/ software freedom.
If developers are thinking /for/ us and guiding us in our computing,
  then we're limited to preconceived workflows.
This leaves immense power in the hands of developers even if software is
  free,
    because average users are stuck asking them to implement changes,
      or footing the bill for someone else to do so.

My goal here is to blur those lines between ``user'' and ``programmer'' and
  show you how users can be empowered to take control of their computing in
  practical and powerful ways.
But it does require a different way of thinking.

To begin,
  let's start by exploring something that I think most people can relate to
    using.


** REHEARSED Practical Example: Web Browser [8/8]
*** Browser Topics [3/3]                                         :noexport:
This example is the main segue from GUIs into the utility of keybindings
into shell, so it has to be compelling.  I chose something that is
frequently done by users: visiting webpages and searching for text.

- [X] Most webpages include styling, images, and other media that are best
      represented in a GUI.
  - Of course, I'm a firm believer in progressive enhancement, but this
    isn't a web development talk.
- [X] Is it good for finding a word or phrase on a page? [4/4]
  - [X] Menu -> Find in This Page -> Type.  Sure.
  - [X] Instructing a user how to do this is inherently visual.  Comment on
        my need to highlight areas of screenshots.
  - [X] More experienced users may prefer =C-f=.
    - Emphasize the motion with my hand.  Explain how that mental association
      is made.  Really focus on this.
  - [X] Location of menu has changed over time (show screenshots), but =C-f=
        has been unchanged for decades.
- [X] What if I had a list of five webpages and I wanted to get rid of the
      ones that didn't have that word? [4/4]
  - [X] Mouse and GUI way:
    - Open each page in a new tab.
    - Menu -> Find on page -> Type.
    - Found, copy URL, open a word processor, paste.
    - Go back, click X on the tab.
    - Repeat.
  - [X] Then show keybinding way:
    - *Demonstrate this on the LP laptop.*
    - Open programs with =M-F2=
    - Open each page in a new tab (=C-t=)
    - =C-f ESC=
    - =C-l C-c=
    - =M-TAB C-v RET=
    - =M-TAB C-w=
    - Repeat
  - [X] This would work with nearly /any/ combination of web browser and
        text editor.
  - [X] But what if I had 10?  100?  1000?  This is still tedious and slow.

*** REHEARSED Example: Web Browser                                :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

[[file:images/web-browser.png]]

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:10
:END:

The only GUI I use on a day-to-day basis is my web browser.
In this case,
  GNU Icecat,
    which is a Firefox derivative.
This is a screenshot of an admittedly staged session,
  and contains a number of addons.

*** REHEARSED Finding Text (Mouse-Driven GUI Interaction)         :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

**** Images                                                    :B_columns:
:PROPERTIES:
:BEAMER_env: columns
:END:

***** Left                                                     :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.30
:END:

#+ATTR_LATEX: :width 1.5in
[[file:images/ff-find-menu.png]]

***** Right                                                    :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.70
:END:

#+ATTR_LATEX: :width 3in
[[file:images/ff-find-matches.png]]

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

A common operation is to search for a word or phrase,
  like shown here.

Now,
  how exactly to do this with a mouse varies depending on what browser
    you're using,
      but here I highlighted the steps in a modern IceCat or Firefox.
You start by clicking on the little hamburger, hotdog, or
  whatever-you-want-to-call-it menu in the upper-right,
    and then click on "Find in This Page" within the popup.
This then opens a bar at the bottom of the page with an area to type the
  word or phrase you're searching for.
It highlights and scrolls to the first match as you type,
  and has a button to highlight all results.
It also shows the number of results off to the right.
It's a simple,
  yet powerful mechanism that is pretty easy to use.

Is this an efficient means to communicate your intent?
If you're just searching for a name or concept,
  sure,
  it's not so bad.

But notice how I had to convey these steps to you.
I had to take screenshots and highlight where to click with the mouse.
Since a GUI is inherently very visual,
  so are the instructions on how to use it.
There is no canonical representation for these instructions,
  because it involves clicking on elements that have no clear name to the
    user.

*** REHEARSED GUIs Change Over Time                               :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:
**** Images :B_columns:
:PROPERTIES:
:BEAMER_env: columns
:END:

***** Left                                                     :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.50
:END:

#+ATTR_LATEX: :width 1.5in
[[file:images/ff-find-menu.png]]

***** Right                                                    :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.50
:END:

#+ATTR_LATEX: :width 1.5in
[[file:images/ff-edit-find.png]]

#+BEAMER: \uncover<2>{\Large
Ctrl+F
#+BEAMER: }

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:45
:END:

Another difficult thing is: GUIs change over time.
I'm sure many people here remember earlier versions of Firefox that didn't
  have the hamburger menu,
    where the Find menu option was in the Edit menu.
Those old menus do still exist if you hit Alt.
I miss the old menus.
Saying "Go to Edit - Find" is pretty clear,
  and those menu positions were always in the same place across the entire
  desktop environment.
Now individual programs may vary in the their user experience.

But do you notice something in common between these two screenshots?
There's something that /hasn't/ changed over time---something
  that has been the same for /decades/!
=Ctrl+F=.

When you type =Ctrl+F=,
  it immediately opens that search bar and gives focus to the textbox,
    so you can just start typing.

*** REHEARSED Muscle Memory                                   :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Muscle Memory

#+BEAMER: \fullsubtext
Visual \Rightarrow Tactile


**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:40
:END:

With a mouse and a GUI,
  interaction is driven by visual indicators.
The position of your hand on the mousepad or your fingers on a touchpad
  isn't meaningful,
    because your mouse cursor could be anywhere on the screen at any given
      time;
        your /eyes/ provide the context.

But by hitting =Ctrl+F=,
  we have switched our mode of interaction.
It's now /tactile/.
You associate a finger placement;
  a motion;
  and the feeling of the keys being pressed beneath your fingers
    with an action---finding
      something.
You develop muscle memory.

/<Repeatedly make motion with hand and fingers like a madman during the
  above paragraph.>/

*** REHEARSED A Research Task                                 :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Research Task:

#+BEAMER: \fullsubtext
Given a list of webpage URLs
#+BEAMER: \smallsubskip
find all that /do not/ contain ``free software''

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:20
:END:

Let's explore a fairly simple research task together.
Let's say I email you a handfull of URLs---maybe
  5 or 10 of them---that
  are articles about software or technology.
And I want you to come up with a list of the webpages that /do not/ contain
  the phrase ``free software'' so that I can get a better idea of ones to
  focus my activism on.

How might we approach this problem as an average user?

*** REHEARSED Executing the Research Task                         :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

**** Approaches                                                :B_columns:
:PROPERTIES:
:BEAMER_env: columns
:END:

***** Mouse                                                    :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.50
:END:

_Mouse_

1. Click `+' for each new tab, enter\nbsp{}URL
2. Menu \rightarrow Find in This Page
3. Type ``free software''
4. If found, go to #9
5. If /not/ found, highlight URL, right-click, copy
6. Click on text editor
7. Right-click, paste URL, hit =RET= for newline
8. Click on web browser
9. Click `X' on tab, go to #2

******* Notes                                                :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:15
:END:

/(Perhaps I should demonstrate this right away rather than reading through
the list first, to save time?)/

Let's first use the mouse as many users probably would.
To set up,
  let's open each URL in a new tab.
We click on the little `+' icon for a new tab and then enter the URL,
  once for each webpage,
  perhaps copying the URL from the email message.
Once we're all set up,
  we don't care about the email anymore,
  but we need a place to store our results,
  so we open a text editor to paste URLs into.

Now, for each tab,
  we click on the little hamburger menu,
  click on ``Find in This Page'',
  and then type ``free software''.
If we /do not/ see a result,
  we move our mouse to the location bar,
  click on it to highlight the URL,
  right-click, copy,
  click on the text editor to give it focus,
  right-click on the editor, ``Paste'',
  and then hit the return key to move to the next line.
We then go back to the web browser.
If we /do/ see a result,
  we skip copying over the URL.
In either case,
  we then close the tab by clicking on the `X'.

And then we repeat this for each tab,
  until they have all been closed.
When we're done,
  whatever is in our text editor is the list of URLs of webpages that do not
  reference ``free software'',
    and we're done.

Simple enough,
  right?
But it's a bit of a pain in the ass.
All this clicking around doesn't really /feel/ like we're melding mind and
  machine, does it?

What if we used our =Ctrl+F= trick?
That saves us a couple clicks,
  but can we do better?

***** Keyboard                                                 :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.50
:END:

#+BEAMER: \uncover<2>{
_Keyboard_

1. *=Ctrl+T=* for each new tab, enter\nbsp{}URL
2. *=Ctrl+F=* to find
3. Type ``free software''
4. If found, go to #9
5. If /not/ found, *=Ctrl+L Ctrl+C=* to copy URL
6. *=Alt+Tab=* to text editor
7. *=Ctrl+V RET=* to paste URL and add newline
8. *=Alt+Tab=* to web browser
9. *=Ctrl+W=* to close tab, go to #2
#+BEAMER: }

******* Notes                                                :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:50
:END:

Fortunately we have /many/ more keybindings at our disposal!

We'll start with opening each new tab with =Ctrl+T= instead of clicking on
  `+' with the mouse.
/(Maybe show copying the URL from the email without the mouse?)/

To open our text editor,
  we'll use =Alt+F4=.

Once we're all set up,
  we start with the first tab and use =Ctrl+F= as we've seen before,
  and then type ``free software''.
If we /do not/ find a match,
  we're ready to copy the URL.
Hitting =Ctrl+L= will take us to the location bar and highlight the URL.
We can then hit =Ctrl+C= to copy the URL to the clipboard.
=Alt+Tab= to go to our text editor.
We then paste with =Ctrl+V= and hit return to insert a newline.
We can then go back to the web browser by hitting =Alt+Tab= again.
We then close the tab with =Ctrl+W=.

Repeat, and we're done all the same as before.
As a bonus,
  save with =Ctrl+S=.

What's interesting about this approach is that we didn't have to use the
  mouse at all,
    unless maybe you used it to highlight the URL in the email.
You could get into quite the rhythm with this approach,
  and your hands never have to leave the keyboard.
This is a bit of a faster,
  more efficient way to convey our thoughts to the machine,
    right?
We don't have to seek out our actions each time in the GUI---the
  operations are always at our fingertips,
    literally.

*** REHEARSED GUIs of a Feather                               :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Same Keybindings Across (Most) GUIs!

#+BEAMER: \fullsubtext
Browser, Editor, Window Manager, OS, \ldots

**** Notes :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:35
:END:

Another powerful benefit of this approach is---these
  /same exact keybindings work across most GUIs/!
If we switch out Icecat here with nearly any other major web browser,
  and switch out gedit with many other text editors or even word processors,
  this will work all the same!

If you use Windows instead of GNU/Linux---which
  I strongly discourage, but if you do---then
  it'll work the same.

Certain keybindings are ubiquitous---if
  you hit =Ctrl+F= in most GUI programs that support searching,
    you'll get some sort of context-specific search.

Let's look at those keybindings a bit more concisely,
  since that last slide was a bit of a mess.

*** REHEARSED Macro-Like Keyboard Instructions                :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \begingroup\fullslidetext
Macro-Like
#+BEAMER: \endgroup\subskip

#+BEGIN_SRC
Ctrl+T ``https://...'' <N times>

Ctrl+F ``free sofware''
[ Ctrl+L Ctrl+C Alt+Tab Ctrl+V RET Alt+Tab ]
Ctrl+W
<N times>
#+END_SRC

- <2> /Requires visual inspection/ for conditional
- <2> Still manual and tedious---what if there were 1000 URLs?

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

If we type out the keybindings like this,
  it looks a bit more like instructions for the machine,
    doesn't it?
Some of you may be familiar with macros---with
  the ability to record keypresses and play them back later.
If we were able to do that,
  could we automate this task away?

Unfortunately...no.
At least,
  not with the tools we're using right now.
Why is that?

Well,
  for one,
  it requires visual inspection to determine whether or not a match has
    occurred.
That drives conditional logic---that
  bracketed part there.
We also need to know how many times to repeat,
  which requires that we either count or watch the progress.
And we need to be able to inspect the email for URLs and copy them into the
  web browser.

This also scales really poorly.
While using the keyboard is certainly faster than using the mouse,
  we're only dealing with a small set of URLs here.
What if I gave you 100 of them?
1000?
More?
Suddenly this doesn't feel like a very efficient way to convey our intent to
  the machine.
I don't wish that suffering upon anyone.

To get around that,
  we need to change how we think about our computing a bit.

** REHEARSED A New Perspective [15/15]
*** Perspective Topics [13/13]                                   :noexport:
- [X] What if I could walk away and get a coffee, play with the kids,
      come back and have it done for me?
  - Emphasize how users familiar with the tools I haven't yet mentioned
    may know how to do this, but people who don't know of Unix tools
    will still be thinking in terms of the UI, trying to figure out how
    to automate it.
- [X] Right-click on page and inspect an element.
  - Briefly mention DOM and how this represents the current state of
    the page.
  - Maybe show how it can be modified to illustrate the structure better.
    - But I don't want to get too deep into this.
- [X] Right-click on page and View Source.
  - Explain how this is like the source code to the webpage (HTML).
- [X] Copy text into editor, =C-f=.
  - We can still find the text /using the same keybinding/.
- [X] Save HTML file.
- [X] Demonstrate opening it in a web browser vs. an editor.
  - Same exact document, different ways of rendering it.
- [X] Open a terminal [4/4]
  - [X] Type =wget URL=
  - [X] Show how it downloaded a file
  - [X] Open it in a text editor, show how the text is there.  =C-f=.
    - We eliminated the web browser
  - [X] =grep word file.html=
    - We have just eliminated =Ctrl+F= in the editor.
- [X] But it's too verbose, so show =grep -q && echo=.
  - Talk about echo and exit status briefly, but don't go into exit codes.
- [X] The goal is to output a URL to a file
  - Introduce redirection (overwrite and append)
- [X] Now we have duplication: URL in two places
  - Introduce variables
- [X] Eliminate the temporary file entirely using a pipe
- [X] Alias =fetch-url= for =wget -qO-=.
- [X] Introduce the Unix philosophy

*** REHEARSED Secrets?                                        :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

# Slide intentionally left blank

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:55
:END:

So what if I told you that I could go grab some coffee and play with my kids
  and come back later to a list that has been generated for me by an
  automated process?
And what if I told you that it'd only take a minute or two to for me to
  create this process?
And that you don't need to be a programmer to do it?

Well if I told you that then you'd be pretty pissed at me for sending you
  1000 URLs.
So I would never do that.

This is where the whole concept of ``wizardry'' comes in.
Some of you are sitting in the audience or watching this remotely rolling
  your eyes thinking ``oh this guy thinks he's so sweet'',
    because the answer is obvious to you.
But to those of you who are confined to the toolset that I just
  demonstrated...it's
    /not/ going to be obvious.

The problem is that there is a whole world and way of computing that is
  hidden from most users.
And it's not hidden because it's a secret.
It's because modern interfaces have come to completely mask it or provide
  alternatives to it that happen to be ``good enough'' for a particular use
  case.

But ``good enough'' is only good enough until it's not,
  until you need to do something /outside/ of that preconceived workflow.

*** REHEARSED Lifting the Curtain                                 :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

**** Columns                                                   :B_columns:
:PROPERTIES:
:BEAMER_env: columns
:END:

***** Left                                                     :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.30
:END:

[[file:images/ff-view-source-menu.png]]

***** Right                                                    :B_column:
:PROPERTIES:
:BEAMER_env: column
:BEAMER_col: 0.70
:END:

[[file:images/ff-view-source.png]]

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:35
:END:

Let's lift the curtain,
  so to speak,
  on what's really going on in the web browser.

Right-click on the webpage and select "View Page Source" from the
  context menu.
You get a new tab containing the raw code behind the document.
Most of it, anyway.
It is a document language called HTML.
And as you may have noticed,
  it's plain text.
Structured, but plain, text.

And as you can see,
  if we hit =Ctrl+F=,
  ``free software'' is there all the same.
We don't need to view the webpage with all its fancy formatting.
For the problem we're trying to solve,
  the graphical representation provides little benefit.

*** REHEARSED Text                                            :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Text.

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:35
:END:

As we're about to see,
  this simple fact---that
    that the webpage is represented by plain text---opens
    up a whole new world to us.
We have stripped away all the complex visual GUI stuff and we're left with
  the raw substance of the page which still contains the information that we
  are looking for.

But we're still within the web browser.

We don't have to be.
We can copy all of that text and paste it into our editor.
=Ctrl+A Ctrl+C Alt-Tab Ctrl+V=.
And sure enough,
  search works all the same.
=Ctrl+F= and we can still find ``free software''.
Completely different program,
  and we can still find the text using the same keybinding.

*** REHEARSED Text is a Universal Interface                   :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Text is a Universal Interface

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:10
:END:

Text is a universal interface.
And what I mean by that is---you
  don't need any special tools to work with it.
You can view it in your web browser.
You can view it in your text editor.
You can paste it in a text message.
You can print it in a book.
You can write it down on a paper and type it back into your computer.

Text is how we communicate with one-another as human beings.

Let's save this HTML as a file,
  =speakers.html=.

If we opened this file,
  it would open in our web browser and we would see the same webpage,
    although it would look a bit different since a lot of the styling is
      stored outside of this HTML file.

But if again we opened this HTML file in our text editor,
  you would see that same plain text HTML as before;
    one program just chooses to render it differently than another.

Even though we can view the HTML in our text editor,
  we haven't yet eliminated the web browser;
    we still need it to navigate to the webpage and view its source.
But if that's all we're using the web browser for,
  then it's one hell of an inefficient way of telling the computer that we
  just want the HTML document at a certain URL.

Up until this point,
  the keyboard has been used as a secondary interface---as
    an /alternative/ to something.
Now we're going to venture into a world where it is /the/ interface.

*** REHEARSED The Shell Command Prompt                            :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
mikegerwitz@lp2019-laptop:~$
# ^ user    ^ host        ^ working directory (home)
#+END_SRC

#+BEAMER: \begin{uncoverenv}<2->
#+BEAMER: \subskip
This presentation will show:
#+BEAMER: \medskip

#+BEGIN_SRC
$ command
output line 1
output line 2
...
output line N
#+END_SRC
#+BEAMER: \end{uncoverenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:55
:END:

If you open a VTE,
  or virtual terminal emulator,
  you will be greeted with a curious string of characters.
This is a /command prompt/.

The program that is prompting you for a command is called the /shell/.
The GNU shell is =bash=,
  which is the default on most GNU/Linux systems.

Since we're talking about freedom in your computing,
  I hope that you'll try bash on an operating system that respects your
  freedom to use, study, modify, and share its software,
    like a GNU/Linux distribution.
This laptop here runs Trisquel.

Bash is also the default on Mac OSX,
  but the rest of the operating system is non-free;
    you have no freedom there.
And Windows now has something they call
  ``Bash on Ubuntu on Windows'',
    which just is GNU running atop of the proprietary Windows kernel.
You can do better that that!

When I present commands here,
  the command line we are executing is prefixed with a dollar sign,
  and the output immediately follows it,
    like so.

*** REHEARSED Eliminating the Web Browser                         :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
$ wget https://libreplanet.org/2019/speakers/
#+END_SRC

#+BEAMER: \begin{uncoverenv}<2->
#+BEGIN_SRC sh
--2019-03-24 00:00:00-- https://libreplanet.org/2019/speakers/
Resolving libreplanet.org (libreplanet.org)... 209.51.188.248
Connecting to libreplanet.org (libreplanet.org)|209.51.188.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
...
2019-03-24 00:00:00 (1.78 MB/s) - ‘index.html’ saved [67789]
#+END_SRC
#+BEAMER: \end{uncoverenv}

#+BEAMER: \begin{uncoverenv}<3>
#+BEGIN_SRC sh
$ wget -O speakers.html \
       https://libreplanet.org/2019/speakers/
#+END_SRC
#+BEAMER: \end{uncoverenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:05
:END:

Alright!
The goal is to retrieve the HTML file at a given URL.

GNU/Linux distributions usually come with GNU =wget=,
  which does precisely that.
To invoke it,
  we type the name of the command,
  followed by a space,
  followed by the URL we wish to retrieve,
  and then hit enter.

What follows is quite a bit of text.
The details aren't particularly important as long as it's successful,
  but notice that it says it saved to =index.html=.
That's not intuitive to those who don't understand why that name was used.

So let's tell =wget= what file we want to output to.
We do this with the =O= option,
  like so.
It takes a single argument,
  which is the name of the output file.
The backslash here allows us to continue the command onto the next line;
  otherwise, a newline tells the shell to execute the command.

So remember previously that we manually created =speakers.html= by viewing
  the source of the webpage in a web browser and saving it.
If we open this file,
  we'll find that it contains /exactly the same text/ as when we manually
    did it,
      and we never had to open a web browser.
And we can search it all the same as before for ``free software''.

*** REHEARSED Browser vs. =wget= Comparison                       :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC
Ctrl+L ``https://libreplanet.org/2019/speakers/''
#+END_SRC

#+BEAMER: \subskip

#+BEGIN_SRC sh
$ wget https://libreplanet.org/2019/speakers/
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:20
:END:

This is a very different means of interacting with the computer,
  but if we compare this with the keyboard shortcut used previously,
  they are very similar.
Not so scary,
  right?
It's hard to imagine a more direct line of communication with the computer
  for downloading a webpage,
    short of reading your mind.

*** REHEARSED Finding Text on the Command Line                    :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
$ grep 'free software' speakers.html
#+END_SRC

#+BEAMER: \begin{uncoverenv}<2->
\vdots
#+BEGIN_SRC
<p>Mike Gerwitz is a free software hacker and activist with a focus on
exclusively free software. Mike spends most of his free time with his
#+END_SRC
\vdots
#+BEAMER: \end{uncoverenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

Not having to open a web browser is nice,
  but having to open the downloaded HTML file just to search it is a bit of
    a pain;
      is there a command that can help us there too?

We want to know whether a page contains the term ``free software''.
For that we use a tool called =grep=.

The first argument to =grep= is the search string,
  and the remaining arguments---just one here---tell it where it should
  search.
The first argument to =grep= is quoted because it contains a space.

You'll get a bunch of output;
  I just included a small snippet here.
But notice how it happens to include exactly the text we were looking at in
  the web browser.

And with that we have replicated =Ctrl+F=.
But did we do a good job conveying our thoughts to the machine?

We just wanted to know whether the page /contains/ the phrase,
  but we don't care to see it!
So while we have efficiently /conveyed/ a search string,
  we didn't receive an efficient /reply/---it's
    information overload.

*** REHEARSED A More Gentle Reply                                 :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
$ grep --quiet 'free software' speakers.html && echo yes

yes
#+END_SRC

#+BEAMER: \subskip

#+BEAMER: \begin{onlyenv}<2>
#+BEGIN_SRC sh
$ echo 'Hello, world!'

Hello, world!
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<3>
#+BEGIN_SRC sh
$ grep --quiet 'open source' speakers.html || echo no

no
#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

First we tell =grep= to modify its behavior with the =quiet= flag.
You can also use the short form,
  which is just =-q=.
Rather than outputting results,
  =grep= will exit silently and it will instead return a status to the shell
    that says whether or not the search failed.

POSIX-like shells,
  like Bash,
  offer the ability to say ``run this next command if the previous
    succeeds'',
      and this is done by putting two ampersands between the commands.

The command to run if =grep= succeeds in finding a match is =echo=.
All echo does is takes its arguments and spits them right back out again as
  output.
So this essentially states:
  ``search for `free software' in =speakers.html= and output `yes' if it is
    found''.

Since =echo= is its own command,
  it also works by itself.
Here's the classic ``hello, world'' program in shell.

But if you recall our research task,
  it was to search for pages that do /not/ contain the term ``free
    software''.
We can do that too,
  by using two pipes in place of two ampersands.

*** REHEARSED Writing to Files (Redirection)                      :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

- Commands write to standard out (stdout) by default
- /Output redirection/ writes somewhere else

#+BEAMER: \subskip

#+BEGIN_SRC sh
# overwrites each time
$ echo 'Hello, world!'       > hello.txt
$ echo 'Hello again, world!' > hello.txt

# appends (echo adds a newline)
$ echo 'First line'  >> results.txt
$ echo 'Second line' >> results.txt
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:55
:END:

Alright, we're well on our way now!
But we still haven't gotten rid of that damn text editor,
  because we need to save a list of URLs to a file to hold our final
  results!

Well as it so happens,
  writing to a file is such a common operation that it's built right into
    the shell.
We use a feature called /redirection/.

There are two types of output redirection.
If you place a single greater-than symbol followed by a filename after a
  command,
    then the output of that command will replace anything already in the
      file.
So the result of the first two commands will be a =hello.txt= that contains
  only a single line:
    ``Hello again, world!''.

The second type,
  which uses /two/ greater-than symbols,
  /appends/ to the file.
=echo= by default adds a newline,
  so the result of the second two commands is a =results.txt= containing two
    lines,
      ``First line'' and ``Second line'' respectively.
If the file doesn't yet exist,
  it will be created.

*** REHEARSED Starting Our List                               :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEGIN_SRC sh



$ wget --quiet -O speakers.html \
       https://libreplanet.org/2019/speakers/ \
    && grep --quiet 'free software' speakers.html \
         || echo https://libreplanet.org/2019/speakers/ \
              >> results.txt
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

Take a look at that for a moment.
/<pause ~5s>/
Can anyone tell me in just one sentence what the result of this command line
  will be?
/<pause ~5s>/
/<react appropriately>/

As exciting as it is to start to bring these things together,
  the result is pretty anti-climatic---we
    know that =speakers.html= /does/ contain the string ``free software'',
      and so the result is that =results.txt= contains /nothing/!
In fact,
  if =results.txt= didn't exist yet,
  it still wouldn't even exist.

At this point,
  we have successfully eliminated both the web browser and text editor.
But this is a hefty command to have to modify each time we want to try a
  different URL.

*** REHEARSED Command Refactoring                             :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \begin{onlyenv}<6>
#+BEGIN_SRC sh

# original:

$ wget --quiet -O speakers.html \
       https://libreplanet.org/2019/speakers/ \
    && grep --quiet 'free software' speakers.html \
         || echo https://libreplanet.org/2019/speakers/ \
              >> results.txt
#+END_SRC
\subskip
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<1>
#+BEGIN_SRC sh


$ URL=https://libreplanet.org/2019/speakers/
$ wget --quiet -O speakers.html \
       "$URL" \
    && grep --quiet 'free software' speakers.html \
         || echo "$URL" \
              >> results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<2>
#+BEGIN_SRC sh


$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO speakers.html \
       "$URL" \
    && grep -q 'free software' speakers.html \
         || echo "$URL" \
              >> results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<3>
#+BEGIN_SRC sh


$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO - \
       "$URL" \
    | grep -q 'free software' \
        || echo "$URL" \
             >> results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<4>
#+BEGIN_SRC sh


$ URL=https://libreplanet.org/2019/speakers/
$ wget -qO - "$URL" \
    | grep -q 'free software' || echo "$URL" >> results.txt



#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<5->
#+BEGIN_SRC sh
$ alias fetch-url='wget -qO-'

$ URL=https://libreplanet.org/2019/speakers/
$ fetch-url "$URL" \
    | grep -q 'free software' || echo "$URL" >> results.txt



#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:02:05
:END:

We can simplify it by introducing a /variable/.
First we assign the URL to a variable /named/ URL.
We then reference its value by prefixing it with a dollar sign everywhere
  the URL previously appeared.
We put it in quotes just in case it contains special characters or
  whitespace.

We can also make this command line a bit more concise by using the short
  name for the =--quiet= flag,
    which is =-q=.
Notice how in =wget= I combined them into =-qO= instead of using two
  separate dashes with spaces between them,
    but you don't have to do this.

Something else feels dirty.
We're creating this =speakers.html= file just to pass to =grep=.
It's not needed after the fact.
In fact,
  it's just polluting our filesystem.
What if we didn't have to create it at all to begin with?

I'm first going to introduce the notation,
  and then I'll go into why it works.

If we replace the output file =speakers.html= with a single dash,
  that tells =wget= to write to standard out.
This is normally the default behavior of command line programs,
  like =grep= and =echo=,
  but =wget= is a bit different.

We then omit the =speakers.html= from =grep= entirely.
=grep= will read from standard in by default.

We then connect standard out of =wget= to the standard in of =grep= using a
  /single/ pipe, not double;
    this is called a /pipeline/.

Now that we've freed up some characters,
  let's reformat this slightly to be a bit more readable.
And that =wget= command looks a bit cryptic.
How about we define an alias so that it looks a bit more friendly,
  and then we can stop worrying about what it does?

Now here's the original command we started with,
  and where we're at now.

This little bit of abstraction has made our intent even more clear.
It can now clearly be read that we're defining a URL,
  retrieving that URL,
  searching for a term,
  and then appending it to a file on a non-match.

By the way,
  for privacy reasons,
  you can prefix `wget` with `torify` to run it through Tor,
    if you have it installed.

But before we keep going,
  I want to go back to a point I mentioned previously.

*** REHEARSED Again: Text is a Universal Interface           :B_againframe:
:PROPERTIES:
:BEAMER_env: againframe
:BEAMER_ref: *Text is a Universal Interface
:BEAMER_act:
:END:

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:20
:END:

Text is a universal interface.

Notice how we started out our journey manually inspecting text,
  and began replacing the human part of the workflow at each step with a
  command.
That's because text is something that both humans and computers can work
  with easily.

This is a fundamental design principle in the Unix tools that I have begun
  to present to you.

*** REHEARSED Pipelines                                       :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
/``Expect the output of every program to become the input to another''/

#+BEAMER: \fullsubtext\hfill
---Doug McIlroy (1978)

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:15
:END:

The invention of the Unix pipe is credited to Doug McIlroy.
As part of the Unix philosophy,
  he stated:
    ``expect the output of every program to become the input to another''.

More broadly,
  the Unix philosophy can be summarized as:

*** REHEARSED Summary of the Unix Philosophy                  :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:DURATION: 0:00:40
:END:

#+BEAMER: \begingroup\fullslidetext
The Unix Philosophy
#+BEAMER: \endgroup\subskip

#+BEGIN_QUOTE
This is the Unix philosophy: Write programs that do one thing and do it
well. Write programs to work together. Write programs to handle text
streams, because that is a universal interface.

#+BEAMER: \smallsubskip\hfill---Doug McIlroy
#+END_QUOTE

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:40
:END:

/<Read it>/

Up until this point,
  we have changed how we communicate with the machine by moving away from a
  visual interface driven primarily by movement,
    to a textual interface that puts mind and machine on equal footing.
And now here we're talking about another profound shift in how we think.

We start to think of how to decompose problems into small operations that
  exist as part of a larger pipeline.
We think of how to chain small, specialized programs together,
  transforming text at each step to make it more suitable for the next.

** REHEARSED Program Composition [7/7]
*** Composition Topics [6/6]                                     :noexport:
- [X] Clarify how pipelines work with existing =wget | grep=.
- [X] More involved pipeline with more than two programs.
- [X] Emphasize iterative development and how the shell is a REPL.
  - Useful for programmers for prototyping and debugging, but also essential
    to average users for discovery.
  - Evolve by making portions of command dynamic (variables, subshells)
- [X] Now script discovering what pages contain a certain word [3/3]
  - [X] Mention previous example of being emailed a list of URLs.  Rather
        than pasting them into a file, let's discover them using the same
        tool: =grep=.  Save email to a file.
  - [X] =grep -o 'https\?://[^ ]\+'=, show how it gets a list of URLs.
  - [X] Introduce =while= and =read=, showing how we can iteratively run
        commands, maybe =... | while read url; do echo "URL: $url"; done=.
    - Not enough talk time to walk away and get a coffee, but let's see if
      we can maybe let it run for 10--30s while I blabber on.  Depends on
      the connection speed at MIT with all the participants.
- [X] Extract =url-grep= into script.
- [X] Demonstrate running jobs in parallel with =xargs=.

*** REHEARSED LP Sessions                                     :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | head -n14
<header class="keynote-speaker-header" id="garbee">
<hgroup>
<h2>Bdale Garbee</h2>
</hgroup>
</header>
<p><em>Closing keynote</em></p>
--
<header class="keynote-speaker-header" id="loubani">
<hgroup>
<h2>Tarek Loubani</h2>
</hgroup>
</header>
<p><em>Opening keynote (Day 1)</em></p>
--
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep '<em>'
<p><em>Closing keynote</em></p>
<p><em>Opening keynote (Day 1)</em></p>
<p><em>Opening keynote (Day 2)</em></p>
[...]
<p><em>The Tor Project: State of the Onion</em> and <em>Library Freedom Institute: A new hope</em></p>
<p><em>The Tor Project: State of the Onion</em></p>
[...]
<p><em>Large-scale collaboration with free software</em></p>
<p><em>Large-scale collaboration with free software</em></p>
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep -o '<em>[^<]\+</em>'
<em>Closing keynote</em>
<em>Opening keynote (Day 1)</em>
<em>Opening keynote (Day 2)</em>
[...]
<em>The Tor Project: State of the Onion</em>
<em>Library Freedom Institute: A new hope</em>
<em>The Tor Project: State of the Onion</em>
[...]
<em>Large-scale collaboration with free software</em>
<em>Large-scale collaboration with free software</em>
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep -o '<em>[^<]\+</em>' \
    | sort \
    | uniq -cd
      2 <em>Hackerspace Rancho Electrónico</em>
      4 <em>Large-scale collaboration with free software</em>
      2 <em>Library Freedom Institute: A new hope</em>
      2 <em>Right to Repair and the DMCA</em>
      2 <em>Teaching privacy and security via free software</em>
      2 <em>The joy of bug reporting</em>
      5 <em>The Tor Project: State of the Onion</em>
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep -o '<em>[^<]\+</em>' \
    | sort \
    | uniq -cd \
    | sort -nr \
    | head -n5
      5 <em>The Tor Project: State of the Onion</em>
      4 <em>Large-scale collaboration with free software</em>
      2 <em>The joy of bug reporting</em>
      2 <em>Teaching privacy and security via free software</em>
      2 <em>Right to Repair and the DMCA</em>

#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep -o '<em>[^<]\+</em>' \
    | sort \
    | uniq -cd \
    | sort -nr \
    | head -n5 \
    | sed 's#^ *\(.\+\) <em>\(.*\)</em>#\2 has \1 speakers#'
The Tor Project: State of the Onion has 5 speakers
Large-scale collaboration with free software has 4 speakers
The joy of bug reporting has 2 speakers
Teaching privacy and security via free software has 2 speakers
Right to Repair and the DMCA has 2 speakers
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ fetch-url https://libreplanet.org/2019/speakers/ \
    | grep -A5 speaker-header \
    | grep -o '<em>[^<]\+</em>' \
    | sort \
    | uniq -cd \
    | sort -nr \
    | head -n5 \
    | sed 's#^ *\(.\+\) <em>\(.*\)</em>#\2 has \1 speakers#'
    | espeak




#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:02:30
:END:

Let's look at a more sophisticated pipeline with another practical example.

I noticed that some LibrePlanet sessions had multiple speakers,
  and I wanted to know which ones had the /most/ speakers.

The HTML of the speakers page includes a header for each speaker.
Here are the first two.
=-A5= tells =grep= to also output the five lines following matching lines,
  and =head -n14= outputs only the first fourteen lines of output.

We're only interested in the talk titles, though.
Looking at this output,
  we see that the titles have an =em= tag,
    so let's just go with that.
Pipe to =grep= instead of =head=.

It looks like at least one of those results has /multiple/ talks,
  if you can see the ``and'' there.
But note that each is enclosed in its own set of =em= tags.
If we add =-o= to =grep=,
  which stands for /only/,
  then it'll only return the portion of the line that matches,
  rather than the entire line.
Further,
  if there are multiple matches on a line,
  it'll output each match independently on its own line.
That's exactly what we want!
But we have to modify our regex a little bit to prevent it from grabbing
  everything between the first and /last/ =em= tag.
Don't worry if you don't understand the regular expression;
  they take time to learn and tend to be easier to write than they are to
  read.
This one just says ``match one or more non-less-than characters between =em=
  tags''.

Now assuming that the talk titles are consistent,
  we can get a count.
=uniq= has the ability to count consecutive lines that are identical,
  as well as output a count.
We also use =-d= to tell it to only output duplicate lines.
But =uniq= doesn't sort lines before processing,
  so we first pipe it to =sort=.
That gives us a count of each talk!

But I want to know the talks with the /most/ speakers,
  so let's sort it /again/,
  this time numerically and in reverse order,
  and take the top five.

And we have our answer!

But just for the hell of it,
  let's go a step further.
Using =sed=,
  which stands for /stream editor/,
  we can match on portions of the input and reference those matches in a
    replacement.
So we can reformat the =uniq= output into an English sentence,
  like so.
I chose the pound characters delimit the match from the replacement.
The numbers in the replacement reference the parenthesized groups in the
  match.

And then we're going to pipe it to the program =espeak=,
  which is a text-to-speech synthesizer.
Your computer will speak the top five talks by presenter count to you.
Listening to computers speak is all the rage right now,
  right?

*** REHEARSED Interactive, Incremental, Iterative Development :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Incremental Development

#+BEAMER: \fullsubtext
Interactive REPL, Iterative Decomposition

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:10
:END:

Notice how we approached that problem.
I presented it here just as I developed it.
I didn't open my web browser and inspect the HTML;
  I just looked at the =wget= output and then started to manipulate it in
    useful ways working toward my final goal.
This is just /one/ of the many ways to write it.
And this is part of what makes working in a shell so powerful.

In software development,
  we call environments like this REPLs,
    which stands for ``read-eval-print loop''.
The shell reads a command line,
  evaluates it,
  prints a result,
  and then does that all over again.
As a hacker,
  this allows me to easily inspect and iterate on my script in real time,
    which can be a very efficient process.
I can quickly prototype something and then clean it up later.
Or maybe create a proof-of-concept in shell before writing the actual
  implementation in another language.

But most users aren't programmers.
They aren't experts in these commands;
  they have to play around and discover as they go.
And the shell is perfect for this discovery.
If something doesn't work,
  just keep trying different things and get immediate feedback!

And because we're working with text as data,
  a human can replace any part of this process!

*** REHEARSED Discovering URLs                                :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt
https://en.wikipedia.org/wiki/Free_software
https://en.wikipedia.org/wiki/Open_source
https://en.wikipedia.org/wiki/Microsoft
https://opensource.org/about





#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt \
    | while read URL; do
        echo "URL is $URL"
      done
URL is https://en.wikipedia.org/wiki/Free_software
URL is https://en.wikipedia.org/wiki/Open_source
URL is https://en.wikipedia.org/wiki/Microsoft
URL is https://opensource.org/about


#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL \
      done \
    > results.txt




#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL" \
      done \
    | tee results.txt
https://en.wikipedia.org/wiki/Microsoft
https://opensource.org/about


#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL" \
      done \
    | tee results.txt
    | xclip -i -selection clipboard



#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh

$ grep -o 'https\?://[^ ]\+' email-of-links.txt \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL" \
      done \
    | tee >( xclip -i -selection clipboard )
https://en.wikipedia.org/wiki/Microsoft
https://opensource.org/about


#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ xclip -o -selection clipboard \
    | grep -o 'https\?://[^ ]\+' \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL" \
      done \
    | tee >( xclip -i -selection clipboard )
https://en.wikipedia.org/wiki/Microsoft
https://opensource.org/about


#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ xclip -o -selection clipboard \
    | grep -o 'https\?://[^ ]\+' \
    | while read URL; do \
        fetch-url "$URL" | grep -q 'free software' \
          || echo "$URL" \
      done \
    | tee results.txt
https://en.wikipedia.org/wiki/Microsoft
https://opensource.org/about

$ xclip -i -selection clipboard < results.txt
#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:02:15
:END:

Okay, back to searching webpages.
Now that we have a means of creating the list of results,
  how do we feed the URLs into our pipeline?
Why not pull them right out of the email with =grep=?

Let's say you saved the email in =email-of-links.txt=.
This simple regex should grab most URLs,
  but it's far from perfect.
For example,
  it'd grab punctuation at the end of a sentence.
But we're assuming a list of URLs.
Here's some example output with a few.

For each of these,
  we need to run our pipeline.
It's time to introduce =while= and =read=.
=while= will continue to execute its body in a loop until its command fails.
=read= will read line-by-line into one or more variables,
  and will fail when there are no more lines to read.

So if we insert our =fetch-url= pipeline into the body,
  we get this.
For convenience,
  let's use =tee=,
  which is named for a pipe tee;
    it'll send output through the pipeline while also writing the same
      output to a given file.
So now we can both observe the results /and/ have them written to a file!

But we were just going to reply to an email with those results.
Let's assume we're still using a GUI email client.
Wouldn't it be convenient if those results were already on the clipboard for
  us so we can just paste them into the message?
We can accomplish that by piping to =xclip= as shown here.

Ah, crap, but now we can't see the output again.
Do we really need the results file anymore?
Rather than outputting to a file on disk with =tee=,
  we're going to use a special notation that tells bash to invoke a command
    in a subshell and replace that portion of the command line with a path
      to a virtual file representing the standard input of that subshell.
This is a bash-specific feature.
Now we can see the output again!

Well,
  if we're /writing/ to the clipboard,
  why don't we just /read/ from it too?
Instead of saving our mail to a file,
  we can just copy the relevant portion and have that piped directly to
    =grep=!
If you have a list of URLs and you just copy that portion,
  then you can just get rid of =grep= entirely.

What if you wrote to =results.txt= and later decided that you want to copy
  the results to the clipboard?
We can do that too by reading =results.txt= in place of standard input to
  =xclip=,
    as shown here.

Phew!

*** REHEARSED Go Grab a Coffee                                :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEAMER: \fullslidetext
Go Grab a Coffee

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:15
:END:

Remember when I said I could go grab a coffee and play with the kids while
  the script did its thing?
Well now's that time.

But grabbing a coffee means that this system is a bottleneck.
The Internet is fast nowadays;
  ideally, we wouldn't have to wait long.
Can we do better?

*** REHEARSED Async Processes                                 :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEGIN_SRC sh
$ sleep 1 && echo done & echo start
start
done
#+END_SRC

#+BEAMER: \begin{uncoverenv}<2>\subskip
/(Don't do this for large numbers of URLs!)/

#+BEGIN_SRC sh
$ while read URL; do
    fetch-url "$URL" | grep -q 'free software' \
      || echo "$URL" &
  done | tee results.txt
#+END_SRC
#+BEAMER: \end{uncoverenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:45
:END:

What if we could query multiple URLs in parallel?

Shells have built-in support for backgrounding tasks so that they can run
  while you do other things;
    all you have to do is place a single ampersand at the end of a command.
So in this example,
  we sleep for one second and then echo ``done''.
But that sleep and subsequent echo is put into the background,
  and the shell proceeds to execute =echo start= while =sleep= is running in
  the background.
One second later,
  it outputs ``done''.

So here's the loop we were just writing.
If we add an ampersand at the end of that pipeline,
  it'll run in the background and immediately proceed to the next URL,
    executing the loop again.

But there's a problem with this approach.
Sure,
  it's fine if we only have a few URLs.
But what if we have 1000?
That isn't efficient,
  and it's a bit rude to server administrators.

*** REHEARSED Executable Shell Script and Concurrency         :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

**** =url-grep=                                                  :B_block:
:PROPERTIES:
:BEAMER_env: block
:END:

#+BEGIN_SRC sh
#!/bin/bash

search=$1
url=$2

wget -qO- "$url" \
  | grep -q "$search" || echo "$url"
#+END_SRC

**** Execute                                             :B_ignoreheading:
:PROPERTIES:
:BEAMER_env: ignoreheading
:END:

#+BEGIN_SRC sh
$ chmod +x url-grep
#+END_SRC

#+BEAMER: \begin{onlyenv}<1>
#+BEGIN_SRC sh
$ while read URL; do
    ./url-grep 'free software' "$URL" >> results.txt
  done
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<2>
#+BEGIN_SRC sh
$ xargs -n1 ./url-grep 'free software' > results.txt


#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<3>
#+BEGIN_SRC sh
$ xargs -n1 -P5 ./url-grep 'free software' > results.txt
#             ^ 5 concurrent processes

#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:30
:END:

Before we continue,
  we're going to have to write our pipeline in a way that other programs can
    run it.
Up to this point,
  the program has just been embedded within an interactive shell session.
One of the nice things about shell is that you can take what you entered
  onto the command line and paste it directly into a file and,
    with some minor exceptions,
    it'll work all the same.

Let's take our pipeline and name it =url-grep=.
Aliases only work in interactive sessions by default,
  so we're going to just type =wget= directly here.
Alternatively,
  you can define a function.
We use the positional parameters =1= and =2= here to represent the
  respective arguments to the =url-grep= command,
    and assign them to new variables for clarity.

The comment at the top of the file is called a ``shebang''.
This is used by the kernel so that it knows what interpreter to use to run
  our program.

To make it executable,
  we use =chmod= to set the executable bits on the file.
We can then invoke it as if it were an executable.
You actually don't /have/ to do this;
  you can call =bash url-grep= instead of making it executable,
    and then you don't need the shebang either.

Now we replace the =while= loop with =xargs=.
It takes values from standard in and appends them as arguments to the
  provided command line.
We specify =-n1= to say that only one argument should be read from stdin
  for any invocation of the command;
    that makes it run a new command for every line of input.
Otherwise it'd just append N URLs as N arguments.

And now we can simply use =-P= to tell it how many processes to use at once.
Here we specify =5=,
  meaning =xargs= will run five processes at a time.
You can change that to whatever number makes sense for you.

*** REHEARSED Execution Time                                      :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
$ wc -l url-list
1000

$ time xargs -n1 -P10 ./url-grep 'free software' < url-list
real    0m17.548s
user    0m8.283s
sys     0m4.877s
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:50
:END:

So how long does it take to run?

I took a few URLs and just repeated them in a file so that I had 1000 of
  them.
Running the =xargs= command,
  it finishes in under 18 seconds on my system at home.
Obviously YMMV,
  and certain sites may be slower to respond than others.

If you were to write this from scratch knowing what you know now,
  then in just a few minutes,
  the task will have been automated away /and/ completed,
    all by gluing together existing programs.

You don't need to be a programmer to know how to do this;
  you just need to be familiar with the tools and know what's possible,
    which comes with a little bit of practice.
It can certainly be daunting at first.
But I hope that by walking you through these examples and showing you how to
  construct them step-by-step,
    it helps to demystify them and show that there is no wizardry involved.

We've come a long way from using the web browser and a mouse.

Now that we've finally completed our research task,
  let's look at a few more examples.

** REHEARSED More Examples [8/8]
*** More Example Topics [7/7]                                    :noexport:
- [X] Screenshots with =import=.
  - Including copying to clipboard.
- [X] Using =import= and =tesseract= for screenshot OCR.
  - See if we can demo on the LP laptop.
  - It works very well with the [[https://static.fsf.org/nosvn/libreplanet/2019/assets/keynote_banner.png][LP2019 keynote speakers image]].
- [X] Checking the weather
- [X] Resizing images
- [X] Password management [3/3]
  - [X] =pwgen=.
  - [X] Diceware/EFF word list with POSIX tools.
  - [X] GPG-encrypted password list over SSH with smart card.
- [X] Full circle: automating with =xdotool=.
  - Use =tesserac= to detect matches from =Ctrl+F=.
- [X] Finding documentation with =info= and =man=.


*** REHEARSED Resize Images                                       :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC
$ for img in *.png; do
    convert "$img" -resize 50% "sm-$img"
  done

# nested directories
$ find . -name '*.png' -exec convert {} -resize 50% sm-{} \;
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:30
:END:

This example will be useful to people who have a lot of images that the want
  to perform an operation on.
ImageMagick has a =convert= tool which can do a huge variety of image
  manipulations that you would expect to have to use, say, GIMP for.
In this case,
  we're just using one of the simples ones to reduce the image size by 50%.

The first example uses /globbing/ to find all PNG images in the current
  directory.
The second example uses the =find= command and searches all child
  directories as well.
Both examples produce a new set of images prefixed with =sm-=.

*** REHEARSED Password Generation                                 :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC
# generate a random 32-character password
$ tr -cd '[:graph:]' < /dev/urandom | head -c32
`TB~cmJQ1%S8&tJ,%FoD54}"Fm4}\Iwi

# generate passphrase from EFF's large dice wordlist
# (https://www.eff.org/dice)
$ cut -f2 eff_large_wordlist.txt \
    | sort -R --random-source=/dev/urandom \
    | head -n6 \
    | tr '\n' ' '
oppressor roman jigsaw unhappy thinning grievance
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:45
:END:

How about password generation?
=/dev/urandom= is a stream of random binary data.
We can use =tr= to delete everything that is not a printable character by
  taking the complement of =graph=.
That type of password is useful if you have a password manager,
  but it's not useful if you need to memorize it.

When memorization is needed,
  a /passphrase/ may be a better option.
A common way to generate those is to use a large list of memorable words and
  choose them /at random/.
Diceware is one such system,
  and the EFF has its own word list.
But we don't need physical dice when we can just use =sort= to randomly
  permute the word list.
The EFF recommends taking at least six words,
  which is what I did here.
This one is particularly memorable and morbid-sounding.
I'm a little upset that I put it in the slide instead of using it!

*** REHEARSED Password Manager                                    :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
$ gpg --decrypt password-db.gpg | head -n3
https://foo.com
user mikegerwitz
pass !({:pT6DcJG.cr&OAco_EC63r_*xg|uD
#+END_SRC

#+BEAMER: \begin{uncoverenv}<2>
#+BEGIN_SRC sh
$ gpg --decrypt password-db.gpg \
    | grep -A2 ^https://foo.com \
    | tail -n2 \
    | while read key value; do
        echo "paste $key..."
        printf %s "$value" \
          | xclip -o -selection clipboard -l 1 -quiet
      done
#+END_SRC
#+BEAMER: \end{uncoverenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:40
:END:

Speaking of password managers.
We can create a pretty decent rather quickly.
Let's say we have a password list encrypted using GnuPG,
  which can be decrypted like so.
Each account has a URL,
  username,
  and password.

We pipe the output to =grep= to find the one we're looking for.
The caret anchors the match to the beginning of the line.
We then use =tail= to keep only the last two lines,
  discarding the URL.

Here we see =read= with more than one variable.
For each line,
  we read the first word into =key= and the rest of the line into =value=.
This is where it gets a bit more interesting.
We don't want to actually output our password anywhere where others could
  see it or where it may be vulnerable to a side channel like Van Eck
  phreaking.
Instead,
  we're going to copy the value to the clipboard.
Here we use =printf= instead of =echo= because of some technical details I
  don't have time to get into here,
    but it has to do with =echo= option parsing.

/(If you're reading this: imagine what happens if the password is ``-n
foo'', for example.)/

But the clipboard has its own risks too.
What if there's a malicious program monitoring the clipboard for passwords?
I used =-l 1= with =xclip=.
=-l= stands for ``loop'',
  which is the number of times to serve paste requests.
Normally =xclip= goes into the background and acts as a server.
=-quiet= keeps =xclip= in the foreground.
So if we see that the script moves on to request pasting the next value
  before we've actually pasted it,
    then we'll be made aware that something is wrong and perhaps we should
      change our account information.

Another nice consequence is that the first value you paste will be the
  username,
    and the second value will be the password.
And then the script will exit.
Very convenient!

Since the decrypted data exist only as part of the pipeline,
  the decrypted passwords are only kept plaintext in memory for the duration
    of the script.

*** REHEARSED Remote Password Manager With 2FA                    :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

- Add =extra-socket= to =.gnupg/gpg-agent.conf=
- Add =RemoteForward= in =.ssh/config= for host
- Save script on previous slide as =get-passwd=

#+BEAMER: \subskip

#+BEGIN_SRC sh
$ ssh -Y mikegerwitz-pc get-passwd https://foo.com
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:30
:END:

But what if you need passwords on multiple devices?
Well,
  then you have to worry about how to keep them in sync.
It also means that,
  if you are travelling and asked to decrypt files on your laptop,
    you're put in a tough spot.

Instead,
  let's make that command line from the previous slide a script called
    =get-passwd=,
      and have it take the URL as an argument.
We can then access it remotely over SSH.
But to have clipboard access,
  we need to forward our X11 session,
    which is what =-Y= does.

But that's still not good enough.
What if my master password is compromised---the
  password for my database?
I'd rather have two-factor authentication.
I asymmetrically encrypt my password database using a private key that's
  stored on my Nitrokey,
    which is a smart card---keys
      cannot be extracted from it,
        unless there's a vulnerabilty of course.
To unlock the card,
  I must enter a PIN.
So that's both something I know and something I have.
If you enter the PIN incorrectly three times,
  the PIN needs to be reset with an administrative password.
If you get that wrong three times,
  the device bricks itself.
And this all works over SSH too.

Asymmetic encryption is also nice for shared passwords.
I share a small password database with my wife,
  for example.

Encrypting long-term secrets with asymmetric keys isn't a great idea,
  so there's a tradeoff.
I choose to accept it,
  because passwords aren't long-term secrets---I
    can easily change them.
But you could easily do both---
  first require decryption with your smart card and then enter a passphrase
    for a symmetric key.



*** REHEARSED Taking Screenshots                                  :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEGIN_SRC sh
# draw region on screen, output to ss.png
$ import ss.png

# screenshot of entire screen after 5 seconds
$ import -pause 5 -window root ss.png

# screenshot to clipboard
import png:- | xclip -i -selection clipboard -t image/png
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:00:35
:END:

Okay,
  back to something less serious.
ImageMagick also comes with a vaguely-named utility called =import=,
  which can capture images from an X server.
Screenshots.

If you run it with just a filename,
  then it'll change your cursor to a cross.
You can drag to define a rectangular region to copy,
  or you can just click on a window to take a screenshot of the whole thing.

The bottom example avoids outputting to a file entirely and instead feeds
  the raw image data to standard out.
We then pipe that to =xclip= to copy it to the clipboard.
Notice the new =image/png= type there.
Now you can paste the image into other programs,
  like image editors or websites.

*** REHEARSED Screenshot OCR                                      :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
$ import png:- | tesseract -psm 3 - - | cowsay
 __________________________________
/ Keynote Speakers                 \
|                                  |
| i                                |
|                                  |
| Bdale Garbee Micky Metts Richard |
\ Stallman Tarek Loubani           /
 ----------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
#+END_SRC
#+BEAMER: \end{onlyenv}

#+BEAMER: \begin{onlyenv}<+>
#+BEGIN_SRC sh
# OCR at URL
$ wget -qO- https://.../keynote_banner.png \
    | tesseract -psm 3 - -

# perform OCR on selected region and speak it
$ import png:- | tesseract -psm 3 - - | espeak

# perform OCR on clipboard image and show in dialog
$ xclip -o -selection clipboard -t image/png \
    | tesseract -psm 3 - - \
    | xargs -0 zenity --info --text
#+END_SRC
#+BEAMER: \end{onlyenv}

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:00
:END:

Since =import= lets us select a region of the screen,
  what if we used that to create a script that runs OCR on whatever we
  select?
And just for fun,
  what if the translation was presented to us by a cow?

=tesseract= is a free (as in freedom) optical character recognition
  program.

In this example,
  I selected the keynote speaker image on the LP2019 website.
It worked quite well.

But a cow isn't practical.
Instead,
  you can imagine maybe binding this to a key combination in your window
    manager.
In that case,
  maybe it'd be more convenient if it was spoken to you,
    like the second example.
Or maybe copied to your clipboard.

In the third example,
  we take an image off of the clipboard,
  run OCR,
  and then display the resulting text in a GUI dialog with =zenity=.

I really like these examples,
  because to an average user,
  all of this seems somewhat novel.
And yet,
  it's one of the simplest examples we've done!

YMMV though with tesseract,
  depending on your settings and training data.

*** REHEARSED Full Circle                                     :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:END:

#+BEGIN_SRC sh
$ xdotool search --name ' GNU IceCat$' windowactivate --sync \
          windowsize 1024 600 \
          key ctrl+t \
    && while read url; do
         xdotool getactivewindow \
                 key ctrl+l type "$url" \
           && xdotool getactivewindow \
                      key Return sleep 5 \
                      key ctrl+f sleep 0.5 \
                      type 'free software' \
           && import -window "$( xdotool getactivewindow )" \
                     -crop 125x20+570+570 png:- \
                | tesseract -psm 3 - - \
                | grep -q ^Phrase && echo "$url" \
       done < url-list | tee results.txt
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:02:25
:END:

Okay,
  for this final example,
  I'm going to do something a bit more complex.
Please take a few seconds to look at this.
<pause>

=xdotool= is a swiss army knife of X11 operations.
It can find windows,
  give them focus,
  send keystrokes,
  move the mouse,
  and do many other things.

The first line here finds the first window ending in ``GNU IceCat'' and
  gives it focus.
=--sync= blocks until that completes so we don't proceed too hastily.
We then proceed to resize it to 1024x600,
  and then open a new tab by sending =Ctrl+T=.

That's right.
We've come full circle back to the web browser.

We then proceed to read each URL form a file =url-list=,
  which you can see after =done=.
For each URL,
  we send =Ctrl+L= to give focus to the location bar and then type in the
  URL.
We can't chain any commands in =xdotool= after =type=,
  which is why we have another invocation to hit =Return=.
We then sleep for five seconds to give time to navigate.
I use Tor,
  so latency varies.
We then send =Ctrl+F=,
  wait very briefly to give IceCat time to trigger the find,
  and then send our string to search for.

If you remember,
  I mentioned that part of the problem with the GUI approach is that it
    requires visual inspection.
Fortunately for us,
  we have =tesseract=!
So we take a screenshot of the IceCat window at the offset where the match
  results are on my system.
We pipe that image to =tesseract= and,
  if it contains the word ``Phrase'',
  as in ``Phrase not found'',
  we echo the URL as a non-match.
All of this is =tee='d to =results.txt= like before.

This is /not/ what I had in mind when I talked about melding mind and
  machine.
But this shows that,
  even with GUIs,
  we can produce some level of automation using existing tools and a little
  bit of creativity.
Of course,
  this may not work on your system if your font size is different or because
    of various other factors;
      to generalize this,
        we'd have to get more creative to find the result text.

It's also worth mentioning that =xdotool= can come in handy for the password
  manager too---instead
    of copying to the clipboard,
      we can type it directly into a window.
And by specifying which window to send it to,
  we can ensure that we don't accidentally type in the wrong window,
    like a chat,
  if the user changes focus.
That also thwarts systems that implement the terrible anti-pattern of try to
  prevent you from pasting passwords.


*** REHEARSED Getting Help                                        :B_frame:
:PROPERTIES:
:BEAMER_env: frame
:END:

- All GNU packages have Info manuals and =--help=
- Most programs (including GNU) have manpages

#+BEAMER: \subskip

#+BEGIN_SRC sh
$ grep --help    # usage information for grep
$ man grep       # manpage for grep
$ info grep      # full manual for grep

# bash help
$ help
$ man bash
#+END_SRC

**** Notes                                                      :B_noteNH:
:PROPERTIES:
:BEAMER_env: noteNH
:DURATION: 00:01:30
:END:

I have presented a lot of stuff here,
  and I only got to a fraction of what I would have liked to talk about.
Some of you watching this aren't familiar with a lot of these topics,
  or possibly /any/ of them,
  so getting started may seem like a daunting task.
Where do you start?

As I showed before,
  the process of writing a command line is an iterative one.
Learning is the same way.
I don't remember all of the options for these programs.
=xdotool= I had used only lightly before this talk,
  for example;
    I had to research how to write that command line.
But I didn't use the Internet to do it;
  I did it from the comfort of my terminal using only what was already
    installed on my system.

You can usually get usage information for programs by typing =--help= after
  the command.
This will work for all GNU programs,
  but not all command line programs implement it.
All GNU programs also offer Info manuals,
  which read like books;
    those can be found with the =info= command,
      and can also be read in a much better format using Emacs.
You can also usually find them online in HTML format.
Most command line programs for Unix-like operating systems also include
  manpages,
    accessible with the =man= command.
If you want to know how to use =man=,
  you can view its own manpage using =man man=.

You can also get some help using Bash itself by simply typing =help= to list
  its builtins,
    and it has a very comprehensive manpage.

This is obviously a bit different than how people interact with GUIs,
  which are designed to be discoverable without the need for users to read
    documentation.


** Thank You                                                   :B_fullframe:
:PROPERTIES:
:BEAMER_env: fullframe
:DURATION: 00:00:01
:END:

#+BEGIN_COMMENT
Thank you.
#+END_COMMENT

#+BEGIN_CENTER
Mike Gerwitz

[[mailto:mtg@gnu.org][=mtg@gnu.org=]]

\bigskip

Slides and Source Code Available Online

<[[https://mikegerwitz.com/talks/cs4m]].pdf>

\bigskip

\vfill

Licensed under the Creative Commons Attribution ShareAlike 4.0
International License
#+END_CENTER


* Exporting                                                        :noexport:
For a non-interactive build, including all dependencies, simply run =make=.

Once all dependencies are built, you should be able to simply export this
buffer as a Beamer presentation (=C-c C-e l P=) to get an updated PDF (or
you can just run =make= again).


* Copyright and Licenses                                           :noexport:
This file Copyright (C) 2019 Mike Gerwitz.

This file is licensed under the Creative Commons Attribution ShareAlike 4.0
International License.  See [[file:COPYING.CCBYSA]] for the full license text.

Additionally, all code fragments are dual-licensed as such:

All code fragments are free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (see [[file::COPYING]]).  If not, see
<http://www.gnu.org/licenses/>.


* Local Variables                                                  :noexport:
# Local Variables:
# org-todo-keyword-faces: (("DRAFT" . org-upcoming-deadline) \
#                          ("DEVOID" . (:inherit org-warning \
#                                       :inverse-video t)) \
#                          ("LACKING" . org-warning) \
#                          ("REVIEWED" . "yellow") \
#                          ("AUGMENT" . (:foreground "yellow" :bold t :underline t)) \
#                          ("READY" . (:inherit org-scheduled :bold t :underline t)))
# eval: (add-to-list 'org-structure-template-alist
#                    '("C" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"))
# End: