Skip to content

Instantly share code, notes, and snippets.

Avatar
🍊

cosven cosven

🍊
View GitHub Profile
@cosven
cosven / main.py
Last active May 12, 2022
macOS nowplaying implemented in pyobjc
View main.py
from Foundation import NSRunLoop, NSMutableDictionary, NSObject
from MediaPlayer import MPRemoteCommandCenter, MPNowPlayingInfoCenter
from MediaPlayer import (
MPMediaItemPropertyTitle, MPMediaItemPropertyArtist,
MPMusicPlaybackState, MPMusicPlaybackStatePlaying, MPMusicPlaybackStatePaused
)
class No
@cosven
cosven / main.swift
Created May 11, 2022
macOS nowplaying for FeelUOwn
View main.swift
import Foundation
import MediaPlayer
import Network
let cmdCenter = MPRemoteCommandCenter.shared()
cmdCenter.togglePlayPauseCommand.addTarget{ (e) -> MPRemoteCommandHandlerStatus in
return .success
}
View nowplaying.swift
import Foundation
import MediaPlayer
import Network
let cmdCenter = MPRemoteCommandCenter.shared()
cmdCenter.togglePlayPauseCommand.addTarget{ (e) -> MPRemoteCommandHandlerStatus in
return .success
}
@cosven
cosven / xiami_to_fuo_collection.py
Last active Jan 5, 2021
导出虾米歌单到 ~/.FeelUOwn/collections 目录并自动刷新 UI,运行方式:fuo exec < xiami_to_fuo_collection.py
View xiami_to_fuo_collection.py
import os
from tomlkit import document, value, dumps
from fuocore.models.uri import reverse
from fuo_xiami import provider
user = provider._user
if user is None:
raise Exception('你可能没有登录')
@cosven
cosven / demo.py
Last active Dec 8, 2020
feeluown models v2 - demo
View demo.py
from typing import List
class SongDisplayModel:
pass
class SongModel:
pass
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