After reading (almost done) with: The Code Book : The Secret History of Codes and Code-Breaking Paperback – April 30, 2002by Simon Singh (Author) available at Amazon and so on I became fascinated with the history and the small stories that goes along with the different codes used and still being used today. Here is…
Category: Python
TODO Python Regular Expressions
https://realpython.com/regex-python/
Function app
https://docs.microsoft.com/en-us/azure/azure-functions/ First function Python https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-python Linux, hm, must upload code from local The Azure Functions extension for Visual Studio Code. Azure icon click it, takes time Select a language for your function project: Choose Python.Select a Python alias to create a virtual environment: Choose the location of your Python interpreter. If the location isn’t shown,…
Azure SDK Pyhon
https://azure.github.io/azure-sdk/python_introduction.html Python Guidelines: Introduction: Design principlesIdiomaticConsistentApproachableDiagnosableDependablePython Design Principles:–PEP 20 — The Zen of Python, import this https://www.python.org/dev/peps/pep-0020/ General Guidelines: https://azure.github.io/azure-sdk/general_introduction.html Gitub: https://github.com/azure/azure-sdk-for-python Supported python versions:Code style: https://www.python.org/dev/peps/pep-0008/ Naming conventions: service_client = ServiceClient() service_client.list_things() def do_something(): class ThisIsCorrect(object): pass MAX_SIZE = 4711 database_module.py Method signatures: DO NOT use, static, do not use get set, use properties…
Docker-compose ubuntu
Install it from here, the two first lines https://get.docker.com/ curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh docker –version Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your…
PEP 8
Programming Recommendations https://www.python.org/dev/peps/pep-0008/#programming-recommendations Use is not operator rather than not … is. While both expressions are functionally identical, the former is more readable and preferred. Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier. Derive exceptions from Exception rather than BaseException. Direct inheritance from BaseException…
Python debugging in VS Code
Debugging 101 https://github.com/microsoft/vscode-recipes/tree/master/debugging%20python We need VSC, Python extension and a launch.json with the minimum of integrated and external. The launch.json Debug->Open configurations Ok, let’s run a script and test it. F5 is for run, F10 is for step into. We are going to test Python set functions, union and intersection. The breakpoint will be at…
Python, lxml and Xpath
https://lxml.de/xpathxslt.html https://www.w3schools.com/xml/xpath_syntax.asp Read a file with xml, convert it to a string from bytes: pip install lxml from lxml import etree as et Make dictionary (duplicate keys, get atr) result: Code: def xml_to_dict(xmlfile): msg = {} count = 1 with open(xmlfile) as r: xml = r.read() print(type(xml)) parser = et.XMLParser(recover=True, collect_ids=True) root = et.fromstring(bytes(xml, encoding=”utf-8″), parser) x = root.xpath(“//*”)# get all #x…
Python as systemctl service
https://www.loggly.com/blog/new-style-daemons-python/ https://github.com/torfsen/python-systemd-tutorial This is an easy and not enough tested script, you may also enable it to start at boot. Read about systemctl: https://www.freedesktop.org/software/systemd/man/systemctl.html So create a file in /lib/systemd/system touch python_service.service sudo nano python_service.service run the script with (when it is done and has no erros): This is my test script: It prints service…
MariaDb linux Python ORM
https://linuxize.com/post/how-to-install-mariadb-on-ubuntu-18-04/ MariaDB is an open source, multi-threaded relational database management system, backward compatible replacement for MySQL. It is maintained and developed by the MariaDB Foundation including some of the original developers of the MySQL. https://linuxize.com/post/how-to-create-a-sudo-user-on-ubuntu/ sudo apt update sudo apt install mariadb-server sudo mysql -V sudo systemctl status mariadb Run the mysql_secure_installation command to improve…