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
def calculate_aspect(width: int, height: int) -> tuple[int, int]: | |
""" Calculate aspect ratio of a screen resolution """ | |
def gcd(a, b): | |
"""The GCD (greatest common divisor) is the highest number that evenly divides both width and height.""" | |
return a if b == 0 else gcd(b, a % b) | |
r = gcd(width, height) | |
x = int(width / r) |
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
<?php | |
function getYoutubeEmbedHtml($url){ | |
$query = parse_url($url, PHP_URL_QUERY ); | |
$args = array(); | |
parse_str($query, $args); | |
$videoId = isset($args["v"]) ? $args["v"] : null; | |
if(!$videoId){ | |
return null; | |
} | |
return "<style>.iframe-container { position:relative; margin-bottom: 30px; padding-bottom:56.25%; padding-top:25px; height:0; max-width:100%; } .iframe-container iframe { position:absolute; top:0; left:0; width:100%; height:100%; border:none; }</style><div class=\"iframe-container\"><iframe src=\"https://youtube.com/embed/{videoId}\" allowfullscreen=\"\"></iframe><br /></div>"; |