Skip to content

Commit 572881a

Browse files
added interactive linux cli exercises post
1 parent 97e9d16 commit 572881a

File tree

18 files changed

+89
-18
lines changed

18 files changed

+89
-18
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ I'm addicted to reading fantasy/sci-fi books, so I have a [blog](https://learnby
66

77
## Posts
88

9+
* [Interactive Linux CLI Text Processing Exercises](https://learnbyexample.github.io/interactive-linux-cli-exercises/)
910
* [Festive deals for books on Python, Linux, JavaScript, Regular Expressions and more](https://learnbyexample.github.io/programming-deals-2022/)
1011
* [Building TUIs with textual: first impressions](https://learnbyexample.github.io/textual-first-impressions/)
1112
* [Computing from the Command Line book announcement](https://learnbyexample.github.io/computing-from-the-command-line-announcement/)

Diff for: atom.xml

+60-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,63 @@
55
<link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
66
<link href="https://learnbyexample.github.io"/>
77
<generator uri="https://www.getzola.org/">Zola</generator>
8-
<updated>2022-12-07T00:00:00+00:00</updated>
8+
<updated>2022-12-09T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
10+
<entry xml:lang="en">
11+
<title>Interactive Linux CLI Text Processing Exercises</title>
12+
<published>2022-12-09T00:00:00+00:00</published>
13+
<updated>2022-12-09T00:00:00+00:00</updated>
14+
<link rel="alternate" href="https://learnbyexample.github.io/interactive-linux-cli-exercises/" type="text/html"/>
15+
<id>https://learnbyexample.github.io/interactive-linux-cli-exercises/</id>
16+
<content type="html">&lt;p&gt;Having an interactive program that automatically loads questions and checks the solution is wonderful to have while learning a topic. This &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;CLI-Exercises&quot;&gt;TUI app&lt;&#x2F;a&gt; has 40 beginner to intermediate level exercises for Linux CLI text processing tools.&lt;&#x2F;p&gt;
17+
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;main&#x2F;CLI-Exercises&#x2F;cli_exercises.png&quot; alt=&quot;Sample screenshot for CLI exercises&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
18+
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;&lt;br&gt;
19+
&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;a class=&quot;zola-anchor&quot; href=&quot;#installation&quot; aria-label=&quot;Anchor link for: installation&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
20+
&lt;p&gt;Last month, I started learning a Python TUI framework called &lt;a href=&quot;https:&#x2F;&#x2F;textual.textualize.io&#x2F;&quot;&gt;Textual&lt;&#x2F;a&gt;. After working on a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;SquareTicTacToe&quot;&gt;4x4 board game&lt;&#x2F;a&gt;, I made an interactive app to help you test your CLI text processing skills with 40 beginner to intermediate level exercises. The app is fairly basic in terms of features — only single input file, so no stdin data, multiple files, etc.&lt;&#x2F;p&gt;
21+
&lt;p&gt;You&#x27;ll need Python for this (I used 3.8, it should work for more recent versions too).&lt;&#x2F;p&gt;
22+
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#f5f5f5;color:#1f1f1f;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; python3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt; -m&lt;&#x2F;span&gt;&lt;span&gt; venv textual_apps
23+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; cd textual_apps
24+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; source bin&#x2F;activate
25+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; pip install textual==0.5.0
26+
&lt;&#x2F;span&gt;&lt;span&gt;
27+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; git clone&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt; --depth&lt;&#x2F;span&gt;&lt;span&gt; 1 https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps.git
28+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; cd TUI-apps&#x2F;CLI-Exercises
29+
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; python cli_exercises.py
30+
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
31+
&lt;br&gt;
32+
&lt;h2 id=&quot;video-demo&quot;&gt;Video demo&lt;a class=&quot;zola-anchor&quot; href=&quot;#video-demo&quot; aria-label=&quot;Anchor link for: video-demo&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
33+
&lt;p align=&quot;center&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; loading=&quot;lazy&quot; src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;0ggfQzXeYJg&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;&#x2F;iframe&gt;&lt;&#x2F;p&gt;
34+
&lt;br&gt;
35+
&lt;h2 id=&quot;brief-guide&quot;&gt;Brief Guide&lt;a class=&quot;zola-anchor&quot; href=&quot;#brief-guide&quot; aria-label=&quot;Anchor link for: brief-guide&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
36+
&lt;ul&gt;
37+
&lt;li&gt;Press &lt;strong&gt;Ctrl+p&lt;&#x2F;strong&gt; and &lt;strong&gt;Ctrl+n&lt;&#x2F;strong&gt; to navigate the questions list.&lt;&#x2F;li&gt;
38+
&lt;li&gt;Type the command in the box below the question.&lt;&#x2F;li&gt;
39+
&lt;li&gt;Press &lt;strong&gt;Enter&lt;&#x2F;strong&gt; to execute the command.
40+
&lt;ul&gt;
41+
&lt;li&gt;Output would be displayed below the command box.&lt;&#x2F;li&gt;
42+
&lt;li&gt;If the output matches the expected results, the command box will turn &lt;em&gt;green&lt;&#x2F;em&gt; and a reference solution will also be shown.&lt;&#x2F;li&gt;
43+
&lt;li&gt;Issues due to errors and timeout (about &lt;code&gt;2&lt;&#x2F;code&gt; seconds) will be displayed in &lt;em&gt;red&lt;&#x2F;em&gt;.&lt;&#x2F;li&gt;
44+
&lt;&#x2F;ul&gt;
45+
&lt;&#x2F;li&gt;
46+
&lt;li&gt;Press &lt;strong&gt;Ctrl+s&lt;&#x2F;strong&gt; to show the reference solution if you are unable to solve an exercise.&lt;&#x2F;li&gt;
47+
&lt;li&gt;Press &lt;strong&gt;Ctrl+t&lt;&#x2F;strong&gt; to toggle between light and dark themes.&lt;&#x2F;li&gt;
48+
&lt;li&gt;Press &lt;strong&gt;Ctrl+q&lt;&#x2F;strong&gt; to quit the app.&lt;&#x2F;li&gt;
49+
&lt;li&gt;Some basic emacs readline shortcuts are supported, like &lt;strong&gt;Ctrl+u&lt;&#x2F;strong&gt;, &lt;strong&gt;Ctrl+k&lt;&#x2F;strong&gt;, &lt;strong&gt;Ctrl+w&lt;&#x2F;strong&gt;, etc&lt;&#x2F;li&gt;
50+
&lt;&#x2F;ul&gt;
51+
&lt;p&gt;Your progress is automatically saved and restored. Already answered questions will be skipped.&lt;&#x2F;p&gt;
52+
&lt;blockquote&gt;
53+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;warning.svg&quot; alt=&quot;warning&quot; &#x2F;&gt; There is no safeguard against the command you are executing. They are treated as if you typed them from a shell session.&lt;&#x2F;p&gt;
54+
&lt;&#x2F;blockquote&gt;
55+
&lt;p&gt;For more detailed instructions, visit &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;CLI-Exercises&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;CLI-Exercises&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
56+
&lt;br&gt;
57+
&lt;h2 id=&quot;ebook&quot;&gt;Ebook&lt;a class=&quot;zola-anchor&quot; href=&quot;#ebook&quot; aria-label=&quot;Anchor link for: ebook&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
58+
&lt;p&gt;Most of the exercises in this app is based on my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;cli-computing&quot;&gt;Computing from the Command Line&lt;&#x2F;a&gt; ebook. I hope to add all the 200+ exercises from this ebook someday.&lt;&#x2F;p&gt;
59+
&lt;br&gt;
60+
&lt;h2 id=&quot;feedback&quot;&gt;Feedback&lt;a class=&quot;zola-anchor&quot; href=&quot;#feedback&quot; aria-label=&quot;Anchor link for: feedback&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
61+
&lt;p&gt;I&#x27;d highly appreciate your feedback. Please file &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;issues&quot;&gt;an issue&lt;&#x2F;a&gt; if there are bugs, crashes, etc.&lt;&#x2F;p&gt;
62+
&lt;p&gt;Hope you find this TUI app useful. Happy learning :)&lt;&#x2F;p&gt;
63+
</content>
64+
</entry>
1065
<entry xml:lang="en">
1166
<title>Python tip 20: saving and loading json</title>
1267
<published>2022-12-07T00:00:00+00:00</published>
@@ -218,7 +273,7 @@
218273
<entry xml:lang="en">
219274
<title>Building TUIs with textual: first impressions</title>
220275
<published>2022-11-15T00:00:00+00:00</published>
221-
<updated>2022-11-22T00:00:00+00:00</updated>
276+
<updated>2022-12-09T00:00:00+00:00</updated>
222277
<link rel="alternate" href="https://learnbyexample.github.io/textual-first-impressions/" type="text/html"/>
223278
<id>https://learnbyexample.github.io/textual-first-impressions/</id>
224279
<content type="html">&lt;p&gt;Last week, I finally started exploring &lt;a href=&quot;https:&#x2F;&#x2F;textual.textualize.io&#x2F;&quot;&gt;textual&lt;&#x2F;a&gt;. The main motivation was to start implementing a few project ideas I&#x27;ve had in my todo list for years. I don&#x27;t particularly have a preference between TUI (terminal user interface) and GUI (graphical user interface) for these projects. Seeing a few Textual demos on twitter (courtesy &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;willmcgugan&quot;&gt;Will McGugan&lt;&#x2F;a&gt;) over the past few months, I felt like exploring this framework first.&lt;&#x2F;p&gt;
@@ -3518,7 +3573,7 @@
35183573
<entry xml:lang="en">
35193574
<title>Improve your Python regex skills with 75 interactive exercises</title>
35203575
<published>2021-12-01T00:00:00+00:00</published>
3521-
<updated>2021-12-01T00:00:00+00:00</updated>
3576+
<updated>2022-12-09T00:00:00+00:00</updated>
35223577
<link rel="alternate" href="https://learnbyexample.github.io/python-25-days-of-regex/" type="text/html"/>
35233578
<id>https://learnbyexample.github.io/python-25-days-of-regex/</id>
35243579
<content type="html">&lt;p&gt;Still confused about Python regular expressions? Grow your confidence with &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;py_regular_expressions&quot;&gt;Python re(gex)?&lt;&#x2F;a&gt; ebook (FREE this month!) and an &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;py_regular_expressions&#x2F;tree&#x2F;master&#x2F;interactive_exercises&quot;&gt;interactive GUI app&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
@@ -3539,6 +3594,8 @@
35393594
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;&#x2F;images&#x2F;python_exercises&#x2F;sub.png&quot; alt=&quot;Python exercise example for re.sub&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
35403595
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;&#x2F;images&#x2F;python_exercises&#x2F;split.png&quot; alt=&quot;Python exercise example for re.split&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
35413596
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;&#x2F;images&#x2F;python_exercises&#x2F;findall.png&quot; alt=&quot;Python exercise example for re.findall&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
3597+
&lt;p&gt;And here&#x27;s a brief demo:&lt;&#x2F;p&gt;
3598+
&lt;p align=&quot;center&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; loading=&quot;lazy&quot; src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;Ytz-E-rRdX4&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;&#x2F;iframe&gt;&lt;&#x2F;p&gt;
35423599
&lt;br&gt;
35433600
&lt;h2 id=&quot;25-days-of-regex&quot;&gt;25 Days Of Regex&lt;a class=&quot;zola-anchor&quot; href=&quot;#25-days-of-regex&quot; aria-label=&quot;Anchor link for: 25-days-of-regex&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
35443601
&lt;p&gt;If 75 exercises seem daunting to you, consider doing 3 exercises per day. Allocate some time everyday to read the book and complete 3 challenges.&lt;&#x2F;p&gt;

Diff for: images/textual/square_tictactoe.png

1.8 KB
Loading

0 commit comments

Comments
 (0)