Skip to content

Instantly share code, notes, and snippets.

Avatar
🍊

cosven cosven

🍊
View GitHub Profile
View goroutine.txt
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
@cosven
cosven / i_generation.c
Created Oct 15, 2020
get file inode number and inode generation number
View i_generation.c
#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
右键找相似
View .fuorc.py
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))
View .fuorc.py
# -*- 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 Feb 25, 2020
一个方便测试 sql 的脚本,配合 ipython notebook 使用味道更佳...
View run_sql.py
"""
这个脚本的好处:运行 sql 并能看到 sql 的输出,输出格式类似 mysql client
比如,运行下面这个脚本,会有如下输出。
```
i j
1 3
(1062, "Duplicate entry '1' for key 'PRIMARY'")
i j
1 2
@cosven
cosven / test.markdown
Created Feb 15, 2020
cmd 支持不同格式输出 - 方案性能对比
View test.markdown

简单的测试了下时间,目前 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 Feb 10, 2020
profiling playlist_add fuocore.SongModel
View test.py
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 Feb 6, 2020
FeelUOwn YouTube provider
View youtube_provider.py
import os
import time
import json
import subprocess
from fuocore.provider import AbstractProvider
from fuocore.models import SongModel
no_proxy_list = [
@cosven
cosven / t.py
Last active Oct 28, 2020
导出网易云音乐歌单到 fuo 文件
View t.py
"""
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 / extract_sql.py
Created Nov 14, 2019
parse sql statements from general logs
View extract_sql.py
#!/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:
You can’t perform that action at this time.