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 ast | |
class ConvertIfExpr(ast.NodeTransformer): | |
def visit_Call(self, node: ast.Call): | |
''' | |
Assumes the form if_then_else(cond)(then_case)(else_case) | |
All calls are expected to have exactly one argument. | |
''' |
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 __future__ import annotations | |
import pygame | |
import math | |
from datetime import datetime | |
HOURS_PER_DAY = 10 | |
MINUTES_PER_HOUR = 100 | |
SECONDS_PER_MINUTE = 100 | |
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 __future__ import annotations | |
import pygame | |
import random | |
import pathlib | |
HERE = pathlib.Path(__file__).absolute().parent | |
class BaseSprite(pygame.sprite.Sprite): | |
_image_res: tuple[int] |
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 sys | |
def int_succeeds(c: str): | |
try: | |
int(c) | |
except ValueError: | |
return False | |
return True | |
chars = [chr(n) for n in range(sys.maxunicode + 1)] |
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 __future__ import annotations | |
from PIL import Image, ImageDraw | |
def neighbours(x, y): | |
return [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1), (x - 1, y - 1), (x + 1, y - 1), (x - 1, y + 1), | |
(x + 1, y + 1)] | |
def find_ocean_coords(filename, testsize=(128, 128)): |
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 __future__ import annotations | |
import math | |
import colorsys | |
from PIL import Image, ImageDraw, ImageFont | |
RowTuple = tuple[float, float] | None | |
def calc_lines(t_start: int, t_end: int) -> tuple[RowTuple, RowTuple, RowTuple]: | |
""" |
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 socket | |
import threading | |
import queue | |
import time | |
from dataclasses import dataclass | |
from typing import Any | |
@dataclass | |
class Client: |
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 ast | |
import os | |
import random | |
import string | |
import sys | |
import unicodedata as ud | |
class IdentifierTransformer(ast.NodeTransformer): | |
def __init__(self, char_sets: dict[str, dict[str, list]]): |
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 PIL import Image, ImageDraw | |
import math | |
def main(): | |
im = Image.open('city.png').convert('RGB') | |
out = Image.new('RGB', im.size) | |
dotw = 16 | |
doth = 16 |
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 multiprocessing import Process, Queue | |
import os | |
import time | |
from urllib.parse import urlencode, urljoin | |
import requests | |
from dotenv import load_dotenv | |
load_dotenv() | |
STREAMLABS_API_BASE = 'https://streamlabs.com/api/v1.0/' |