Download/clone all files in gist locally.
Install all requirements:
pip install -r requirements.txt
Start Sanic server:
Download/clone all files in gist locally.
Install all requirements:
pip install -r requirements.txt
Start Sanic server:
:: Refs: | |
:: - https://www.minitool.com/news/unable-to-terminate-process-access-is-denied.html | |
:: - https://superuser.com/questions/1183057/tasklist-shows-process-but-taskkill-is-unable-to-kill-it-even-as-admin | |
tasklist | |
tasklist | findstr "process_name.exe" | |
taskkill /im "process_name.exe" /f |
# Ref: https://stackoverflow.com/a/66514587 | |
# Just made changes reponse to JSON type | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import json | |
class handler(BaseHTTPRequestHandler): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
def do_GET(self): |
Keeping this stackoverflow answer(Python) handy for future use:
try:
func1()
except Exception as ex:
trace = []
tb = ex.__traceback__
while tb is not None:
trace.append({
"filename": tb.tb_frame.f_code.co_filename,
# A small example that works text based templates | |
# Ref: https://stackoverflow.com/a/8284419 | |
# Note: Works only for top-level variables, i.e., id dictionary is passed then we can't parse keys defined within the dictionaries | |
from jinja2 import Environment, BaseLoader, meta | |
if __name__ == '__main__': | |
template_text = '<div>{{ title }}</div>' | |
template_env = Environment(loader=BaseLoader()) | |
variable_list = list(meta.find_undeclared_variables(template_env.parse(template_text))) | |
print("List of variables inside template: "+variable_list) |
await
await async_func()
asyncio
import asyncio
asyncio.run(async_func())
Windows cmd line to create dummy 1 GB file:
C:\ fsutil file createnew dummy.doc 1073741823
File C:\dummy.doc is created
Linux shell to create dummy 1 GB file:
# Code reference: https://gis.stackexchange.com/a/327046 | |
import json | |
import pyproj | |
import shapely.wkt as shp_wkt | |
import shapely.geometry as shp_geo | |
from shapely.geometry import Polygon as ShpPolygon | |
REM Use icacls command in windows OS to set file permission which operates chmod in *nix platform. This script can be run on classic command prompt. | |
REM Syntax: | |
REM icacls.exe <ssh_Key_filename> /reset | |
REM icacls.exe <ssh_Key_filename> /grant:r "%username%":"(R)" | |
REM icacls.exe <ssh_Key_filename> /inheritance:r | |
icacls.exe vm_access.pem /reset | |
icacls.exe vm_access.pem /grant:r "%username%":"(R)" | |
icacls.exe vm_access.pem /inheritance:r |
By default, state
variable is attached to any model object that is passed to Machine
object initalisation in transitions library. Passing model_attribute
will allow us to define custom state attribute. This wasn't obvious while going through the document. TL;DR 📖🥱😜
https://github.com/pytransitions/transitions
Also django-transitions
is like experimental repo and maintained since Jan 2019. So I was looking for the solution without using it. Even if we use it mentioned only about setting custom name in Mixins
. Does not make sense to just to use mixins for custom variables. So example I shown in models.py
is better way. Next, I need to see how I can inherit this feature into custom ModelField class.
Sample execution:
$ ./manage.py shell