Skip to content

Instantly share code, notes, and snippets.

View ly0's full-sized avatar
👊
已全仓买入

latyas ly0

👊
已全仓买入
  • China
View GitHub Profile
# coding=utf-8
import time
import socket
import os
from tornado import gen
# class _ReleasingContextManager(object):
# def __init__(self, obj, future):
@ly0
ly0 / wait_subtasks.py
Last active March 20, 2017 20:03
wait_subtasks.py
# coding=utf-8
"""Wait for all subtasks have done.
"""
import tornado
import tornado.locks
from tornado.concurrent import Future
class ProcessWaiter(tornado.locks._TimeoutGarbageCollector):
@ly0
ly0 / anyword_aww_parser.py
Created November 13, 2016 08:40
Anyword app aww dict file parser.
import sys
import struct
filename = sys.argv[1]
with open(filename, 'rb') as f:
f.seek(12)
list_start = struct.unpack('>I', f.read(4))[0]
words_start = struct.unpack('>I', f.read(4))[0]
@ly0
ly0 / asyncio_unittest.py
Created December 4, 2015 08:35
asyncio unittest
import unittest
import asyncio
import inspect
def async_test(f):
def wrapper(*args, **kwargs):
if inspect.iscoroutinefunction(f):
future = f(*args, **kwargs)
else:
@ly0
ly0 / xiami2kgl-2.py
Created July 20, 2015 18:19
虾米音乐导出成kgl到网易音乐 含有artist title 和album的信息
#coding=utf-8
import requests
from pyquery import PyQuery as PQ
import urllib2
import sys
from bs4 import BeautifulSoup
from multiprocessing import Pool
from functools import partial
import codecs
import re
@ly0
ly0 / xiami2kgl.py
Created July 20, 2015 18:15
含专辑名 标题和艺术家的虾米歌单导出为kgl格式
#coding=utf-8
import requests
from pyquery import PyQuery as PQ
import urllib2
import sys
from bs4 import BeautifulSoup
from multiprocessing import Pool
from functools import partial
import codecs
import re
@ly0
ly0 / a.js
Created May 22, 2015 10:52
api.m.taobao.com/rest/h5ApiUpdate.do签名的算法
!
function (a) {
String.prototype.trim === a && (String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, "")
}), Array.prototype.reduce === a && (Array.prototype.reduce = function (b) {
if (void 0 === this || null === this) throw new TypeError;
var c, d = Object(this),
e = d.length >>> 0,
f = 0;
if ("function" != typeof b) throw new TypeError;
@ly0
ly0 / adhoc
Created April 19, 2014 15:43 — forked from anonymous/adhoc
#!/bin/bash
#####################################
#Author: Leon Lee #
#email: lendylongli@gmail.com #
#QQ: 730395591 #
#Version: 1.0 #
#Note: If you have some good ideas #
# or advice, please mail me^^ #
#####################################
@ly0
ly0 / dicts.py
Created April 11, 2014 11:56
dict.py + wbdict.py + etym.py = dicts.py
#!/usr/bin/python
#coding=utf-8
import os
from Queue import Queue
import sys
import threading
def get_dict(word):
text = os.popen('dict %s' % word).read()
q.put('\n' + '-'*10 + '海词' + '-'*10 + '\n' + text)
@ly0
ly0 / markdown-template.html
Created March 22, 2014 22:00
一个markdown的模板
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />