This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Ref: https://zetcode.com/python/sqlite3-connection-row-factory/ | |
| See also: https://zetcode.com/python/sqlite3-row-keys/ | |
| """ | |
| import sqlite3 | |
| from collections import namedtuple | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Relevant unicode characters reference: https://www.unicode.org/charts/PDF/U2000.pdf | |
| how to type an unicode character in Linux: | |
| CTRL + Shift + U2014 Enter | |
| how to type an unico character in Windoze: (not sure here !) | |
| NumLock ON Alt Down 0151 | |
| file_with_illegal_characters.csv | |
| -------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FIND NETWORK HIERARCHIES in SQLITE | |
| using | |
| Simple Recursion with Common Table Expressions ( CTE ) | |
| ====================================================== | |
| Ref: https://www.youtube.com/watch?v=7GpyHedM4pw | |
| Ref: https://douglaskline.blogspot.com/2016/06/simple-recursion-in-sql-with-common.html | |
| Recursive CTE Principle: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://stackoverflow.com/questions/74400075/how-to-select-based-on-a-substring-in-jq | |
| # https://jqlang.org/manual/#conditionals-and-comparisons | |
| # https://play.jqlang.org/s/ovqQqRTfNE_Zxw0 | |
| # https://www.youtube.com/watch?v=YrVR09v78Dc | |
| curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq -r '.[].commit.author | select (.email | contains(".us"))' | |
| curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq '.[].commit.author | select (.email | contains("github") | not) ' | |
| curl -s 'https://api.github.com/repos/jqlang/jq/commits?per_page=80' | jq --arg n "github" '.[].commit.author | select (.email | contains($n)) ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| PyTricia : Matching IPs to Subnets in Python in an Efficient Way | |
| https://jmanteau.fr/posts/matching-ips-to-subnets-in-python-in-an-efficient-way/ | |
| https://github.com/jsommers/pytricia | |
| https://www.youtube.com/watch?v=i5zP7iiw91Y ; | |
| What is Python Pickle? A Beginner’s Guide to Data Serialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Inspiration ... where did I start ?: | |
| # https://www.blopig.com/blog/2021/05/hosting-multiple-flask-apps-using-apache-mod_wsgi/ | |
| # https://www.rosehosting.com/blog/how-to-install-flask-on-ubuntu-22-04-with-apache-and-wsgi/?srsltid=AfmBOoqkm3GW5tXYBQywDTb_Y6SuLD0URVm9OC3uBqO4QhtSHpndMbz- | |
| # https://stackoverflow.com/questions/29882579/run-multiple-independent-flask-apps-in-ubuntu | |
| # https://serverfault.com/questions/357108/what-permissions-should-my-website-files-folders-have-on-a-linux-webserver | |
| sudo apt install apache2 -y | |
| sudo systemctl status apache2 | |
| sudo apt install libapache2-mod-wsgi-py3 | |
| apachectl -M | grep wsgi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SQLITE DATE - TIME - DATETIME YOUTUBE TUT | |
| https://www.youtube.com/watch?v=nJRvz5Rhrx0 | |
| # Insert DEFAULT timestamp "now" as INTEGER | |
| # and unixepoch prior SQLITE 3.38 (2022-02-22). | |
| #################################################### | |
| create table t1 (c1 TEXT, c2 INTEGER DEFAULT (strftime('%s', 'now'))); | |
| insert into t1(c1) values ('drink'),('eat'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| The walrus operator “:=” is an operator used to evaluate, assign, and return value from a single statement in Python. | |
| It was introduced in Python 3.8 | |
| """ | |
| sss = {'color': 'red', 'size': 'l', 'clips': {'number': 6, 'material': 'metal'}} | |
| if value := sss.get("clips", {}).get("number"): | |
| print(f"Number of clips: {value}") | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| my_favorite = {"product": "Stella", "flavors": ["walnut", "prune"], "ranking": None, "price": 1.15, "in_stock": False } | |
| """ | |
| json.dumps() function converts a subset of Python objects into a json string. | |
| """ | |
| my_favorite_json = json.dumps(my_favorite , indent=2, sort_keys=True) | |
| print(my_favorite_json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app.py | |
| # https://stackoverflow.com/questions/74213961/how-create-endpoints-in-multiple-files | |
| # https://flask.palletsprojects.com/en/stable/blueprints/ | |
| from flask import Flask, jsonify, request | |
| from candy import candy_bp | |
| from beer import beer_bp | |
| from netz import netz_bp |
NewerOlder