Python

Python Logger

a custom logger for Python let’s tune the default logger a bit so he write nice and colored messages. Screenshot config.py a little config File … cat <<'EOF'> config.py LOGGER_MAX_FILE_LENGTH = 10 EOF src/logger.py the logger code in the ‘src’ Folder mkdir src cat <<'EOF'> src/logger.py import logging import datetime import sys from config import * if isinstance(LOGGER_MAX_FILE_LENGTH, int): LOGGER_MAX_FILE_LENGTH = str(LOGGER_MAX_FILE_LENGTH) def get_now() -> str: # # choose your format # current_time = datetime.

Python - Build Executable

wanna convert a script to a executable ? Build a Sample Script cat << EOF > main.py a = "top" b = "secret" print("This is", a, b) EOF python3 main.py This is top secret update poetry ? doas poetry self update poetry self update or pip install poetry -U add pyinstaller poetry init poetry add pyinstaller build Binary poetry run pyinstaller main.py --onefile check Binary ls -la dist/ file dist/main ls -la dist/ 4735533 Jun 26 22:17 main ```.

Python Course

Title 1 Title 2 Title 3 Test Any Comments ? sha256: b9d70cb1f09e97aa8707c8a8b26e0fb0f599ec23d2eda337ba3899dfbc0c02c5

OpenBSD - ansible-pylibssh

wanna build ansible-pylibssh on OpenBSD 7.3 ? Build failed ? $ pip install ansible-pylibssh Defaulting to user installation because normal site-packages is not writeable Collecting ansible-pylibssh Using cached ansible-pylibssh-1.1.0.tar.gz (106 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: ansible-pylibssh Building wheel for ansible-pylibssh (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for ansible-pylibssh (pyproject.

Multiprocessing

Parallel Processing i recently read an article about parallel processing. i remembered my domain checker service which checks a lot of domains for their availablitly, and this script runs sequentiel and needs around 30 seconds. initially i worked on a caching mechanism to speed up results. but if a service is not used that often (nobody is useing my domain checker…), there is not much you can gain with caching.

Python - Redirector

Redirector App wrote a little redirector app and tought i will explain and share it here. it’s a bit like a url shortener, but you can define the “shortcut” of the URL. how does it work it basically consists of a Text File wir Redirection URL’s. redi.txt stoege,https://www.stoege.net blog,https://blog.stoege.net test,https://www.test.com Call it so, when you open a Browser and Request the URL: https://your.domain.de/blog, you get redirected to https://blog.stoege.net main.app from flask import Flask, redirect, request import datetime import os import random # Vars redirect_file="redi.

Python - Little Wordcloud

Do you like Word Clouds ? I do …! following a litte Script which Parse a Website and build a appropriate Word Cloud Script mkdir ~/mywordcloud; cd ~/mywordcloud cat <<'EOF' > main.py import fire import matplotlib.pyplot as plt import pandas as pd import re import requests from bs4 import BeautifulSoup from wordcloud import STOPWORDS, WordCloud def gen_cloud_tag(url: str = "https://blog.stoege.net"): # add https if not url.startswith("https://"): url = "https://" + url # get Webpage response = requests.

Flask JWT - Sample

Flask & JWT getting your hands dirty with Flask and JWT Source https://dev.to/grahammorby/jwt-auth-in-flask-python-18i4 with some modifications by myself … Environment Test under macOS & OpenBSD, Poetry installed and working Script build virtual env export app="app100" export FLASK_APP="${app}/app" poetry new ${app} cd ${app} set python 3.10 poetry env use $(which python3.10) gsed -i "s/python = \"^3.*$/python = \"^3.10\"/" pyproject.toml poetry lock add packages wget -4 -O requirements.txt https://raw.githubusercontent.com/GrahamMorbyDev/jwt-flask/master/requirements.txt echo "marshmallow-sqlalchemy" >> requirements.

Django on Gooogle Cloud

I’ll give a try running an Application on Google Cloud. Not with great sucess :( Source https://codelabs.developers.google.com/codelabs/cloud-run-django?hl=en#0 https://codelabs.developers.google.com/codelabs/cloud-run-hello-python3#1 Get Cloud List, Active Account gcloud auth list gcloud config set account 'username@gmail.com' List Projects gcloud config list project [core] project = cloud-run-372113 Your active configuration is: [cloudshell-6045] username@cloudshell:~ (cloud-run-372113)$ Set Project ID gcloud config set project cloud-run-372113 username@cloudshell:~ (cloud-run-372113)$ gcloud config set project cloud-run-372113 Updated property [core/project]. Enable API gcloud services enable \ artifactregistry.

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 ! Any Comments ? sha256: afb99c7e3ed003bee48b65795a153c4fe7835fe3dae0759b70ab2bfb5adc4fd5