Skip to content

Instantly share code, notes, and snippets.

View cosven's full-sized avatar
🍊

Shaowen Yin cosven

🍊
View GitHub Profile
#!/usr/bin/python
# -*- coding:utf8 -*-
import chardet
import sys, os
import shutil
from mutagen.mp3 import MP3
import mutagen.id3
from mutagen.id3 import ID3
from mutagen.easyid3 import EasyID3
@cosven
cosven / string_cmp.py
Last active July 10, 2016 07:42
Python3 字符串比较,很奇怪。
In [33]: os.listdir('.')
Out[33]:
['.DS_Store',
'Closer - Travis.mp3',
'I Really Like You - Carly Rae Jepsen.mp3',
'Love Story - Taylor Swift.mp3',
'Per dimenticare - Zero Assoluto.mp3',
"Sono Bugiarda (I'm A Believer) - Caterina Caselli.mp3",
'The Phoenix - Fall Out Boy.mp3',
'We Are Never Ever Getting Back Together - Taylor Swift.mp3',
Feb 21, 2017 11:50:34 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up slave: ci1-mirror
Feb 21, 2017 11:50:34 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Feb 21, 2017 11:50:34 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://ci0.aws.dev:8080/]
Feb 21, 2017 11:50:34 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Feb 21, 2017 11:50:34 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to ci0.aws.dev:36840
import asyncio
from functools import partial
from slacker import Slacker
__alias__ = 'Slack 状态同步'
__version__ = '0.1'
__desc__ = 'Slack 状态同步'
@cosven
cosven / models.py
Created August 16, 2017 02:17
tranditional model definition ways in python
"""
there are three typical ways to define a model in python.
"""
# ---------------------------------------------------
# use namedtuple: simple but not flexible or powerful
# ---------------------------------------------------
from collections import namedtuple
@cosven
cosven / asyncio_socket_server.py
Last active November 2, 2017 13:13
learning asyncio in practice
# server made with asyncio
# flake8: noqa
import asyncio
from socket import (socket, AF_INET, SOCK_STREAM, SO_REUSEADDR, SOL_SOCKET)
async def start_server(sock):
server = await loop.create_server(asyncio.Protocol, sock=sock)
@cosven
cosven / asyncio_douban_zufang.py
Last active March 14, 2022 09:46
北京豆瓣租房小脚本...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
豆瓣租房爬虫
Install:
pip install beautifulsoup4
Usage:
@cosven
cosven / mac_global_hotkey.py
Last active January 8, 2022 13:59
OSX global hotkeys via python.
# -*- coding: utf-8 -*-
"""
Dependency::
pip3 install pyobjc-framework-Cocoa
pip3 install pyobjc-framework-Quartz
Usage::
@cosven
cosven / subtree.py
Created April 27, 2018 03:17
leetcode subtree visualization
import random
from graphviz import Digraph
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
@cosven
cosven / table_context_menu.py
Created June 30, 2018 00:51
feeluown 项目一些废弃代码
def contextMenuEvent(self, event):
menu = QMenu()
index = self.indexAt(event.pos())
song = self.model().data(index, Qt.UserRole)
if song.album:
show_album_action = QAction('专辑:{}'.format(song.album.name), menu)
show_album_action.triggered.connect(
partial(self.show_album_needed.emit, song.