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 + +