Skip to content

Commit

Permalink
Update moar things
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkomiu committed Mar 1, 2024
1 parent 08fcf68 commit f96e022
Show file tree
Hide file tree
Showing 19 changed files with 1,541 additions and 196 deletions.
1 change: 1 addition & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ UKI
Chroot
Modeset
NOUVEAU
ExploitDB
10 changes: 3 additions & 7 deletions assets/css/base.css → assets/css/entry.base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
@import "tailwindcss/components";
@import "tailwindcss/utilities";

@import "katex/dist/katex";

@import "assets/css/hack";
@import "assets/css/prose";

@import "assets/css/author";
@import "assets/css/post";
@import "assets/css/pagefind";
@import "assets/css/footer.css";
@import "assets/css/highlight.css";
@import "assets/css/pagination.css";

/* @import "https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap"; */
@import "assets/css/footer";
@import "assets/css/highlight";
@import "assets/css/pagination";

::selection {
@apply bg-fuchsia-900 text-fuchsia-50;
Expand Down
1 change: 1 addition & 0 deletions assets/css/entry.latex.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "katex/dist/katex";
12 changes: 12 additions & 0 deletions assets/css/prose.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
@apply mt-12 relative;
}

.prose samp pre {
@apply flex rounded-none bg-black text-green-600 border border-green-800 px-4 pb-2 pt-5;
}

.prose .highlight pre,
.prose .highlight code {
@apply text-fuchsia-500;
Expand Down Expand Up @@ -155,3 +159,11 @@
.prose .highlight table code {
@apply p-0;
}

.prose .highlight td:first-of-type pre {
@apply mr-4;
}

.prose .mermaid {
@apply bg-neutral-300 mx-auto;
}
8 changes: 0 additions & 8 deletions assets/js/base.js → assets/js/entry.base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "@hotwired/turbo";
import katexAutoRender from "katex/contrib/auto-render";

import { displayLanguageTabs, loadCodeActions } from "./code";
import { loadMenu } from "./menu";
Expand Down Expand Up @@ -32,13 +31,6 @@ function onPageLoad() {

loadCodeActions();

katexAutoRender(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false },
],
});

displayLanguageTabs();
sectionExpandToggle();
}
Expand Down
12 changes: 12 additions & 0 deletions assets/js/entry.latex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import katexAutoRender from "katex/contrib/auto-render";

function onPageLoad() {
katexAutoRender(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false },
],
});
}

window.addEventListener("turbo:load", onPageLoad);
7 changes: 7 additions & 0 deletions assets/js/entry.mermaid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import mermaid from "mermaid";

function onPageLoad() {
mermaid.initialize({ startOnLoad: true });
}

window.addEventListener("turbo:load", onPageLoad);
42 changes: 41 additions & 1 deletion content/guides/secure-debian/0-usb-installation-specifics.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,50 @@ not using USB storage for your Debian installation, you can safely skip this sec
During the regular installation, I'll be using the path `/EFI/my-debian/Linux.efi` for the Unified Kernel Image that
gets created in our EFI partition. However, in order to make UEFI recognize that the USB storage is bootable, we need
to use the "default" path that UEFI will use to look for an EFI. So, according to the
[EFI Spec](https://uefi.org/sites/default/files/resources/UEFI%20Spec%202.8B%20May%202020.pdf#page=573), we need to use:
[EFI Spec (page 573)](https://uefi.org/sites/default/files/resources/UEFI%20Spec%202.8B%20May%202020.pdf#page=573):

> For removable media devices there must be only one UEFI-compliant system partition, and that partition
> must contain an UEFI-defined directory in the root directory. The directory will be named EFI. All OS
> loaders and applications will be stored in a subdirectory below EFI called BOOT. There must only be one
> executable EFI image for each supported processor architecture in the BOOT directory.
We need to use the following path for the UKI file on the USB drive instead:

```bash
/EFI/BOOT/BOOTX64.EFI
```

> **Note:** If you're not using an x86_64 processor you'll need to use the appropriate filename for your architecture.
You could also do this for a non-portable installation. However, when using an internal drive, it's generally better to
use the "custom" paths and add the boot entry manually. This is because the UEFI firmware will generally have a boot
menu that will allow you to select the boot device. It will also allow us to maintain the "old" boot entry for the
previous kernel version in case we need to roll back an upgrade.

Keep in mind that by using the "default" path, we won't have the ability to maintain multiple kernel versions on the
same USB drive. This is because the UEFI firmware will only look for the one file in the `EFI/BOOT` directory that
matches our CPU architecture. In order to add the "old" kernel version, we need to either manually execute it from the
UEFI shell or install, and **sign** the `systemd-boot` boot manager EFI as the "default" entry to give us a menu for
selecting a specific kernel to load.

## CPU Microcode

Linux relies on _microcode_ packages that are used to fix bugs in the CPU architecture. They are loaded into the kernel
(or in our case the UKI) at boot. When using a portable Linux installation, we need to make sure that we add the
missing microcode packages to the installation. We only need the missing one(s) that we plan to support because the
installation of Debian will handle installing the microcode package for the CPU architecture that we've installed on.

To add the **AMD** microcode run:

```bash
apt install amd64-microcode
```

To add the **Intel** microcode run:

```bash
apt install intel-microcode
```

> **Note:** Some Linux distros will include both x64 microcode packages by default. So you may not _need_ to run these
> commands. However, I generally find it to be a good idea to run them just to be sure that they're added to the kernel.
64 changes: 41 additions & 23 deletions content/notes/machine-learning/cpp/cpp-02-linear-algebra/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,40 @@ This will cover some basic linear algebra terms, concepts, and algorithms that a
- **Scalar:** This is a single number.
- **Vector:** This is an array of ordered numbers. Each element has a distinct index.
Notation is a bold lowercase typeface for names and an italic typeface with subscript for elements:
$$ \vec{p} = \begin{bmatrix} x*{1} \\\\ x*{2} \\\\ . \\\\ . \\\\ x\_{n} \end{bmatrix} $$

```latex
\vec{p} = \begin{bmatrix} x*{1} \\ x*{2} \\ . \\ . \\ x_{n} \end{bmatrix}
```

- **Matrix:** A two-dimensional array of numbers. Each element has a distinct pair of indices.
Notation is a bold uppercase typeface for names and italic but not bold typeface with comma-separated list of indices
in subscript for elements:

$$
A = \begin{bmatrix}
A_{1,1} & A_{1,2} \\\\
A_{2,1} & A_{2,2} \\\\
A_{3,1} & A_{3,2} \end{bmatrix}
$$
```latex
A =
\begin{bmatrix}
A_{1,1} & A_{1,2} \\
A_{2,1} & A_{2,2} \\
A_{3,1} & A_{3,2}
\end{bmatrix}
```

- **Tensor:** An array of numbers arranged in a multi-dimensional regular grid. Represents generalizations of matrices.
It's like a multi-dimensional matrix. For example, tensor $A$ with dimensions $ 2 \times 2 \times 2 $ can look like:
$$

```latex
A =
\begin{bmatrix}
\begin{bmatrix} 1 & 2\\\\ 3 & 4 \end{bmatrix} \\\\
\begin{bmatrix} 5 & 6\\\\ 7 & 8 \end{bmatrix}
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix} \\
\begin{bmatrix}
5 & 6 \\
7 & 8
\end{bmatrix}
\end{bmatrix}
$$
```

A vector can also be considered a matrix of size $ n \times 1 $.

Expand All @@ -52,21 +64,27 @@ These are some of the most common operations for linear algebra in ML:
- **Element-wise operations:** These are operations that are applied to each element of a vector or matrix.
- **Dot product:** This is the sum of the products of the corresponding entries of the two sequences of numbers.
For example, the dot product of vectors $ \vec{a} $ and $ \vec{b} $ is:
$$ \vec{a} \cdot \vec{b} = \sum*{i=1}^{n} a*{i} b\_{i} $$

```latex
\vec{a} \cdot \vec{b} = \sum*{i=1}^{n} a*{i} b_{i}
```

- **Transposing:** The transpose of a matrix flips the matrix over its diagonal.
For example, the transpose of matrix $ A $ is:
$$

```latex
A^{T} =
\begin{bmatrix}
1 & 3 & 5 \\\\
1 & 3 & 5 \\
2 & 4 & 6
\end{bmatrix}^{T} =
\begin{bmatrix}
1 & 2 \\\\
3 & 4 \\\\
1 & 2 \\
3 & 4 \\
5 & 6
\end{bmatrix}
$$
```

- **Norm:** This calculates the size of a vector.
- **Inverting:** This is the process of finding the inverse of a matrix.

Expand All @@ -81,21 +99,21 @@ sequential data more efficiently. SIMD instructions allow for parallelization of

Consider the following matrix for both row and column-major ordering sections below:

$$
```latex
A =
\begin{bmatrix}
a_{1,1} & a_{1,2} & a_{1,3} \\\\
a_{1,1} & a_{1,2} & a_{1,3} \\
a_{2,1} & a_{2,2} & a_{2,3}
\end{bmatrix}
$$
```

$$
```latex
B =
\begin{bmatrix}
1 & 2 & 3 \\\\
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
$$
```

### Row-major Order

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ m1 << 1, 2, 3,

Which will fill the matrix as:

$$
```latex
m1 =
\begin{bmatrix}
1 & 2 & 3 \\\\
4 & 5 & 6 \\\\
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
$$
```

Elements can be directly accessed using the `()` operator:

Expand Down Expand Up @@ -136,35 +136,31 @@ m.block(1, 1, 2, 2) *= 4; // changes the values in the original matrix
This is equivalent to:
$$
```latex
M =
\begin{bmatrix}
m_{0,0} & m_{0,1} & m_{0,2} & m_{0,3} \\\\
m_{1,0} & m_{1,1} & m_{1,2} & m_{1,3} \\\\
m_{2,0} & m_{2,1} & m_{2,2} & m_{2,3} \\\\
m_{0,0} & m_{0,1} & m_{0,2} & m_{0,3} \\
m_{1,0} & m_{1,1} & m_{1,2} & m_{1,3} \\
m_{2,0} & m_{2,1} & m_{2,2} & m_{2,3} \\
m_{3,0} & m_{3,1} & m_{3,2} & m_{3,3}
\end{bmatrix}
$$
```

$$
```latex
B =
\begin{bmatrix}
m_{1,1} & m_{1,2} \\\\
m_{1,1} & m_{1,2} \\
m_{2,1} & m_{2,2}
\end{bmatrix}
$$
<!-- markdownlint-disable -->
```

$$
```latex
B = B * 4 =
\begin{bmatrix}
m_{1,1} * 4 & m_{1,2} * 4 \\\\
m_{1,1} * 4 & m_{1,2} * 4 \\
m_{2,1} * 4 & m_{2,2} * 4
\end{bmatrix}
$$
<!-- markdownlint-enable -->
```

There are also methods for accessing rows and columns by index (which is a specific type of block operation):

Expand All @@ -183,17 +179,17 @@ mat.colwise() += v; // adds v to each column of mat
This operation is equivalent to:
$$
```latex
\begin{bmatrix}
1 & 2 & 3 \\\\
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix} .colwise() +
\begin{bmatrix}
0 \\\\
0 \\
1
\end{bmatrix} =
\begin{bmatrix}
1 & 2 & 3 \\\\
1 & 2 & 3 \\
\textbf{5} & \textbf{6} & \textbf{7}
\end{bmatrix}
$$
```
8 changes: 4 additions & 4 deletions content/notes/machine-learning/e2e-project/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ With this information in mind, we can determine the following:

A typical performance measure for regression problems is the Root Mean Square Error (RMSE).

$$
```latex
\text{RMSE}(\mathbf{X}, h) = \sqrt{\frac{1}{m} \sum_{i=1}^{m} \left(h(\mathbf{x}^{(i)}) - y^{(i)}\right)^2}
$$
```

It measures the standard deviation of the errors the system makes in its predictions.

Both the RMSE and the Mean Absolute Error (MAE) are ways to measure the distance between two vectors:
the vector of predictions and the vector of target values.

$$
```latex
\text{MAE}(\mathbf{X}, h) = \frac{1}{m} \sum_{i=1}^{m} \left| h(\mathbf{x}^{(i)}) - y^{(i)} \right|
$$
```

Various distance measures are possible, but the RMSE is more sensitive to outliers than the MAE.
Other distance measures, or _norms_, are possible:
Expand Down
8 changes: 8 additions & 0 deletions content/notes/thm/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: TryHackMe
author: Nikko Miu
date: 2024-02-29T01:00:00Z
showAllSubpages: true
tags:
- thm
---
8 changes: 8 additions & 0 deletions content/posts/my-second-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ suspendisse potenti nullam ac. Tincidunt id aliquet risus feugiat in. Varius
quam quisque id diam vel. Egestas erat imperdiet sed euismod nisi. Scelerisque
felis imperdiet proin fermentum leo vel orci porta non. Ut faucibus pulvinar
elementum integer. Fermentum odio eu feugiat pretium nibh ipsum consequat nisl.

```mermaid
flowchart TD
A[Square Rect] -- Link text --> B((Circle))
A --> C(Round Rect)
B --> D{Rhombus}
C --> D
```
4 changes: 4 additions & 0 deletions layouts/_default/_markup/render-codeblock-latex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ .Page.Store.Set "hasLatex" true }}
$$
{{ .Inner | safeHTML }}
$$
Loading

0 comments on commit f96e022

Please sign in to comment.