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
| from fastapi import FastAPI, Path | |
| from fastapi.routing import APIRouter | |
| from fastapi.responses import StreamingResponse | |
| from starlette.responses import RedirectResponse, HTMLResponse | |
| import asyncio | |
| import json | |
| import logging | |
| import time | |
| from typing import TextIO | |
| from pathlib import Path |
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
| """ | |
| ASGI Middleware for serving the frontend application. | |
| This modules is used in development environment only. | |
| When in production, the frontend application may be served by a dedicated web server. | |
| ``` | |
| if not_in_production_environment: | |
| app = FrontendAppMiddleware(app, app_dir='<path to npm project>') | |
| ``` |
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
| struct SHA256_CTX { | |
| data : array<u32, 64>, | |
| datalen : u32, | |
| bitlen : array<u32, 2>, | |
| state : array<u32, 8>, | |
| info : u32, | |
| }; | |
| fn sha256_init_ctx(ctx : ptr<function, SHA256_CTX>) | |
| { |
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
| from types import ModuleType | |
| def import_submodules(module: ModuleType) -> None: | |
| """ | |
| Import all submodules of a module, recursively, including subpackages. | |
| :param module: module (package) to import submodules of | |
| """ | |
| import importlib | |
| import pkgutil |
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
| """ | |
| This is a serializer / deserializer for the RESP3 protocol. | |
| protocol spec at https://github.com/antirez/RESP3/blob/master/spec.md | |
| """ | |
| from typing import Generator, BinaryIO, Any | |
| class error_str(str): | |
| pass |
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
| """ | |
| try to display an image in terminal using vt100 256 color codes | |
| """ | |
| import os, sys | |
| from PIL import Image | |
| #~dep:colored | |
| from colored import Back, Style | |
| from typing import TextIO |
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 re | |
| import requests | |
| import logging | |
| from urllib.parse import urljoin | |
| import asyncio | |
| import websockets | |
| from http import HTTPStatus | |
| from asgiref.typing import ( | |
| ASGI3Application, |
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
| from cvzone.FaceMeshModule import FaceMeshDetector | |
| import cv2 | |
| cap = cv2.VideoCapture(0) | |
| detector = FaceMeshDetector(maxFaces=2) | |
| while True: | |
| success, img = cap.read() | |
| img, faces = detector.findFaceMesh(img) | |
| if faces: | |
| print(faces[0]) |
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
| ################################################################################ | |
| ## compile quickjs as a static library | |
| set(QUICKJS_GIT_TAG master) | |
| include(FetchContent) | |
| FetchContent_Declare( | |
| quickjs | |
| GIT_REPOSITORY https://github.com/bellard/quickjs.git | |
| GIT_TAG ${QUICKJS_GIT_TAG} |
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
| #ADD data/ca-bundle.crt /usr/share/ca-certificates/mycompany/ca-bundle.crt | |
| #RUN << EOF | |
| cd /usr/share/ca-certificates/mycompany | |
| i=1; while openssl x509 -out cert$i.pem; do | |
| echo mycompany/cert$i.pem >> /etc/ca-certificates.conf | |
| i=$((i+1)) | |
| done < ca-bundle.crt | |
| update-ca-certificates | |
| #EOF |
NewerOlder