Skip to content

Commit 96c12d0

Browse files
committed
feat+content: added bonus materials section with a couple of entries
1 parent e6cd59f commit 96c12d0

File tree

16 files changed

+388
-23
lines changed

16 files changed

+388
-23
lines changed

src/client/styles/header.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@
6363
margin-left: 10px;
6464
margin-right: 10px;
6565
}
66-
}
66+
}
67+
68+
@media print {
69+
.header {
70+
display: none !important;
71+
}
72+
}

src/client/styles/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ figure figcaption p {
7777
/* Page styles */
7878
.page {
7979
max-width: 100%;
80-
margin: 0 auto;
80+
margin: 0;
8181
}
8282

83-
.page h1,
83+
.page h1,
8484
article h1 {
8585
font-size: 2rem;
8686
text-align: left;

src/components/LessonLinks.astro

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { Lesson } from '../types';
33
44
export interface Props {
5-
lesson: Lesson,
5+
lesson: Pick<Lesson, 'links'>,
66
}
77
88
const { lesson } = Astro.props;
@@ -13,14 +13,25 @@ const linksEntries = Object.entries(lesson.links || {});
1313
{
1414
linksEntries.length > 0
1515
? (
16-
<h2>Useful Resources</h2>
17-
<ul>
18-
{linksEntries.map(([text, link]) => (
19-
<li><a href={link} target="_blank">{text}</a></li>
20-
))}
21-
</ul>
16+
<div class="lesson-links">
17+
<h2>Useful Resources</h2>
18+
<ul>
19+
{linksEntries.map(([text, link]) => (
20+
<li><a href={link} target="_blank">{text}</a></li>
21+
))}
22+
</ul>
23+
</div>
2224
)
2325
: <></>
2426
}
2527

28+
<style>
29+
30+
@media print {
31+
.lesson-links {
32+
display: none;
33+
}
34+
}
35+
36+
</style>
2637

src/components/LessonNavigation.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ const {
3030
)}
3131
</div>
3232
</div>
33+
34+
<style>
35+
@media print {
36+
.pagination {
37+
display: none;
38+
}
39+
}
40+
</style>

src/components/LessonOverview.astro

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22
import { baseUrl, lessonMarker, type AstroLesson } from '../helpers.astro';
33
44
export interface Props {
5+
category?: 'lesson' | 'bonus',
56
lesson: AstroLesson,
67
}
78
8-
const { lesson } = Astro.props;
9+
const { category, lesson } = Astro.props;
910
10-
const lessonUrl = `${baseUrl}lessons/${lesson.slug}`;
11+
const subPath = category == 'bonus' ? 'bonus/' : 'lessons/';
12+
13+
const lessonUrl = `${baseUrl}${subPath}${lesson.slug}`;
1114
const slidesUrl = `${baseUrl}slides/${lesson.slug}`
15+
16+
const title = category == 'bonus'
17+
? lesson.data.title
18+
: `${lessonMarker(lesson.data.state)} ${lesson.data.order}. ${lesson.data.title}`
1219
---
1320

1421
<article class="post on-list">
1522
<h2 class="post-title">
1623
<a href={lessonUrl}>
17-
{lessonMarker(lesson.data.state)} {lesson.data.order}. {lesson.data.title}
24+
{title}
1825
</a>
1926
</h2>
2027
<div class="post-meta">

src/content.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ const lessons = defineCollection({
1313
}),
1414
});
1515

16-
export const collections = { lessons };
16+
const bonus = defineCollection({
17+
type: 'content',
18+
schema: z.object({
19+
title: z.string(),
20+
description: z.string().optional(),
21+
links: z.record(z.string()).optional(),
22+
hasSlides: z.boolean().default(false),
23+
}),
24+
});
25+
26+
export const collections = { lessons, bonus };

src/content/bonus/permissions.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: 'File permissions'
3+
description: 'A short overview of file permissions'
4+
hasSlides: false
5+
links: {
6+
'Permissions in-depth': 'https://www.linuxfoundation.org/blog/blog/classic-sysadmin-understanding-linux-file-permissions',
7+
}
8+
---
9+
10+
## Access control
11+
12+
Multi-user system require a way to control what level of access
13+
each user has to a specific file or directory.
14+
15+
In Unix-like systems the access is governed through file permissions.
16+
17+
## Viewing file permissions
18+
19+
Use the `ls -l /path/to/file` to view the permissions
20+
21+
```bash
22+
ls -alh /bin/bash
23+
# prints: -rwxr-xr-x 1 root root 1.2M Aug 1 22:56 /bin/bash
24+
```
25+
26+
---
27+
28+
## How are permissions structured
29+
30+
There are 3 types of access:
31+
32+
- Read - view the contents of a file / directory
33+
- Write - modify the contents of a file / directory
34+
- Execute - execute a file (run as command) / open a directory
35+
36+
---
37+
38+
In Unix-like systems permissions are applied on 3 levels:
39+
40+
- the user owning the file
41+
- the group owning the file
42+
- anyone else
43+
44+
---
45+
46+
When listing permissions we see that are 3 triplets:
47+
48+
_spaces added for clarity_
49+
50+
```
51+
rwx r-x r--
52+
```
53+
54+
In this example:
55+
56+
- The user has full access
57+
- Members of the group can read and execute
58+
- Everyone else can only read
59+
60+
---
61+
62+
### Permissions as octal numbers
63+
64+
Another way to represent the same information is using octal numbers:
65+
66+
```
67+
rwx r-x r--
68+
69+
# same as
70+
71+
754
72+
```
73+
74+
---
75+
76+
This is achieved by assigning a unique, complimentary number to each permission and summing them:
77+
78+
- Read: 4
79+
- Write: 2
80+
- Execute: 1
81+
82+
So full access is 4+2+1 = 7
83+
84+
---
85+
86+
## Modifying permissions
87+
88+
Use the `chmod` command to set the permissions for a file / directory:
89+
90+
```bash
91+
# add the execute permissions for all levels to a file
92+
chmod +x filename
93+
94+
# remove the execute permissions for all levels to a file
95+
chmod -x filename
96+
```
97+
98+
---
99+
100+
Use the octal representation to set the full permissions of a file / directory:
101+
102+
```bash
103+
# only the owning user has full access to the file
104+
chmod 700 filename
105+
```

src/content/bonus/regex.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: 'Regular expressions'
3+
description: 'A very short primar on regular expressions'
4+
hasSlides: false
5+
links: {
6+
'Regex cheatsheet': 'https://www.rexegg.com/regex-quickstart.php',
7+
}
8+
---
9+
10+
## Regular expressions
11+
12+
Regular expressions are a powerful way to express search patterns.
13+
14+
Many languages provide a way to use them in your programs.
15+
16+
Internally, regular expressions are represented as **finite state machines**.
17+
18+
### How do regular expressions work
19+
20+
1. The interpreter / compiler parses the regular expression
21+
2. It builds the finite state machine that will make it efficient to execute the regex
22+
3. Applying the regex to an input, executes the FSM and produces matches
23+
24+
---
25+
26+
## Regex syntax basics
27+
28+
Characters:
29+
30+
```bash
31+
. # represents any character
32+
\s # represents a whites-pace character
33+
\d # represents a digit
34+
\n # represents a new line
35+
\. # represents a literal . character
36+
```
37+
38+
---
39+
40+
Qualifiers:
41+
42+
```
43+
* # represents 0 or more repetitions
44+
.* # 0 or more of any character
45+
a* # 0 or more 'a' characters
46+
47+
+ # represents 1 or more repetitions
48+
.+ # one or more of any character
49+
50+
? # represents 0 or 1 repetitions
51+
b? # 0 or 1 b characters
52+
```
53+
54+
---
55+
56+
Groupings:
57+
58+
```bash
59+
[abcxyz] # any of the given characters
60+
[a-z] # any character in the given range
61+
[^xyz] # any character other than the given
62+
```
63+
64+
---
65+
66+
Boundaries:
67+
68+
```bash
69+
^ # represents the start of a line
70+
$ # represents the end of a line
71+
```
72+
73+
---
74+
75+
## Putting it all together
76+
77+
The following regular expression selects all lines that:
78+
79+
- start with either a, b or c
80+
- have any number of any characters
81+
- do NOT end with a digit
82+
83+
```bash
84+
85+
cat my-long-file | grep -e '^[abc].*[^\d]$'
86+
87+
```
88+
89+
</bonus-content>

src/content/lessons/working-with-the-file-system.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ cd ../ # still in /
6969
cd ../../../../ # still in /
7070
```
7171

72+
<bonus-content>
73+
74+
> The file system is represented as tree structure of files and directories with the root directory at the top of the tree.
75+
76+
</bonus-content>
77+
7278
---
7379

7480
We can use a relative path to ensure we are using a local file:
@@ -137,6 +143,8 @@ ls -alh /bin/bash
137143
# prints: -rwxr-xr-x 1 root root 1.2M Aug 1 22:56 /bin/bash
138144
```
139145

146+
See [Bonus: File permissions](/bonus/permissions) for more details
147+
140148
---
141149

142150
## Path expansions
@@ -210,6 +218,32 @@ grep -e '^a.*z$' *
210218

211219
---
212220

221+
### Note on confusing syntax
222+
223+
Note that the syntax for both **path expansions** and **regular expressions** looks similar.
224+
225+
However they are very different and used in different contexts.
226+
227+
---
228+
229+
- Path expressions are performed directly by Bash
230+
231+
- Path expressions are resolved before command execution
232+
233+
- The resulting files are passed as parameters to the command
234+
235+
---
236+
237+
- Regexs are interpreted by the program / command
238+
239+
- Regexs are executed after path expansions
240+
241+
- Regexs are more powerful and applicable in more environments
242+
243+
See [Bonus: Regular Expressions](/bonus/regex) for more details
244+
245+
---
246+
213247
## Manipulating the file system
214248

215249
There are many commands that allow us to create, move, copy or delete files and directories
@@ -247,6 +281,12 @@ rm filename
247281
rm -rf useless-dir/
248282
```
249283

284+
<class-note>
285+
286+
Be careful, using this form of the `rm` can destroy your files!
287+
288+
</class-note>
289+
250290
---
251291

252292
## Redirections

src/helpers.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export async function getLessons() {
99
.sort((a, b) => a.data.order - b.data.order);
1010
}
1111
12+
export async function getBonusMaterials() {
13+
return (await getCollection('bonus'));
14+
}
15+
1216
export const baseUrl = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL : import.meta.env.BASE_URL + '/';
1317
1418
export function lessonMarker(state: keyof LessonState) {

0 commit comments

Comments
 (0)