This file contains 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
def __get_proper_size_pic_from_url(url, uplimit, workbench=tempfile.mkdtemp(), pic_name=str(time.time()*1000000)): | |
pic_loc = os.path.join(workbench, pic_name+'.'+url.split('.')[-1]) | |
r = requests.get(url, stream=True) | |
if r.status_code == 200: | |
with open(pic_loc, 'wb') as f: | |
r.raw.decode_content = True | |
shutil.copyfileobj(r.raw, f) | |
else: | |
logger.warning('download pic failed with url {0}'.format(url)) | |
return |
This file contains 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: utf-8 -*- | |
import sys | |
import os | |
import os.path as path | |
def get_project_row_info(project, suffix): | |
res = { | |
'all_line': 0, | |
'annotation': 0, |
This file contains 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:utf-8 -*- | |
from collections import defaultdict | |
shinewords = open('cli.txt','r').read().decode('utf-8') | |
section = shinewords.strip().split("==========\r\n") | |
books = defaultdict(lambda : "") | |
for i in section: | |
try: | |
i = i.split('\n') | |
books[i[0]] += i[3]+'\n\n' |
This file contains 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 unittest | |
# 1situation. | |
def emailsuite(): | |
suite = unittest.TestSuite() | |
tests = [ | |
'test_normal_sendemail', | |
'test_no_dealnocb_work' | |
] | |
return unittest.TestSuite(map(testemail.EmailTestCase, tests)) | |
# 2situation. |
This file contains 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 librabbitmq import Connection | |
rconf = { | |
"host": "localhost", | |
"userid": "guest", | |
"password": "guest", | |
"vhost": "/", | |
"exchange": "kong", | |
"extype": "direct" | |
} |
This file contains 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
public class GetTest { | |
public static void main(String[] args){ | |
String targetUrl = "http://localhost:5000/getdata"; | |
HttpClient httpClient = HttpClientBuilder.create().build(); | |
HttpGet getRequest = new HttpGet(targetUrl); | |
getRequest.addHeader("Accept", "application/json"); | |
try { | |
HttpResponse response = httpClient.execute(getRequest); | |
int resCode = response.getStatusLine().getStatusCode(); |
This file contains 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 imaplib | |
def open_connection(verbose=False): | |
connection = imaplib.IMAP4_SSL('imap.gmail.com', 993) | |
# username = gmail["username"] | |
# password = gmail["password"] | |
username = 'silverdismond@gmail.com' | |
password = 'qwer`123' | |
connection.login(username, password) | |
return connection |
This file contains 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
function createComparisonFunciton(propertyName) { | |
return function(object1, object2) { | |
var value1 = object1[propertyName]; | |
var value2 = object2[propertyName]; | |
if (value1 < value2) { | |
return -1; | |
} else if (value1 > value2) { | |
return 1; |
This file contains 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
# 获取昨天今天明天日期: | |
yesterday = time.strftime('%Y-%m-%d',time.localtime(time.time() - 24*60*60)) | |
today = time.strftime("%Y-%m-%d", time.localtime(time.time())) | |
tomorrow = time.strftime('%Y-%m-%d',time.localtime(time.time() + 24*60*60)) | |
# 字符串转时间戳与时间戳转字符串: | |
timeArray = time.strptime(atimestr, "%Y-%m-%d %H:%M:%S") | |
thistime = time.mktime(timeArray) | |
value = time.localtime(timestramp) |
This file contains 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:utf-8 -*- | |
import json | |
import codecs | |
a = { "name": "一个"} | |
b = json.dumps(a, indent=4) | |
print type(b) | |
f = codecs.open('test3.py', 'wb', encoding='utf-8') | |
f.write(b.decode("unicode_escape")) |