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 time | |
| import json | |
| from html.parser import HTMLParser | |
| from pathlib import Path | |
| import genanki | |
| import requests | |
| VOCAB_URL = "https://www.ntnu.edu/now/{chapter}/vocabulary" | |
| CHAPTERS = list(range(1, 11)) # 1 to 10 (inc.) |
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
| INTRO_SEGMENT = """\ | |
| print('| welcome to my simple tic-tac-toe game!') | |
| print('| take your turn by choosing a tile [1-9].')\n | |
| """ | |
| GRID_SEGMENT = """\ | |
| print('\\n| {0} | {1} | {2} |') | |
| print('| {3} | {4} | {5} |') | |
| print('| {6} | {7} | {8} |\\n') | |
| """ |
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 numbers import Integral | |
| class Flag(int): | |
| def __new__(cls, value: int, parent_cls: type = None): | |
| flag = super().__new__(cls, value) | |
| if parent_cls is None: | |
| parent_cls = cls |
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 ctypes | |
| def size_of(obj): | |
| cls = type(obj) | |
| return cls.__sizeof__(obj) | |
| def mem_replace(target, source): | |
| target_size = size_of(target) |
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 dis | |
| from types import CodeType | |
| def _patch_code(code: CodeType, **kwargs): | |
| """Create a new CodeType object with modified attributes.""" | |
| code_attrs = {} | |
| # Collect the original CodeType attributes |