Codesnippets und Typst

This commit is contained in:
2026-09-06 09:46:18 +02:00
parent 2a36a62377
commit 9ce65c617a
2 changed files with 68 additions and 0 deletions
+51
View File
@@ -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;
}
```
+17
View File
@@ -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