Skip to content

Commit

Permalink
feat: show glossary definitions on mouseover
Browse files Browse the repository at this point in the history
Closes #95
  • Loading branch information
gvwilson committed Jul 8, 2023
1 parent 5f27b9e commit 0bf9b70
Show file tree
Hide file tree
Showing 82 changed files with 641 additions and 611 deletions.
28 changes: 14 additions & 14 deletions docs/archive/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="repo" content="https://github.com/gvwilson/sdxpy">
<meta name="build_date" content="2023-07-07">
<meta name="build_date" content="2023-07-08">
<meta name="template" content="default">
<meta name="major" content="Chapter 10">
<meta name="has_slides" content="true">
Expand Down Expand Up @@ -361,7 +361,7 @@ <h1>Chapter 10: A File Archiver</h1>
but we&rsquo;d rather not have to.
We&rsquo;d also like to be able to see what we&rsquo;ve changed
and to collaborate with other people.</p>
<p>A <a class="gl-ref" href="../glossary/#version_control_system" markdown="1">version control system</a>
<p>A <a class="gl-ref" href="../glossary/#version_control_system" title="A system for managing changes made to software during its development." markdown="1">version control system</a>
like <span class="ix-entry" ix-key="Git;version control system" markdown="1"><a href="https://git-scm.com/">Git</a></span>
solves all of these problems at once.
It keeps track of changes to files
Expand Down Expand Up @@ -551,14 +551,14 @@ <h2 id="archive-track">Section 10.3: Tracking Backups</h2>
keeps track of which files have and haven&rsquo;t been backed up already.
It stores backups in a directory that contains files like <code>abcd1234.bck</code>
(the hash followed by <code>.bck</code>)
and creates a <a class="gl-ref" href="../glossary/#manifest" markdown="1">manifests</a>
and creates a <a class="gl-ref" href="../glossary/#manifest" title="A list of something's parts or components." markdown="1">manifests</a>
that describe the content of each snapshot.
A real system would support remote storage as well
so that losing one hard drive wouldn&rsquo;t mean losing all our work,
so we need to design our system with multiple back ends in mind.</p>
<p>For now,
we will store manifests in <span class="ix-entry" ix-key="CSV" markdown="1">CSV</span> files named <code>ssssssssss.csv</code>,
where <code>ssssssssss</code> is the <a class="gl-ref" href="../glossary/#utc" markdown="1">UTC</a> <a class="gl-ref" href="../glossary/#timestamp" markdown="1">timestamp</a>
where <code>ssssssssss</code> is the <a class="gl-ref" href="../glossary/#utc" title="The standard time against which all others are defined. UTC is the time at longitude 0°, and is not adjusted for daylight savings. Timestamps are often reported in UTC so that they will be the same no matter what timezone the computer is in." markdown="1">UTC</a> <a class="gl-ref" href="../glossary/#timestamp" title="A digital identifier showing the time at which something was created or accessed. Timestamps should use ISO date format for portability." markdown="1">timestamp</a>
of the backup&rsquo;s creation.</p>
<div class="callout">
<h3>Time of Check/Time of Use</h3>
Expand All @@ -569,15 +569,15 @@ <h3>Time of Check/Time of Use</h3>
are the result of programmers assuming things weren&rsquo;t going to happen.</p>
<p>We could try to avoid this problem by using a two-part naming scheme <code>ssssssss-a.csv</code>,
<code>ssssssss-b.csv</code>, and so on,
but this leads to a <a class="gl-ref" href="../glossary/#race_condition" markdown="1">race condition</a>
called <a class="gl-ref" href="../glossary/#toctou" markdown="1">time of check/time of use</a>.
but this leads to a <a class="gl-ref" href="../glossary/#race_condition" title="A situation in which a result depends on the order in which two or more concurrent operations are carried out." markdown="1">race condition</a>
called <a class="gl-ref" href="../glossary/#toctou" title="A race condition in which a process checks the state of something and then operates on it, but some other process might alter that state between the check and the operation." markdown="1">time of check/time of use</a>.
If two users run the backup tool at the same time,
they will both see that there isn&rsquo;t a file (yet) with the current timestamp,
so they will both try to create the first one.
Ensuring that multi-file updates are <a class="gl-ref" href="../glossary/#atomic_operation" markdown="1">atomic operations</a>
Ensuring that multi-file updates are <a class="gl-ref" href="../glossary/#atomic_operation" title="An operation that is guaranteed to complete, i.e., one that cannot be interrupted part-way through." markdown="1">atomic operations</a>
(i.e., that they always behave a single indivisible step)
is a hard problem;
<a class="gl-ref" href="../glossary/#file_locking" markdown="1">file locking</a> is a common approach,
<a class="gl-ref" href="../glossary/#file_locking" title="The act of restricting updates to a file, or its deletion, so that operations on it appear atomic." markdown="1">file locking</a> is a common approach,
but complete solutions are out of the scope of this book.</p>
</div>
<p>This function creates a backup—or rather,
Expand All @@ -593,8 +593,8 @@ <h3>Time of Check/Time of Use</h3>
</div>
<p class="continue">Writing a high-level function first
and then filling in the things it needs
is called <a class="gl-ref" href="../glossary/#successive_refinement" markdown="1">successive refinement</a>
or <a class="gl-ref" href="../glossary/#top_down_design" markdown="1">top-down design</a>.
is called <a class="gl-ref" href="../glossary/#successive_refinement" title="See top-down design." markdown="1">successive refinement</a>
or <a class="gl-ref" href="../glossary/#top_down_design" title="In software design, the practice of writing the more abstract or higher-level parts of the program first, then filling in the details layer by layer. In practice, programmers almost always modify the upper levels as they work on the lower levels, but high-level changes become less common as more of the details are filled in." markdown="1">top-down design</a>.
In practice,
nobody designs code and then implements the design without changes
unless they have solved closely-related problems before <span class="bib-ref">[<a class="bib-ref" href="../bibliography/#Petre2016">Petre2016</a>]</span>.
Expand Down Expand Up @@ -638,7 +638,7 @@ <h3>Time of Check/Time of Use</h3>
We will look at ways to fix this in the exercises as well.</p>
<div class="callout">
<h3>What Time Is It?</h3>
<p>Our <code>backup</code> function relies on a <a class="gl-ref" href="../glossary/#helper_function" markdown="1">helper function</a>
<p>Our <code>backup</code> function relies on a <a class="gl-ref" href="../glossary/#helper_function" title="A function created to support another function or functions that has no other use on its own." markdown="1">helper function</a>
called <code>current_time</code>
that does nothing but call <code>time.time</code> from Python&rsquo;s standard library:</p>
<div class="code-sample lang-py" title="backup.py">
Expand Down Expand Up @@ -698,7 +698,7 @@ <h3>What Time Is It?</h3>
</div>
<h2 id="archive-refactor">Section 10.4: Refactoring</h2>
<p>Now that we have a better idea of what we&rsquo;re doing,
we can go back and create a <a class="gl-ref" href="../glossary/#base_class" markdown="1">base class</a>
we can go back and create a <a class="gl-ref" href="../glossary/#base_class" title="In object-oriented programming, a class from which other classes are derived." markdown="1">base class</a>
that prescribes the general steps in creating a backup:</p>
<div class="code-sample lang-py" title="backup_oop.py">
<div class="highlight"><pre><span></span><code><span class="k">class</span> <span class="nc">Archive</span><span class="p">:</span>
Expand Down Expand Up @@ -727,7 +727,7 @@ <h2 id="archive-refactor">Section 10.4: Refactoring</h2>
it makes life easier when we want to write archivers
that behave the same way but work differently.
For example,
we could create an archiver that <a class="gl-ref" href="../glossary/#file_compression" markdown="1">compresses</a>
we could create an archiver that <a class="gl-ref" href="../glossary/#file_compression" title="Any of several techniques for reducing the size required to store a file. Compression works by finding patterns and replacing them with shorter sequences of bits or bytes." markdown="1">compresses</a>
files as it archives them
by deriving a new class from <code>ArchiveLocal</code>
and changing only its <code>_copy_files</code> method.</p>
Expand Down Expand Up @@ -776,7 +776,7 @@ <h3 class="exercise">JSON Manifests</h3>
<li>
<p>Write another program called <code>migrate.py</code> that converts a set of manifests
from CSV to JSON.
(The program&rsquo;s name comes from the term <a class="gl-ref" href="../glossary/#data_migration" markdown="1">data migration</a>.)</p>
(The program&rsquo;s name comes from the term <a class="gl-ref" href="../glossary/#data_migration" title="The act of moving data from one system or format to another." markdown="1">data migration</a>.)</p>
</li>
<li>
<p>Modify <code>backup.py</code> programs so that each manifest stores the user name of the person who created it
Expand Down
18 changes: 9 additions & 9 deletions docs/archive/slides/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="repo" content="https://github.com/gvwilson/sdxpy">
<meta name="build_date" content="2023-07-07">
<meta name="build_date" content="2023-07-08">
<meta name="template" content="slides">
<meta name="major" content="Chapter 10">

Expand Down Expand Up @@ -48,7 +48,7 @@ <h1>A File Archiver</h1>

- Want to save snapshots of work in progress

- Create a simple <a class="gl-ref" href="../../glossary/#version_control_system" markdown="1">version control system</a>
- Create a simple <a class="gl-ref" href="../../glossary/#version_control_system" title="A system for managing changes made to software during its development." markdown="1">version control system</a>

- And show how to test it using mock objects (<a class="x-ref" href="../../mock/">Chapter 9</a>)

Expand All @@ -62,7 +62,7 @@ <h1>A File Archiver</h1>

- Handles renaming

- Then create a <a class="gl-ref" href="../../glossary/#manifest" markdown="1">manifests</a> to show
- Then create a <a class="gl-ref" href="../../glossary/#manifest" title="A list of something's parts or components." markdown="1">manifests</a> to show
what unique blocks of bytes had what names when

---
Expand Down Expand Up @@ -131,7 +131,7 @@ <h1>A File Archiver</h1>
- But we want to test what happens when they change,
which makes things complicated to maintain

- Use a <a class="gl-ref" href="../../glossary/#mock_object" markdown="1">mock object</a> (<a class="x-ref" href="../../mock/">Chapter 9</a>)
- Use a <a class="gl-ref" href="../../glossary/#mock_object" title="A simplified replacement for part of a program whose behavior is easy to control and predict. Mock objects are used in unit tests to simulate databases, web services, and other complex systems." markdown="1">mock object</a> (<a class="x-ref" href="../../mock/">Chapter 9</a>)
instead of the real filesystem

---
Expand Down Expand Up @@ -229,7 +229,7 @@ <h1>A File Archiver</h1>
- Backed-up files are `abcd1234.bck`

- Manifests are `ssssssssss.csv`,
where `ssssssssss` is the <a class="gl-ref" href="../../glossary/#utc" markdown="1">UTC</a> <a class="gl-ref" href="../../glossary/#timestamp" markdown="1">timestamp</a>
where `ssssssssss` is the <a class="gl-ref" href="../../glossary/#utc" title="The standard time against which all others are defined. UTC is the time at longitude 0°, and is not adjusted for daylight savings. Timestamps are often reported in UTC so that they will be the same no matter what timezone the computer is in." markdown="1">UTC</a> <a class="gl-ref" href="../../glossary/#timestamp" title="A digital identifier showing the time at which something was created or accessed. Timestamps should use ISO date format for portability." markdown="1">timestamp</a>

---

Expand All @@ -239,7 +239,7 @@ <h1>A File Archiver</h1>

- Manifest naming scheme fails if we try to create two backups in less than one second

- A <a class="gl-ref" href="../../glossary/#toctou" markdown="1">time of check/time of use</a> <a class="gl-ref" href="../../glossary/#race_condition" markdown="1">race condition</a>
- A <a class="gl-ref" href="../../glossary/#toctou" title="A race condition in which a process checks the state of something and then operates on it, but some other process might alter that state between the check and the operation." markdown="1">time of check/time of use</a> <a class="gl-ref" href="../../glossary/#race_condition" title="A situation in which a result depends on the order in which two or more concurrent operations are carried out." markdown="1">race condition</a>

- May seem unlikely, but many bugs and security holes seemed unlikely to their creators

Expand All @@ -257,7 +257,7 @@ <h1>A File Archiver</h1>
```


- An example of <a class="gl-ref" href="../../glossary/#successive_refinement" markdown="1">successive refinement</a>
- An example of <a class="gl-ref" href="../../glossary/#successive_refinement" title="See top-down design." markdown="1">successive refinement</a>

---

Expand Down Expand Up @@ -340,7 +340,7 @@ <h1>A File Archiver</h1>

## Refactoring

- Create a <a class="gl-ref" href="../../glossary/#base_class" markdown="1">base class</a> with the general steps
- Create a <a class="gl-ref" href="../../glossary/#base_class" title="In object-oriented programming, a class from which other classes are derived." markdown="1">base class</a> with the general steps

```py
class Archive:
Expand All @@ -355,7 +355,7 @@ <h1>A File Archiver</h1>
```


- Derive a <a class="gl-ref" href="../../glossary/#child_class" markdown="1">child class</a> to do local archiving
- Derive a <a class="gl-ref" href="../../glossary/#child_class" title="In object-oriented programming, a class derived from another class (called the parent class)." markdown="1">child class</a> to do local archiving

- Convert functions we have built so far into methods

Expand Down
2 changes: 1 addition & 1 deletion docs/bib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="repo" content="https://github.com/gvwilson/sdxpy">
<meta name="build_date" content="2023-07-07">
<meta name="build_date" content="2023-07-08">
<meta name="template" content="default">
<meta name="major" content="Appendix A">

Expand Down
Loading

0 comments on commit 0bf9b70

Please sign in to comment.