Alpine - Pandas on Docker Image

How to install Pandas on Alpine Linux Run Alpine Container docker run -it alpine add packages apk update apk add python3 py3-pip gcc python3-dev g++ add / build pandas time pip install pandas real 26m 13.14s user 30m 46.40s sys 3m 27.51s Happy Pandas ! sha256: afb99c7e3ed003bee48b65795a153c4fe7835fe3dae0759b70ab2bfb5adc4fd5


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.

Url Shortener for CLI

CLI Url Shortener wrote a little URL Shortener in Python with FastAPI and a wrapper script for cli usage. needs httpie & jq packages. python backend is under development, cli wrapper for different os right here … Usage somehost$ ./myurlshort usage: /usr/local/bin/myurlshort anyhost$ ./myurlshort CLI Wrappers OpenBSD cat << 'EOF' > myurlshort #!/usr/bin/env bash # url shortener for openbsd, v1.0, 2022-09-12, by @stoege which jq >/dev/null || ( echo -e "*** jq not installed ***\ndoas pkg_add jq\n"; ) which https >/dev/null || ( echo -e "*** httpie not installed ***\ndoas pkg_add httpie\n"; ) if [[ $# -ne 1 ]]; then echo -e "\nusage: $0 http://veeeeeeeeeeeeeeeeeeeeeeeeeery.

JC - JSON from CLI

how to build json from cli we all like json, do we ? add package doas pkg_add jc try ping openbsd-box # ping -c 3 |jc --ping -p 2>/dev/null { "destination_ip": "", "data_bytes": 56, "pattern": null, "destination": "", "packets_transmitted": 3, "packets_received": 3, "packet_loss_percent": 0.0, "duplicates": 0, "round_trip_ms_min": 9.219, "round_trip_ms_avg": 9.826, "round_trip_ms_max": 10.158, "round_trip_ms_stddev": 0.43, "responses": [ { "type": "reply", "bytes": 64, "response_ip": "", "icmp_seq": 0, "ttl": 59, "time_ms": 10.

Python PIP3

Python PIP OpenBSD 7.1 # python3 --version Python 3.9.12 # python3 -m pip --version pip 22.0.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9) List installed python3 -m pip list List Outated python3 -m pip list --outdated --format columns sha256: 6ada0942bc4d02ee477ab233571e893547049a379479b61910541e561d2f053a

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.


Python Snippets RealPython Best Practices: Convert CSV to JSON cat LARGEFILE.csv |python3 -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))' > LARGEFILE.json Zfill Padding Zero >>> for i in range(1,10): ... str(i).zfill(4) '0001' '0002' '0003' ... Different Padding #!/usr/bin/env python3 for i in range(1,99): print( str(i).zfill(4) +" "+ str(i).rjust(4, '-') +" "+ str(i).ljust(4, '-') +" "+ str(i).center(4, '-') ) 0001 ---1 1--- -1-- 0002 ---2 2--- -2-- 0003 ---3 3--- -3-- .


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 OpenBSD … and update path pip install --user poetry cat <<'EOF'>> ~/.profile # Poetry export PATH=$PATH:~/.local/bin EOF . ~/.profile ev install as root ? doas pip install --user poetry cat <<'EOF'>> ~/.profile # Poetry export PATH=$PATH:/root/.


Docker Command Cheat Sheet Visual Studio Code for macOS Linux Netzplan CT Ansible Edureka Windows Events NMAP SQL Stuff Bash Convention and Libraries Assembler 80186 and higher HTTP Status Codes Python Cheatsheet - Olivier La Flamme Data Wrangling with pandas Cheat Sheet OWASP Key Management Cheat Sheet Python Cheatsheet SQL Stuff by @yosracodes Security Infographics Kubectl Cheat Sheet for Kubernetes Admins SED Oneliners Boll PaloAlto THC’s favourite Tips, Tricks & Hacks (Cheat Sheet)

Python Pip

Python PIP how to PIP with OpenBSD … Already Installed ? doas pkg_info -Q py3-pip py3-pip-20.1.1p0 (installed) Install pip3 doas pkg_add py3-pip-- doas ln -sf /usr/local/bin/pip3.9 /usr/local/bin/pip Search doas pip search csvkit Install csvkit doas pip install wheel csvkit Upgrade pip doas pip install --upgrade pip Upgrade pip packages for i in $(pip list -o | awk 'NR > 2 {print $1}'); do doas pip install -U $i; done or doas pip install pip-review doas pip-review --interactive sha256: 39b0c97b5063483f3d42fd6ac5515f679180cb454d35cff5ee487a19f0fb5343