code structure:
$ tree .
.
├── mock_app_running.py
└── chatbot
└── webhook.py
""" | |
$ python sqlalchemy-high-concurrency-issue.py | |
... | |
$ echo "select * from steal;" | mysql -uscott -ptiger test | |
user_id money | |
89b65422-36ed-48db-ba25-68c3b27eedcc 2 | |
$ | |
$ python -O sqlalchemy-high-concurrency-issue.py | |
... | |
""" |
code structure:
$ tree .
.
├── mock_app_running.py
└── chatbot
└── webhook.py
<html> | |
<head> | |
<script defer src="https://pyscript.net/latest/pyscript.js"></script> | |
</head> | |
<body> | |
<div id="output"></div> | |
<py-script> | |
import asyncio | |
async def main(): |
/* | |
Usage: | |
``` | |
$ mkdir myscreenshot | |
$ cd myscreenshot | |
$ npm i puppeteer --save | |
$ | |
$ vim myScreenshot.js | |
const puppeteer = require('puppeteer'); | |
... |
You can then restrict a test run to only run tests marked with webtest
:
$ pytest -v -m webtest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 3 deselected / 1 selected
Basic Click Application
$ pip install click
$ python click_hello.py Jeff
Hello Jeff!
$ python click_hello.py Alice
Hello Alice!
def mergesort(seq): | |
mid = len(seq) // 2 | |
lft, rgt = seq[:mid], seq[mid:] | |
if len(lft) > 1: lft = mergesort(lft) | |
if len(rgt) > 1: rgt = mergesort(rgt) | |
res = [] | |
while lft and rgt: | |
if lft[-1] >= rgt[-1]: res.append(lft.pop()) | |
else: res.append(rgt.pop()) | |
return (lft or rgt) + res[::-1] |
def is_balance(s) -> bool: | |
open, close = '<{[(', ')]}>' | |
brackets = dict(zip(open, close[::-1])) | |
# print( brackets ) | |
stack = [] | |
for c in s: | |
if c in brackets: # open; O(1) | |
stack.append(c) # .push | |
elif c in brackets.values(): # close; O(4) |
from pathlib import Path | |
from typing import Any, Dict, Optional, Union | |
from hydra import compose, initialize_config_dir | |
from omegaconf import DictConfig | |
from pydantic import BaseModel, BaseSettings | |
from pydantic.env_settings import SettingsSourceCallable | |
# {python project}/app/config.py | |
project_dir = Path(__file__).parent.parent |
Requirement\Solution, conf.py , config.ini , config/ directory , proj-ops/ repository , Config Server | |
change config , ✅ , ✅ , ✅ , ✅ , ✅ | |
Simple(in minutes) , ✅ , ✅ , ✅ , ❌(required opration technology), ❌(not a problem if has a great library) | |
Coupling , ❌ , ✅ , ✅ config/prd.ini ❌ config/prd.py, -- , ✅ | |
mulitple environment, ❌ , ❌ , ✅ , ✅ , ✅ | |
security , ❌ , ❌ , ❌ , ✅ , ✅ | |
maintenance cost , ✅ , ✅ , ✅ , ✅ |