FastAPI - Dependencies and Custom Headers Source Code from fastapi import Depends, FastAPI, Header, HTTPException app = FastAPI() async def verify_token(x_token: str = Header()): if x_token != "fake-super-secret-token": raise HTTPException(status_code=400, detail="X-Token header invalid") async def verify_key(x_key: str = Header()): if x_key != "fake-super-secret-key": raise HTTPException(status_code=400, detail="X-Key header invalid") return x_key @app.get("/items/", dependencies=[Depends(verify_token), Depends(verify_key)]) async def read_items(): return [{"item": "Foo"}, {"item": "Bar"}] Test’s Failed no Custom Header curl -s http://localhost/api/items/ |jq { "detail": [ { "loc": [ "header", "x-token" ], "msg": "field required", "type": "value_error.

Ruby on Rails Install Ruby Install Ruby and set Symlinks doas su - pkg_add ruby-3.1.2 ln -sf /usr/local/bin/ruby31 /usr/local/bin/ruby ln -sf /usr/local/bin/bundle31 /usr/local/bin/bundle ln -sf /usr/local/bin/bundler31 /usr/local/bin/bundler ln -sf /usr/local/bin/erb31 /usr/local/bin/erb ln -sf /usr/local/bin/gem31 /usr/local/bin/gem ln -sf /usr/local/bin/irb31 /usr/local/bin/irb ln -sf /usr/local/bin/rdoc31 /usr/local/bin/racc ln -sf /usr/local/bin/rake31 /usr/local/bin/rake ln -sf /usr/local/bin/rdoc31 /usr/local/bin/rbs ln -sf /usr/local/bin/rdoc31 /usr/local/bin/rdbg ln -sf /usr/local/bin/rdoc31 /usr/local/bin/rdoc ln -sf /usr/local/bin/ri31 /usr/local/bin/ri ln -sf /usr/local/bin/typeprof31 /usr/local/bin/typeprof Install Nokogiri pkg_add ruby31-nokogiri-1.13.1p0 Install Rails pkg_add ruby-3.

Git Tags

With Tags, we have the possibility to “Tag” a certain Point as important. Just give it a release Number (v0.1, v0.2, v1.0) or whatever you like. list tags list all tags for a certain repo git tag add Tag when you’re fine with a version, add a tag … git tag -a v1.0 -m "my Version 1.0" push Tags you have to push the Tags separatly. they do not get pushed with the common “git push” command

Go CrossCompile

Crosscompile under GoLang Python is cool and everybody like it, but i also like the Concept of writing some Code, compile it for different Platforms and run it everywhere. Google’s Go Language got the possiblity to compile it for multiple Architectures and Operating Systems at the same time. Why not give a try … ? Little Hello World package main import ( "fmt" "os" ) func main() { s := "world" if len(os.


{ “[python]”: { “editor.defaultFormatter”: “charliermarsh.ruff”, “editor.formatOnSave”: true, “editor.codeActionsOnSave”: { “source.organizeImports”: “explicit”, “source.fixAll”: true }, }, } settings.json Useful Settings for VSCode … settings.json test -d .vscode || mkdir .vscode test -f .vscode/settings.json && mv .vscode/settings.json .vscode/settings.json-$(date +%s) cat << 'EOF' > .vscode/settings.json { "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": "explicit", "source.fixAll": true }, }, } EOF settings.json (old) test -d .vscode || mkdir .vscode cat << 'EOF' > .

Little Mail Validator in Python

wrote a little Mail Adresse Validator in Python. use it, modify it, like it … best practice for python is to use a virtual env like Poetry (or virtualenv) and add the “email-validator” module like this: poetry add email-validator Code few lines of code … #!/usr/bin/env python3 from email_validator import validate_email, EmailNotValidError ok=[] nok=[] emails = [ "my+address@mydomain.tld", "", "", "", "asf.asdf", "franz!", "asdf@asdf.adf" ] print ("\nMy Little Mail Validator\n") for email in emails: try: # Validate.


some stuff i learned about the “C” Language -> DataTypes Char to Store one single Character #include<stdio.h> int main() { char zeichen1; char zeichen2; zeichen1 = 'A'; zeichen2 = 66; printf("Zeichen: %c, %c\n", zeichen1, zeichen2 ); return 0; } Zeichen: A, B Short / unsigned short #include<stdio.h> int main() { // kleine Zahl mit Vorzeichen deklarieren (erstellen) short kleineZahl; // kleine Zahl auf Grenzwert setzen kleineZahl = 32767; // kleineZahl ausgeben printf("Wert von kleineZahl: %d\n", kleineZahl); // eins hochzählen, also 32767+1, was eigentlich 32768 ergibt kleineZahl++; // kleineZahl ausgeben printf("Wert von kleineZahl: %d\n", kleineZahl); return 0; } Wert von kleineZahl: 32767 Wert von kleineZahl: -32768 int 16 or 32 Bit, depending on Architectur

Regex IPv4 & IPv6

Regex is cool. But have you ever tried to grep IPv4 / IPv6 Adresses from a File or extract from a bunch of data ? Did you use Google Search and found lot of Links, Tip’s and Examples ? And non of them worked well ? I can highly recommend CyberChef for stuff like that … Regex from CyberChef If you wanna use Regex in your own Scripts, here is a little Extract from Cyberchef.


1. Intro Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Links Install on OpenBSD Wanna Install on OpenBSD ? # get root doas su - Install as Root # Install Poetry pip3 install --user poetry # on error PEP 668: #pip3 install --user poetry --break-system-packages # Update Poetry pip3 install poetry -U # Update Profile cat << EOF >> ~/.

Puffy Spezial

Tips, Trick, Notes and Snippets around OpenBSD Get Interfaces ifconfig | awk '/^[^\t]/{iface=$1} /inet6? / {print iface, $2}' lo0: ::1 lo0: fe80::1%lo0 lo0: vio0: fe80::9400:2ff:fe16:5a70%vio0 vio0: 2a01:4f8:c0c:fff7::2 vio0: Adding Static Default GW man route route add -inet default route add -inet6 default 2001:db8:efef::1 Use Puffy as Jumphost Redirect incomming Traffic from a certain Source and also NAT the Outgoing Traffic so we remain in the “Line” ;)