Posts

Jetporch - Jet

Intro did you ever heared of Jetporch, short Jet ? Don’t worry, you’re not the only one ;) Jet Project of Jet is being led by Michael DeHaan, the original creator of Ansible. So, expect something like Ansible, faster, written in rust … same same, but different. Installation on Debian 12 grab a fresh machine and patch it export DEBIAN_FRONTEND=noninteractive apt-get clean apt-get autoclean apt-get update -y apt-get upgrade -yq apt-get dist-upgrade -yq apt-get autoremove -y Install Rust from Source jet needs rustc 1.

Poetry Packages

Let’s play with Packages and Libraries References Python Modules Poetry Scripts Switch to Root Folder cd /some/path/you/want Create a new Package poetry new mypackage add some libraries poetry add requests … add some code … cat << 'EOF' > mypackage/__init__.py print("importing", __name__) EOF cat << 'EOF' > mypackage/main.py print("importing", __name__) def test1(): print("test1") def test2(name: str): print("hello", name) def test3(name: str, age:int): print(f"Hello {name} at age {age}") if __name__ == "__main__": print("This is a Library or Package.

Hugo Table

How to add a Table to Hugo Create Table Shortcode cat <<'EOF'> layouts/shortcodes/table.html {{ $htmlTable := .Inner | markdownify }} {{ $class := .Get 0 }} {{ $old := "<table>" }} {{ $new := printf "<table class=\"%s\">" $class }} {{ $htmlTable := replace $htmlTable $old $new }} {{ $htmlTable | safeHTML }} </table> EOF Build Table add this to your Markdown File … | a | b | c | | - | - | - | | bli | bla | blu | | green | blue | red | Result a b c bli bla blu green blue red Align Left | a | b | c | | :- | :- | :- | | bli | bla | blu | | green | blue | red | Result a b c bli bla blu green blue red Align Right | a | b | c | | -: | -: | -: | | bli | bla | blu | | green | blue | red | Result a b c bli bla blu green blue red Any Comments ?

Debian behind TLS Proxy

Behind Corp Proxy let’s assume you’re behing a Corp Proxy which enforce TLS Inspection, you don’t have the Proxy Cert and you want to Upgrade your Boxes … … and of course, you do this in the LAB and for Research only and not your Productiv Environment! TLS Inspection enabled apt-get upate W: Failed to fetch https://packages.sury.org/php/dists/bookworm/InRelease Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification.

Python TinyDB

Storing Data in JSON - TinyDB Small Example how to Store Data in JSON, and Query them afterwards like a NOSQL DB. Have a look at TinyDB if you wanna see more. Code from tinydb import TinyDB, Query from pprint import pprint # Create or load a database file db = TinyDB('db.json') # insert some sample data def insert(): # Insert data db.insert({'name': 'John', 'age': 30}) db.insert({'name': 'Alice', 'age': 25, 'hobbies': 'sleep'}) db.

Fastapi Project Template

Project Template for FastAPI gave a try with a FastAPI Template, https://github.com/rochacbruno/fastapi-project-template.git Projectname: gugus1234 clone the repo git clone https://github.com/rochacbruno/fastapi-project-template.git gugus1234 cd gugus1234 Switch Poetry i’d like to have poetry as virtual env manager make switch-to-poetry Rename some Stuff had to rename some string in pyproject and different files … mv project_name gugug1234 gsed -i 's/a-flask-test/gugus1234/' pyproject.toml gsed -i 's/project_name/gugus1234/' pyproject.toml gsed -i 's/project_name/gugus1234/g' gugus1234/cli.py gugus1234/app.py gugus1234/config.py gugus1234/security.py Run Poetry once poetry shell poetry lock poetry install Admin User let’s create admin user

Fastapi Simple Security

How to Protect your App with Simple Security Let’s build a small API Endpoint with FastAPI and protect it with SimpleSecurity. API key based security package for FastAPI, focused on simplicity of use: Full functionality out of the box, no configuration required API key security with local sqlite backend, working with both header and query parameters Default 15 days deprecation for generated API keys Key creation, revocation, renewing, and usage logs handled through administrator endpoints No dependencies, only requiring FastAPI and the python standard library Build new App and show the Directory Structure

Restricted Shell

Restricting User to Script Let’s assume you have some Users around and they should be able to run certain Scripts. These Scripts do various things, login to some systems, perform task, get data from an API, whatever you want. All these Actions needs Credentials which must be available to the script, although they are not part of the Script. They could be Provides via OS Env, .env File, Encrypted Password Store or whatever.

SSH LogLevels

Log Levels for SSH In SSH, the LogLevel option allows you to control the level of logging information generated by the SSH client and server. There are several log levels you can use to adjust the verbosity of SSH logging. Here are the most commonly used log levels: QUIET: Suppresses all log messages, except for fatal errors. It provides the least amount of information. FATAL: Logs only fatal errors, indicating severe issues that may prevent the SSH session from being established.

Python Ping3

Need a Litte Ping Function ? Test cat <<'EOF'> ping.py import argparse from ping3 import ping, verbose_ping def do_ping(host: str, timeout: int = 3, size: int = 1500, output: str = "json"): # output: json|txt # '21.54 ms' if size > 1500: size = 1500 result = ( str( round( ping(dest_addr=host, timeout=timeout, size=size, unit="ms"), 2, ) ) + " ms" ) if output.lower() == "json": return {"host": host, "timeout": timeout, "size": size, "result": result} if output.