Skip to content

Instantly share code, notes, and snippets.

View RamiAwar's full-sized avatar
🎯
Working on Pet, Dataline, and SQLAlchemy stuff

Rami Awar RamiAwar

🎯
Working on Pet, Dataline, and SQLAlchemy stuff
View GitHub Profile
def post_exam_computation(exam_id):
exam_results = db.get(exam_id)
max_score = max(exam_results)
min_score = min(exam_results)
avg_score = sum(exam_results) / len(exam_results)
exam_stats = {"max": max_score, "min": min_score, "avg": avg_score}
db.save(exam_stats)
def post_exam_computation(exam_id):
exam_results = db.get(exam_id) # Database call
max_score = max(exam_results)
min_score = min(exam_results)
exam_stats = {"max": max_score, "min": min_score}
db.save(exam_stats)
def validate_unwrap(path_model=None, query_model=None, body_model=None):
"""Validates a Sanic route handler using path, query and body pydantic models.
This decorator would automatically validate the request path/query/body models and
plug in instances of the pydantic models as additional arguments to the route handler.
Usage:
from pydantic import BaseModel, validator
class CustomerIn(BaseModel):
first_name: str
export PATH=/usr/local/bin:$PATH
export PROMPT=" %(?.%F{green}√.%F{red}X %?) %F{green}%n@%1d λ "
eval "$(pyenv init -)"
# Git integration
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
'''This python code performs face tracking and simulates scrolling. First, the image feed is recieved from the camera. A facial detection algorithm is applied
once in every 5 frames. On detecting the face, a rectangular frame is drawn around the detected face, and the deviation from the center of the screen to the center of the face is taken as the scroll delta.
Requires Python + OpenCV'''
import cv2
from pynput.mouse import Button, Controller
mouse = Controller()
HAAR_CASCADE_PATH = "haarcascade_frontalface_alt.xml"
extends Node2D
onready var dirt_tilemap = $DirtTileMap
onready var wall_tilemap = $WallTileMap
var rng = RandomNumberGenerator.new()
var CellSize = Vector2(32, 32)
var width = 2048/CellSize.x
var height = 1216/CellSize.y
extends Node2D
onready var dirt_tilemap = $DirtTileMap
onready var wall_tilemap = $WallTileMap
var rng = RandomNumberGenerator.new()
var CellSize = Vector2(32, 32)
var width = 2048/CellSize.x
var height = 1216/CellSize.y
extends Node2D
onready var dirt_tilemap = $DirtTileMap
onready var wall_tilemap = $WallTileMap
var rng = RandomNumberGenerator.new()
var CellSize = Vector2(32, 32)
var width = 2048/CellSize.x
var height = 1216/CellSize.y
extends Node2D
onready var dirt_tilemap = $DirtTileMap
onready var wall_tilemap = $WallTileMap
var rng = RandomNumberGenerator.new()
var CellSize = Vector2(32, 32)
var width = 2048/CellSize.x
var height = 1216/CellSize.y
extends Node2D
onready var dirt_tilemap = $DirtTileMap
onready var wall_tilemap = $WallTileMap
var rng = RandomNumberGenerator.new()
var CellSize = Vector2(32, 32)
var width = 1024/CellSize.x
var height = 608/CellSize.y