This file contains 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
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) |
This file contains 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
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) |
This file contains 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
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 |
This file contains 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
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 file contains 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 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" |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
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 |