Skip to content

Instantly share code, notes, and snippets.

@ch-yx
ch-yx / superproperty.md
Created May 25, 2024 03:28
superproperty

made a small script:

@dataclass
class superproperty:
    g:"func"=None
    s:"func"=None
    d:"func"=None
    def __set_name__(self, owner, name):
        iter=(b for b in owner.__mro__ if hasattr(b,name))
        next(iter)
import subprocess
import numpy
x=subprocess.Popen(["ffmpeg","-re","-f","rawvideo","-s","250x250","-pix_fmt","rgb24","-i","-",
"-vcodec", "libx264",
"-acodec", "aac", "-b:a", "192k",
"-f", "flv",
"rtmp://live-push.bilivideo.com/live-bvc/?streamname=************"],stdin=subprocess.PIPE,stderr=subprocess.PIPE)
import requests,math
import syntax_sugar
def down(url,cp=40):
ls=int((requests.get(url,headers={"range":"bytes=0-0"}).headers["Content-Range"]).split("/")[1])
lp=math.ceil(ls/cp)
print(len(range(0,ls,lp)))
@ch-yx
ch-yx / conv list to tuple
Created September 4, 2020 16:49
[] -> ()
def f():
import marshal
tuplis=[]
def ltot(inpl):
if id(inpl) in tuplis:
return b"r"+tuplis.index(id(inpl)).to_bytes(4,"little")
else:
tuplis.append(id(inpl))
ret=b"\xa9"+len(inpl).to_bytes(1,"little")
for i in inpl:
class ignore():
def __init__(s,*e):
s.e=e
def __enter__(s):
pass
def __exit__(s,c,e,t):
try:
raise e
except s.e:
return 1