This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import feedparser | |
import re | |
import time | |
URL = 'https://waimaichaoren.atlassian.net/activity?maxResults=5&os_authType=basic' | |
COOKIE_STR = """""" | |
REQUEST_HEADER = { | |
'Cookie': COOKIE_STR, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf8 | |
import subprocess | |
import itertools | |
import psycopg2 | |
dc = "a,ai,an,ang,ao,ba,bai,ban,bang,bao,bei,ben,beng,bi,bian,biao,bie,bin,bing,bo,bu,ca,cai,can,cang,cao,ce,cei,cen,ceng,cha,chai,chan,chang,chao,che,chen,cheng,chi,chong,chou,chu,chua,chuai,chuan,chuang,chui,chun,chuo,ci,cong,cou,cu,cuan,cui,cun,cuo,da,dai,dan,dang,dao,de,dei,den,deng,di,dia,dian,diao,die,din,ding,diu,dong,dou,du,duan,dui,dun,duo,e,ei,en,eng,er,fa,fan,fang,fei,fen,feng,fiao,fo,fou,fu,ga,gai,gan,gang,gao,ge,gei,gen,geng,gong,gou,gu,gua,guai,guan,guang,gui,gun,guo,ha,hai,han,hang,hao,he,hei,hen,heng,hm,hng,hong,hou,hu,hua,huai,huan,huang,hui,hun,huo,ji,jia,jian,jiang,jiao,jie,jin,jing,jiong,jiu,ju,juan,jue,jun,ka,kai,kan,kang,kao,ke,kei,ken,keng,kong,kou,ku,kua,kuai,kuan,kuang,kui,kun,kuo,la,lai,lan,lang,lao,le,lei,leng,li,lia,lian,liang,liao,lie,lin,ling,liu,lo,long,lou,lu,luan,lun,luo,ma,mai,man,mang,mao,me,mei,men,meng,mi,mian,miao,mie,min,ming,miu,mo,mou,mu,n,na,nai,nan,nang,nao,ne,nei,nen,neng,ng,ni,nia,nian,niang,niao,nie |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from django.template.defaultfilters import stringfilter, striptags, slice_filter | |
def cut_string(value, limit): | |
s = striptags(value) | |
s = s.replace('\n', '').replace(' ', '') | |
return slice_filter(s, str(limit)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#When dropbox is not working on ubuntu 12 | |
#you tried to execute on terminal: | |
#dropbox start | |
#and the error is something like this: | |
#Starting Dropbox.../home/YOUR_USER/.dropbox-dist/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required #by /usr/lib/x86_64-linux-gnu/libproxy.so.1) | |
#Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so | |
#Done! | |
#FIX | |
cd /home/YOUR_USER/.dropbox-dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
from string import lowercase | |
def test(n): | |
result = [] | |
for i in range(n): | |
result.extend(''.join(v) for v in product(lowercase, repeat=i+1)) | |
return result | |
print test(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.core.urlresolvers import reverse | |
register = template.Library() | |
@register.simple_tag | |
def add_active(request, name, by_path=False): | |
""" Return the string 'active' current request.path is same as name | |
Keyword aruguments: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- Encoding: utf-8 -*- | |
import base64 | |
import binascii | |
import cgi | |
import hashlib | |
import hmac | |
import logging | |
import time | |
import urllib | |
import urlparse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
import sys | |
import StringIO | |
import requests | |
import PIL.Image | |
import tesserwrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import os | |
In [2]: dir = '/home/liwei/boxy' | |
In [3]: sum([[os.path.join(base,file) for file in files] for base,_,files in os.walk(dir)],[]) | |
Out[3]: | |
['/home/liwei/boxy/test.html', | |
'/home/liwei/boxy/base.css', | |
'/home/liwei/boxy/jquery-1.6.4.min.js', | |
'/home/liwei/boxy/boxy.css', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tips = new Array(222); | |
code = new Array(222); | |
tips[0] = '查看软件xxx安装内容'; | |
code[0] = 'dpkg -L xxx'; | |
tips[1] = '查找软件库中的软件'; | |
code[1] = 'apt-cache search 正则表达式'; | |
tips[2] = '查找软件库中的软件'; | |
code[2] = 'aptitude search 软件包'; | |
tips[3] = '查找文件属于哪个包'; | |
code[3] = 'dpkg -S filename'; |