Skip to content

Instantly share code, notes, and snippets.

View script.py
import os
import subprocess
import tempfile
import contextlib
import secrets
import glob
import shutil
import time
from argparse import ArgumentParser
from functools import partial
View simple.reizql
Query:
FunctionDef(body=[*..., Return(Call())])
AST:
Match(
name="FunctionDef",
filters={
"body": List(
items=[
Expand,
View bank.py
from __future__ import annotations
import uuid
import copy
from contextlib import contextmanager
from dataclasses import dataclass, field
from enum import IntEnum, auto
def restore(originals, frozens):
for original, frozen in zip(originals, frozens):
View balance_boxes_fast.py
# Problem:
# Balance all boxes with the minimum number of moves. Each
# move is the operation of taking N from one box and distributing
# it to other boxes equally.
# 30, 50, 45, 40, 35
#
# 1st move: take 12 from third box [45], and give other boxes +3
# 33, 53, 33, 43, 38
#
View redisgraph_insert_ast.py
import ast
tree = ast.parse("""
1
""")
import redis
from redisgraph import Node, Edge, Graph, Path
View pegen_restore_token.c
expr_ty _PyPegen_produce_string(Parser *p, expr_ty a) {
int start = -1, end = -1, length = 0, seen_walrus = 0, mark;
for (mark = p->mark; start == -1; --mark) {
Token* token = p->tokens[mark];
if (token->end_lineno == a->end_lineno
&& token->end_col_offset == a->end_col_offset)
{
end = mark;
}
if (token->lineno == a->lineno
View maybe.py
import random
@object.__new__
class Maybe:
def __bool__(self):
return random.choice((True, False))
print(bool(Maybe), bool(Maybe), bool(Maybe))
print(Maybe is Maybe)
View test.css
html{
background-image:url('https://user-images.githubusercontent.com/47358913/83976033-0a87fd80-a900-11ea-8de7-1def45a939ed.png');
padding: 10rem;
}
body {
/* background-color: none..class{ */
background:rgba(0,0,0);
/* background: #000065; */
color: white;
font-size: 2em;
View economybotv2.py
import inspect
import json
import re
import socket
import time
from collections import UserString
from dataclasses import asdict, dataclass, field
from typing import Any, Callable, Set, Tuple
TRUSTED = frozenset(("beginbotbot", "isidentical"))
View economybot.py
import re
import json
import socket
from dataclasses import dataclass, field, asdict
from collections import UserString
from typing import Set
TRUSTED = frozenset(("beginbotbot", "isidentical"))
COMMAND_RE = re.compile(r"(?P<command>![a-z]*)+")
ECONOMY_RE = re.compile(r"Mana: (?P<mana>\d+) \| Street Cred: (?P<credit>\d+) \| Cool Points: (?P<points>\d+)")