Skip to content

Instantly share code, notes, and snippets.

View cosven's full-sized avatar
🍊

Shaowen Yin cosven

🍊
View GitHub Profile
This file has been truncated, but you can view the full file.
goroutine 3620521 [running]:
runtime/pprof.writeGoroutineStacks(0x40a8ae0, 0xc00827fdc0, 0x0, 0x0)
/usr/local/go/src/runtime/pprof/pprof.go:679 +0x9d
runtime/pprof.writeGoroutine(0x40a8ae0, 0xc00827fdc0, 0x2, 0x13951e6, 0xc009e2b340)
/usr/local/go/src/runtime/pprof/pprof.go:668 +0x44
runtime/pprof.(*Profile).WriteTo(0x5a60da0, 0x40a8ae0, 0xc00827fdc0, 0x2, 0xc00827fdc0, 0xd)
/usr/local/go/src/runtime/pprof/pprof.go:329 +0x3da
net/http/pprof.handler.ServeHTTP(0xc011b55991, 0x9, 0x40fd480, 0xc00827fdc0, 0xc001003400)
/usr/local/go/src/net/http/pprof/pprof.go:245 +0x33a
net/http/pprof.Index(0x40fd480, 0xc00827fdc0, 0xc001003400)
@cosven
cosven / t.py
Last active October 28, 2020 05:15
导出网易云音乐歌单到 fuo 文件
"""
Usage:
1. 在 FeelUOwn 中登录网易云
2. fuo exec < t.py
"""
from fuo_netease import provider
from fuocore.models.uri import reverse
from fuocore.cmds.helpers import show_song
@cosven
cosven / i_generation.c
Created October 15, 2020 02:48
get file inode number and inode generation number
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <linux/fs.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int main (int argc, char **argv) {
@cosven
cosven / .fuorc.py
Created May 15, 2020 14:30
右键找相似
def add_download_action(ctx):
from fuocore import aio
from fuocore.models import ModelType, SearchType
global app
def sample(models):
for model in models:
if model.meta.model_type == ModelType.song:
print(str(model))
@cosven
cosven / .fuorc.py
Created May 13, 2020 16:41
example
# -*- mode: Python; -*-
# vi: ft=python
import json
import os
import threading
from functools import partial
config.AUDIO_SELECT_POLICY = 'sq>>>'
@cosven
cosven / run_sql.py
Last active February 25, 2020 09:01
一个方便测试 sql 的脚本,配合 ipython notebook 使用味道更佳...
"""
这个脚本的好处:运行 sql 并能看到 sql 的输出,输出格式类似 mysql client。
比如,运行下面这个脚本,会有如下输出。
```
i j
1 3
(1062, "Duplicate entry '1' for key 'PRIMARY'")
i j
1 2
@cosven
cosven / test.markdown
Created February 15, 2020 04:12
cmd 支持不同格式输出 - 方案性能对比

简单的测试了下时间,目前 4k 首歌曲,大概是这么个情况。

In [16]: start = time.time()
    ...: get_dumper('json').dump(songs)
    ...: print(time.time() - start)
0.3063631057739258

In [17]: start = time.time()
 ...: get_dumper('json').dump(songs)
@cosven
cosven / test.py
Last active February 10, 2020 07:53
profiling playlist_add fuocore.SongModel
import cProfile
from fuocore.models import SongModel
songs_10k = [SongModel(identifier=i) for i in range(0, 4000)]
songs = []
def playlist_add(song):
if song not in songs:
songs.append(song)
@cosven
cosven / youtube_provider.py
Created February 6, 2020 06:45
FeelUOwn YouTube provider
import os
import time
import json
import subprocess
from fuocore.provider import AbstractProvider
from fuocore.models import SongModel
no_proxy_list = [
@cosven
cosven / extract_sql.py
Created November 14, 2019 13:38
parse sql statements from general logs
#!/usr/bin/env python3
import re
def get_key_value(key, line):
"""get key's value in log line"""
p = re.compile(r'\[{}\='.format(key))
m = p.search(line)
if m is None: