Skip to content

Instantly share code, notes, and snippets.

@NicholasBallard
NicholasBallard / get_db_async.py
Created October 15, 2023 15:01
SQLAlchemy async database session object
from contextlib import asynccontextmanager, contextmanager
from typing import Generator
from sqlalchemy import create_engine
from sqlalchemy.ext.asyncio import async_sessionmaker, AsyncEngine, AsyncSession, create_async_engine
from scada.core.config import settings
@contextmanager
@NicholasBallard
NicholasBallard / .env
Created April 8, 2021 15:28 — forked from eldadfux/.env
Appwrite 0.7 - Stack
_APP_ENV=production
_APP_ENV=development
_APP_SYSTEM_EMAIL_NAME=Appwrite
[email protected]
[email protected]
_APP_OPTIONS_ABUSE=disabled
_APP_OPTIONS_FORCE_HTTPS=disabled
_APP_OPENSSL_KEY_V1=your-secret-key
_APP_DOMAIN=demo.appwrite.io
_APP_DOMAIN_TARGET=demo.appwrite.io
from setuptools import setup
setup(
name='resize',
version='0.0.1',
py_modules=['resize'],
install_requires=[
'click',
'pillow',
],
""" resize.py
"""
from __future__ import annotations
import os
import glob
from pathlib import Path
import sys
import click
resized = resize("checkers.jpg", 30.5)
print(resized.size)
resized.show("resized image", resized)
resized = resize("checkers.jpg", 30.5)
print(resized.size)
resized.show("resized image", resized)
resized = resize("checkers.jpg", 50)
print(resized.shape)
plt.imshow(resized) # can use cv2.imshow("name", image)
import cv2
def resize(fp: str, scale: Union[float, int]) -> np.ndarray:
""" Resize an image maintaining its proportions
Args:
fp (str): Path argument to image file
scale (Union[float, int]): Percent as whole number of original image. eg. 53
Returns:
""" resize.py
"""
from __future__ import annotations
import os
import glob
from pathlib import Path
import sys
import click
from PIL import Image
def resize(fp: str, scale: Union[float, int]) -> np.ndarray:
""" Resize an image maintaining its proportions
Args:
fp (str): Path argument to image file
scale (Union[float, int]): Percent as whole number of original image. eg. 53
Returns: