From 9ce65c617a917d947d6ca3e38c74fa4691bf009f Mon Sep 17 00:00:00 2001 From: Sven Riwoldt Date: Sun, 6 Sep 2026 09:46:18 +0200 Subject: [PATCH] Codesnippets und Typst --- Codesnippets.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ LaTeX_Typst.md | 17 +++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Codesnippets.md create mode 100644 LaTeX_Typst.md diff --git a/Codesnippets.md b/Codesnippets.md new file mode 100644 index 0000000..2749919 --- /dev/null +++ b/Codesnippets.md @@ -0,0 +1,51 @@ +# Codesnippets + +## PHP + +### IPV4 --> CIDR + +```php +function subnetMaskToCidr(string $mask): int +{ + $long = ip2long($mask); + + if ($long === false) { + throw new InvalidArgumentException("Ungültige Subnetzmaske"); + } + + $cidr = 0; + + for ($i = 31; $i >= 0; $i--) { + if (($long & (1 << $i)) !== 0) { + $cidr++; + } else { + break; + } + } + + return $cidr; + +} +``` + +oder + +```php +function subnetMaskToCidr(string $mask): int +{ + $octets = explode('.', $mask); + $cidr = 0; + + foreach ($octets as $octet) { + while ($octet > 0) { + $cidr++; + $octet &= $octet - 1; + } + } + + return $cidr; + +} +``` + + diff --git a/LaTeX_Typst.md b/LaTeX_Typst.md new file mode 100644 index 0000000..a16bbd9 --- /dev/null +++ b/LaTeX_Typst.md @@ -0,0 +1,17 @@ +# LaTeX -- Typst + +## Griechische Buchstaben + +### kleine griechische Buchstaben + +| LaTeX | Vorschau | Typst | +|:-------- | -------- | ----- | +| `\alpha` | $\alpha$ | alpha | +| `\beta` | $\beta$ | beta | +| `\gamma` | $\gamma$ | gamma | +| $\delta$ | $\delta$ | delta | +| | | | + +https://qwinsi.github.io/tex2typst-webapp/cheat-sheet.html + +