34.1. Examples#

Starting to re-organize this, to just past in simple examples so there is one place to find them

34.1.1. Notes and warnings#

Note

We recommend you look at this notebook as the best example of generating content, and we will make a valiant attempt to keep it up to date as we gain more experience. Having said that, the file system chapter today probably has a better set of examples

Warning

It is really easy to waste months with all the degrees of freedom with this authoring model, and we will try to be prescriptive on how we use the tools, so we recommend you jump straight to the tutorial directions on authoring material.

Note

This is an example of a note, in a warning, in a note.


34.1.2. Figures#

As shown in figure Fig. 34.1, most operating systems today have …

../_images/osstructure-1.dio.png

Fig. 34.1 A caption for figure#

For more on figures look at this reference.

34.1.3. Table#

Value

Binary Prefix

Abbreviation

\(1024 = 2^{10}\)

kilo

K

\(1024^2 = 2^{20}\)

mega

M

\(1024^3 = 2^{30}\)

giga

G

\(1024^4 = 2^{40}\)

tera

T

\(1024^5 = 2^{50}\)

peta

P

As shown in ex:table_ref

Function

Reference

Brief Description

mmap()

man 2 mmap

Allocates a page of virtual memory

munmap()

man 2 munmap

Deallocates a page of virtual memory

Could use Pandas from this style guild

import pandas as pd
import numpy as np
import matplotlib as mpl

df = pd.DataFrame({
    "strings": ["Adam", "Mike"],
    "ints": [1, 3],
    "floats": [1.123, 1000.23]
})
df.style \
  .format(precision=3, thousands=".", decimal=",") \
  .format_index(str.upper, axis=1) \
  .relabel_index(["row 1", "row 2"], axis=0)
  STRINGS INTS FLOATS
row 1 Adam 1 1,123
row 2 Mike 3 1.000,230

At the end of this section we have links to various reference materials, for example, sections of Jonathan’s textbook that we plan to steal materials from.

34.1.4. Authoring content#

34.1.4.1. Using jupyterlab#

Will put various hints here on what we find works, although for the most part like any editor, you will gradually experience what works best for you.

  • there seems to be just one file browser, I tend to open multiple links to the textbook:

    1. for the place I am actually authoring

    2. for a browser to move around, look at examples

    3. for the rendered book/result

  • we might want to build some simple vidios/todos

34.1.4.2. Adding figures#

Use draw.io for open source software, I download the desktop version from here since it seems more reliable. You can just download the image to your desktop, edit it there, and upload it again. You can Please use png as the source type of the file, rather than the default drawio; in this case it will create a XXX.drawio.png file, where the diagram is embedded in the png, so you can both dispay it, and edit it. This means you can not only continue to edit the file directly, but can also include exactly the same file in a figure.

Tricks I have found in using this:

  1. with the desktop version you can directly copy images browser see this vidio

  2. I tend to use layers, for animation, then upload it and generate multiple png files form the same image

  3. You very much want to export the picture as high-resolution, by using a large zoom, see Figure Fig. 34.4

../_images/draw-io-control-resolution.png

Fig. 34.2 Making images high resolution.#

If you use the drawio embedded in the notebook environment, to generate a png rather than using the file export from the figure, use the command palette from jupyter “view” menue as shown in figures Fig. 34.3 and Fig. 34.4.

../_images/drawio-export-1.png

Fig. 34.3 Activate Command Palette to export drawio figure as png.#

../_images/drawio-export-2.png

Fig. 34.4 Export drawio figure as png.#

Note, this is strongly discouraged, since I don’t see any way to fix the resolution so that the images don’t suck. I end up exporting from draw.io at 500% to get pictures to look reasonable.

We use the figure directive in myst, so the following:


```{figure} ../images/osstructure-1.drawio.png
---
width: 50%
name: fcontrib:fig:examp
align: right
---
A caption for figure
```

Results in this: