From 55c61202ea7501cbd75b5b48c574c857e8881c87 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 4 Jun 2024 21:45:27 +0200 Subject: initial commit --- 2023/gemini-server-mit-php-programmieren.gmi | 116 +++++++++++++++++++++ ...label-mit-libreoffice-spreadsheet-erstellen.gmi | 49 +++++++++ 2 files changed, 165 insertions(+) create mode 100644 2023/gemini-server-mit-php-programmieren.gmi create mode 100644 2023/label-mit-libreoffice-spreadsheet-erstellen.gmi (limited to '2023') diff --git a/2023/gemini-server-mit-php-programmieren.gmi b/2023/gemini-server-mit-php-programmieren.gmi new file mode 100644 index 0000000..44ee6c6 --- /dev/null +++ b/2023/gemini-server-mit-php-programmieren.gmi @@ -0,0 +1,116 @@ +do it like this lol +=> https://git.dweipert.de/gemini-foundation/tree/src/Server.php + +``` + null, + 'key' => null, + 'passphrase' => null, + ]; + + protected array $requestHandlers = []; + + /** + * @param array $certificate + * @param string $hostname + */ + public function __construct( + array $certificate, + string $hostname = 'localhost' + ) + { + $this->certificate = $certificate; + $this->hostname = $hostname; + } + + public function setCertificate(string $certificateFile, string $keyFile, string $passphrase = ''): static + { + $this->certificate = [ + 'file' => $certificateFile, + 'key' => $keyFile, + 'passphrase' => $passphrase, + ]; + + return $this; + } + + public function onRequest(RequestHandlerInterface|callable $callable): static + { + $this->requestHandlers[] = $callable; + + return $this; + } + + public function listen(int $port = 1965): void + { + $context = stream_context_create(options: [ + 'ssl' => [ + 'local_cert' => $this->certificate['file'], + 'local_pk' => $this->certificate['key'], + 'passphrase' => $this->certificate['passphrase'], + + 'allow_self_signed' => true, + 'verify_peer' => false, + ], + ]); + + $socket = stream_socket_server( + address: "tls://{$this->hostname}:{$port}", + context: $context + ); + + $connections = []; + + while (true) { + $connection = stream_socket_accept( + socket: $socket, + timeout: empty($connections) ? -1 : 0, + peer_name: $peer + ); + + if ($connection) { + $connections[$peer] = $connection; + } + + if (count($connections) == 0) { + continue; + } + + $streams = stream_select( + read: $connections, + write: $write, + except: $except, + seconds: 5 + ); + + if ($streams) { + foreach ($connections as $peer => $connection) { + if (feof($connection)) { + fclose($connection); + unset($connections[$peer]); + continue; + } + + $request = Request::fromResource($connection); + $response = new Response(); + foreach ($this->requestHandlers as $requestHandler) { + $response = $requestHandler($response, $request); + } + $response->send($connection); + + fclose($connection); + unset($connections[$peer]); + } + } + } + } +} +``` diff --git a/2023/label-mit-libreoffice-spreadsheet-erstellen.gmi b/2023/label-mit-libreoffice-spreadsheet-erstellen.gmi new file mode 100644 index 0000000..c5813e1 --- /dev/null +++ b/2023/label-mit-libreoffice-spreadsheet-erstellen.gmi @@ -0,0 +1,49 @@ +# Label mit LibreOffice aus Spreadsheet erstellen + + +Folgender Use-Case wird dargestellt: +* Benötigt werden Schilder für die Bilder bei einer Kunstausstellung +* Die Schilder sollen möglichst platzsparend ausdruckbar sein +* Daten liegen als Zeilen in einer Excel-Datei vor + + +## 1. Excel-Datei in ods-Datei umwandeln + +Excel-Datei einfach in LibreOffice Calc öffnen +und dann als .ods Speichern + + +## 2. Datenbank aus ods-Datei erzeugen + +* LibreOffice Writer öffnen +* File > Wizards > Address Data Source + +* Other external data source +* Settings > Database type: Spreadsheet > ods Datei auswählen +* "Tabelle", also Sheet auswählen +* "Field Assignment" überspringen +* "Data Source Title" = Name der Datenbank + + +## 3. Label erstellen + +* LibreOffice Writer Instanz weiterverwenden +* File > New > Labels + +### 3.1 Labels > Inscription + +* "Database", "Table" und "Database field" auswählen > Auf Pfeil nach links klicken um Felder ins Label zu schreiben +* Das "Label text" Feld ist ein Freitext-Feld, kann also beliebig arrangiert werden + +### 3.2 Labels > Format + +Brand: "A-one" +Type: Keine Ahnung welcher der "richtige" A4-Type ist, der erste taugt + +Auf "New Document" klicken + + +## 4. PDF erzeugen + +=> /img/2023/label-mit-libreoffice-aus-spreadsheet-erstellen-4.png "Save Merged Documents" +"Save as a single large document" > "Save Documents" -- cgit v1.2.3