BLCL的博客小馆

标签 · stdout

首页

关于

归档

stdout

Making subprocess async friendly in Python

It's been a while since i wrote something in English, mostly because there's nothing really interesting, until now. Occasionally, when facing a long running task in Python, I would choose either a distrubuted tasks queue system, or for the convenience, just the subprocess module. It's built-in and well designed for grabbing outputs of a child process runn..

更多
stdout

人声分离简单评测

娃要去表演唱歌,老师要求提供MTV。。 视频是这个,需要去掉人声部分 先用 ffmpeg 提音轨 ffmpeg -i v.mp4 -ac 1 1.mp3 微信小程序上的全是骗充值的,网上的服务: 没卵用 https://vocalremover.org/ 名气很大,搜出来第一就这个 没用 https://www.conversion-tool.com/karaoke/ 卡死 https://www.songpeel.com/song-to-karaoke 要安装 https://github.com/adefossez/demucs 要6G显存 https://github.com/Anjok07/ultimatevocalremovergui 效果很好! https://tunebat.com/Vo..

更多
stdout

吐槽pynsq,另外给subprocess糊了一个异步

pynsq太烂了 起初是因为需要在 Web API 里消费一个消息队列(nsq),给浏览器返回 EventSource 做实时输出。但是没想到官方库pynsq居然写得这么渣: def _handle_term_signal(sig_num, frame): logging.getLogger(__name__).info( 'TERM Signal handler called with signal %r', sig_num) tornado.ioloop.IOLoop.current().stop() def run(): """ Starts any instantiated :class:`nsq.Reader` or :class:`nsq.Wr..

更多
stdout

如何删除 C:\Windows\WinSxS 文件

天气热得心慌,看Win10不爽,决定删几个文件玩玩 首先你需要以 SYSTEM 用户启动 cmd.exe Win+R 敲入: "\\live.sysinternals.com@SSL\DavWWWRoot\tools\PsExec.exe" -i -s cmd.exe 回车。确认当前身份敲入 whoami 夺权:takeown /F "C:\Windows\WinSxS\Backup" /A /R /D Y 授权:cacls "C:\Windows\WinSxS\Backup" /T /G SYSTEM:F /C 开删:rd /s /q "C:\Windows\WinSxS\Backup" 爽! 当然,你也可以让系统代替你清理: Dism.exe /online /Cleanup-Image /Sta..

更多
stdout

从 Leanote 迁移到 Obsidian

差不多积累了10年的笔记,因为软件开发商跑路去做 2B 了,这玩意也没人维护了。换 Obsidian Leanote 不支持导出 .md 但是它自己的格式就是 json,转换一下很简单。 把一个目录下的笔记批量导出为 Leanote 格式,比如导出到 /tmp/folder1 执行Python代码 import json dir = '/tmp/folder1' for n in os.listdir(dir): if not n.endswith('.leanote'): continue with open(f"{dir}{n.replace('.leanote', '.md')}", "w") as f2, open(dir+n) as f1: f2..

更多
stdout

1900年居然不是闰年?

看HN讨论 昨天2024-02-29有哪些闰年的bug,有一个吃惊了 >>> datetime.datetime.strptime('Feb 29', '%b %d') ValueError: day is out of range for month python的 datetime() 默认 year=1900。但是心里想 1900 不应该也是闰年吗? 查了下还真不是。囧。一年有 365.242374 天: 近似看成 365.25 天就是4年一润; 剩余的精度 365.25-365.242374 == 0.0076 天 而且,0.0076 ✖️ 400 == 3.0504,也就是每400年要润3天 结论就是每100年一润,但是每400年又不润 比如 1700, 1800, 190..

更多
stdout

穷人的supervisor OOM killer

厂里的docker上跑了个supervisord,用来把挂掉的进程拉起来。最近的问题不是进程挂掉,而是内存泄漏 跑着跑着内存爆了,然后宿主机OOM随机杀掉一个进程,结果占用内存最大的那个还活着,正常的进程反而gg,该漏的继续漏,然后反复OOM。想看下哪里漏了,--cap-add=SYS_PTRACE 也不给加,OOM策略也不给调,思来想去只能自己做防水补漏了。做起来也简单,supervisor再跑一套bash脚本即可: while true; do p=`ps --no-headers -xo rss,pid --sort=-rss | awk '{ if($1 > 1000000){ print $2 } }'` kill $p 2>/dev/null || echo ..

更多
stdout

从 幻兽帕鲁 Palworld 设想一下未来的联机游戏

打开steam刷到一个新闻《Ten years of RimWorld》。啊?都十年了?回想起来最近非常爆火 幻兽帕鲁 Palworld ,被大家称为缝合怪,什么都缝了。细细盘点一下我对该类别游戏大杂烩的一个评价,以及我对未来游戏机制的一个YY。 Minecraft 挖矿争霸 我从这玩意还没中文名字的beta时代就开始玩(盗版),从山脚下一个 1x2 穴居的第一夜,挖到自己的第一铲煤,再到湖底水晶宫,然后修建自己的铁路在广袤的平原和山间品味那让人留连忘返 procedure generated terrain ,那个时候真的能给人一种激动。 后来搞的什么创造模式,各种复杂的机制和道具,没那个简单的快乐了。 Conan Exiles 和 minecraft 的 voxel 建筑风格相比,它的建筑是由正三角形..

更多
stdout

FastAPI/Starlette 长连接感知断开

之前写过如何 在服务器重启的时候感知长连接,最近发现折腾复杂了。 https://github.com/encode/starlette/discussions/1776 测试代码: import asyncio async def async_streamer(): try: while True: yield b"--boundary\r\nContent-Type: text/plain\r\nContent-Length: 1\r\n\r\n1\r\n" await asyncio.sleep(0) except asyncio.CancelledError: print("caught cance..

更多
stdout

query git notes with Github GraphQL

git notes is an interesting feature, you can use it like git notes add -m "hello test git notes" git push origin 'refs/notes/*' Github supported them back in 2010 then gave up LMAO. If you need to retrive them with Github API, try GraphQL like this { repository(owner: "est", name: "snippets") { refs(refPrefix:"refs/notes/",first:1) { ..

更多
123