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
| exec("\n".join(l[:len(l)//2+1].strip().replace("X"," "*4)for l in"""ni l rof)4*" ","X"(ecalper.)(pirts.]1+2//)l(nel:[l(nioj."n\"(cexe | |
| import sysys tropmi | |
| for l in sys.stdin.readlines():)(senildaer.nidts.sys ni l rof | |
| XL=l.rstrip("\\n");print(L==L[::-1])]1-::[L==L(tnirp;)"n\\"(pirtsr.l=LX | |
| ))]1-:1[)"n\"(tilps.""".split("\n")[1:-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
| @-moz-document domain("tagesschau.de") { | |
| .teasergroup { | |
| display: flex; | |
| flex-wrap: wrap; | |
| } | |
| .teaser:not(.teaser--top) { | |
| flex-basis: 50%; | |
| } |
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
| \usepackage{xparse} | |
| \ExplSyntaxOn | |
| \NewExpandableDocumentCommand{\cmidrulez}{m} | |
| { | |
| \noalign { \__leviathan_cmidrulez:n { #1 } } | |
| \tl_use:N \g__leviathan_cmidrulez_tl | |
| } | |
| \tl_new:N \g__leviathan_cmidrulez_tl |
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 redoable(iterable): | |
| do_redo = False | |
| def redo(): | |
| nonlocal do_redo | |
| do_redo = True | |
| for item in iterable: | |
| yield redo, item | |
| while do_redo: | |
| do_redo = False | |
| yield redo, item |
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
| class Mail: | |
| def __init__(self, **bindings): | |
| self.bindings = bindings | |
| def send(self, **bindings): | |
| self.bindings.update(bindings) | |
| return """Sending email with: | |
| {}""".format( | |
| "\n ".join(f"{key}: {val}" for key, | |
| val in self.bindings.items()) | |
| ) |
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 functools import wraps | |
| def composable(f1): | |
| @wraps(f1) | |
| def wrapper(*args, **kwargs): | |
| if not kwargs and len(args) == 1 and callable(args[0]): | |
| f2 = args[0] | |
| @wraps(f2) |
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
| function! Blackify(type, ...) | |
| let sel_save = &selection | |
| let &selection = "inclusive" | |
| let reg_save = @@ | |
| silent exe "'[,']!black --quiet -" | |
| let &selection = sel_save | |
| let @@ = reg_save | |
| endfun |
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 bind(clsname, first, second=None): | |
| if second is None: # class binding | |
| cls = globals()[clsname] | |
| fn = first | |
| name = fn.fget.__name__ if isinstance(fn, property) else fn.__name__ | |
| setattr(cls, name, fn) | |
| else: # instance binding | |
| self = first | |
| fn = second | |
| name = fn.fget.__name__ if isinstance(fn, property) else fn.__name__ |
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
| # inspiration: https://tinkering.xyz/abusing-type-annotations/ | |
| from __future__ import annotations | |
| from typeanno import restrict | |
| @restrict | |
| class Test: | |
| x: 0 < x < 10 | |
| def __init__(self, x): | |
| self.x = x |
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 functools import partial | |
| def curry(fn, argcount=None): | |
| if not callable(fn): | |
| return partial(curry, argcount=fn) | |
| argcount = argcount or fn.__code__.co_argcount | |
| if argcount < 2: | |
| return fn | |
| def wrapper(first): | |
| return curry(partial(fn, first), argcount-1) |