Skip to content

Instantly share code, notes, and snippets.

View zjjott's full-sized avatar

zhu jianjiang zjjott

  • Ant Financial
  • Hangzhou.China
View GitHub Profile
@zjjott
zjjott / main.py
Last active December 15, 2015 13:49
python爬取diameizi网页,然后下载图片
#coding=utf-8
import os
os.system("wget -r --spider http://diameizi.diandian.com 2>|log.txt")#非常简单的抓取整个网页树结构的语句————实质上是一种偷懒
filein=open('log.txt','r')
fileout=open('dst','w+')#一个装最后的结果的没用的文件
filelist=list(filein)
import urllib2,time
from bs4 import BeautifulSoup
header={
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0.1) Gecko/20100101 Firefox/8.0.1'}
@zjjott
zjjott / endpoint.py
Last active August 29, 2015 14:13
make request in django have endpoint like flask
# coding=utf-8
from django.http import Http404
from django.core.urlresolvers import resolve
class EndPointMiddleware(object):
"""make request in django have endpoint like flask"""
def process_request(self, request):
try:
@zjjott
zjjott / symbols.py
Last active January 26, 2016 06:46
simple symbols system,which is closed for four arithmetic。and resove
def isNumber(x):
return isinstance(x, (int, long, float))
def isValid(x):
return isinstance(x, (Symbols, int, long, float))
def isSymbols(x):
return isinstance(x, Symbols)
@zjjott
zjjott / repo_blame.py
Created January 24, 2017 02:51
convert git HEAD blame of every file to database,for statistics
# coding=utf-8
"""
convert git HEAD blame of every file to database
using:
$ python repo_blame.py --help
$ python repo_blame.py --uri mysql://USER:PASSWD@HOST/DATABASE --repo="/home/zhutou/work/git/linux"
# requirements:
pip install peewee==2.8.5 GitPython==2.1.1
@zjjott
zjjott / gist:90edffc72d4aa06972150d79d86618ba
Created May 28, 2018 07:48
profile_vscode_python_completion.py
4218865 function calls (3451972 primitive calls) in 19.589 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 19.595 19.595 completion.py:553(_process_request)
17143/1332 0.329 0.000 18.992 0.014 /Users/zhutou/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/jedi/evaluate/cache.py:19(wrapper)
1 0.003 0.003 18.716 18.716 completion.py:411(_serialize_definitions)
11624/272 0.080 0.000 18.650 0.069 /Users/zhutou/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/jedi/cache.py:134(wrapper)
1644/71 0.014 0.000 18.512 0.261 /Users/zhutou/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/jedi/evaluate/filters.py:105(infer)
import argparse
import json
import logging
import math
import os
import random
import time
from collections.abc import Mapping
from contextlib import contextmanager, nullcontext
from functools import partial