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 operator as op | |
| from itertools import chain | |
| def car(l): | |
| l = iter(l) | |
| try: | |
| return next(l) | |
| except StopIteration: | |
| return None |
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 operator as op | |
| from itertools import chain | |
| def car(l): | |
| l = iter(l) | |
| try: | |
| return next(l) | |
| except StopIteration: | |
| return None |
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 datetime import datetime, timedelta | |
| class ApiLimit: | |
| def __init__(self, request_limit, time_limit_second): | |
| self.api_count = 0 | |
| self.request_limit = request_limit | |
| self.time_limit_second = time_limit_second | |
| self.start = None | |
| def __call__(self, func): |
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 pyautogui as auto | |
| import time | |
| import random | |
| def hold(key: str, duration: float, natural: bool=True, sd: float=0.05): | |
| duration += random.gauss(0, sd) if natural else 0 | |
| t = time.time() | |
| while time.time() - t < duration: | |
| auto.keyDown(key) |
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
| type Val = | |
| | Int of int | |
| | Bool of bool | |
| type Ope = Add | Mul | Lt | |
| type Ast = | |
| | Val of Val | |
| | Form of Ope * Ast * Ast | |
| let exec ope v1 v2 = | |
| match ope, v1, v2 with |
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
| enum Val { | |
| case int(Int) | |
| case bool(Bool) | |
| case symbol(String) | |
| } | |
| enum Ope { | |
| case add | |
| case mul | |
| case lt |
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
| protocol Potato { | |
| func hash() -> Int | |
| } | |
| extension Potato where Self: Hashable { | |
| func hash() -> Int { | |
| return self.hashValue | |
| } | |
| } |
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
| ; input | |
| (define (my-read) | |
| (let ([a (read)]) | |
| (if (symbol? a) | |
| (symbol->string a) | |
| a))) | |
| (define (my-read-line) | |
| (let ([line (read-line)]) | |
| (if (string=? "" line) | |
| (my-read-line) |
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 operator as ope | |
| from functools import partial | |
| lt, le, eq, ne, ge, gt = [(lambda x: partial(o, x)) for o in [ope.lt, ope.le, ope.eq, ope.ne, ope.ge, ope.gt]] | |
| test = [f for f in [lt(1), le(1), eq(1), ne(1), ge(1), gt(1)]] | |
| print(*test, sep="\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
| def input_loop(question, quit): | |
| while not quit(ans := input(question)): | |
| yield ans | |
| for ans in input_loop("Yo? >>", lambda x: x == "quit"): | |
| print("Your input: ", ans) | |
NewerOlder