qt-style

qt样式

d://stylesheet.qss

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
QLineEdit {
padding: 1px;
border-style: solid;
border: 2px solid gray;
border-radius: 8px;
}

QPushButton {
color: white;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c);
border-width: 1px;
border-color: #339;
border-style: solid;
border-radius: 7;
padding: 3px;
font-size: 10px;
padding-left: 5px;
padding-right: 5px;
min-width: 50px;
max-width: 50px;
min-height: 13px;
max-height: 13px;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "widget.h"
#include "ui_widget.h"
#include <QFile>
#include <QString>
#include <QDebug>
#include "form.h"
#include <QFrame>
/*
QLineEdit {
padding: 1px;
border-style: solid;
border: 2px solid gray;
border-radius: 8px;
}
QPushButton {
color: white;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c);
border-width: 1px;
border-color: #339;
border-style: solid;
border-radius: 7;
padding: 3px;
font-size: 10px;
padding-left: 5px;
padding-right: 5px;
min-width: 50px;
max-width: 50px;
min-height: 13px;
max-height: 13px;
}
*/

/*
* d://stylesheet.qss 内容如上
*/



Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QFile File("d://stylesheet.qss");
if(! File.open(QFile::ReadOnly)){
qDebug()<<"file not exist";
return ;
}

QString StyleSheet = QLatin1String(File.readAll());
// qDebug()<<StyleSheet; /*如果发现有乱码,请改成ansi编码 */
ui->widget->setStyleSheet (StyleSheet);
Form *scene1 = new Form;

/*
* form 里的子控件设置样式
*/

QFrame *childframe = scene1 -> findChild<QFrame *> ("childframe");
childframe->setStyleSheet (StyleSheet);
/*
* 设置整个form样式
*/

// scene1->setStyleSheet (StyleSheet);
scene1->show ();
}

Widget::~Widget()
{
delete ui;
}

毕设系统设计

系统框图

主要编程实现语言

  • c++ & opencv & Qt —-> 图像处理部分
  • python —-> 上传图像到qiniu云(代替 c++ post? )
  • java —-> android手机端

服务器使用框架

  • restfull —-> flask
  • android —-> urlimageviewhelper-1.0.4

android & genymotion

解决android下载慢的问题

挂上 cow 走 http 代理,ipv6速度很快

Genymotion 的 unknown generic error

解决方法:开http代理

远程登录用户注意,远程用户启动不了,可以本地登录启动genymotion后再远程登录

wu yi benchmark

OPE

anno GTRect 的来源

而不是来自 mat 文件

因为有些mat 里没有 anno ,比如coke 这个测试视频

计算自己的 over area

都在util文件夹里

my first pipy app

终于照葫芦画瓢写了个自己能用到的应用

需求分析

平时写博客什么的,发现用别人的图床,不一定可靠,用的人多了,速度就慢,而且不一定啥时,人家就不提供服务了.使用新浪微博的图床好像不能删除传过的图像,万一哪天自己需要删除呢,还是自己的图床好,再说,截图后直接保存外链链接到黏贴板,这不是省去了切换的麻烦了吗,专心于写博客吗.

Github地址

https://github.com/wzyuliyang/qiniu4blog

目前写博客的装备

打开截图脚本自动上传到 qiniu 并且生成外链到粘贴板

http://voyager91.qiniudn.com/Screenshot 2015-04-05 21.38.20.jpg

打开一个 intellji 的 ide

主要是使用它的远程同步

打开 iterm2

编译部署到 github

效果

xpath 练习

xpath 中的基本语法

chrome dev tool 可以拷贝 xpath

//a//b

相对路径 a/c/b 符合, e/a/c/b 也符合

/a/b

绝对路径 root/a/b

例子分析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
#!//usr/bin/python
import requests
import lxml.html

def send_request():
# xpath (GET http://www.cnblogs.com/yuliyang/)

try:
r = requests.get(
url="http://www.cnblogs.com/yuliyang/",
)
print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
return r.content
# print('Response HTTP Response Body : {content}'.format(content=r.content))
except requests.exceptions.RequestException as e:
print('HTTP Request failed')



dom = lxml.html.fromstring(send_request())

print '''
+--------------------------------------------------------+
| |
| here is what xpath outcome |
| |
| http://asciiflow.com/ |
| |
| |
| |
+--------------------------------------------------------+
'''




results = dom.xpath('//div/a[@class="postTitle2"]')
for node in results:
# print node.text
print node.attrib["href"],
print node.text
# print node.attrib["id"]
# print node.attrib["displayName"]
#输出结果:
#http://www.cnblogs.com/yuliyang/p/3786197.html [置顶]基于opencv的人脸检测的web应用
#http://www.cnblogs.com/yuliyang/p/3366343.html [置顶]基于opencv的手写数字识别(MFC,HOG,SVM)
#http://www.cnblogs.com/yuliyang/p/4390636.html 使用七牛云存储----大家自己的图床[python]
#http://www.cnblogs.com/yuliyang/p/4377961.html POST 一张 图像的调试来认识 http post
#http://www.cnblogs.com/yuliyang/p/4370873.html ubuntu 下 数学库编译链接时找不到各种数学问题解决方法 can not fon atan 等等
#http://www.cnblogs.com/yuliyang/p/4361788.html 【转】发布python的包至pypi服务器
#http://www.cnblogs.com/yuliyang/p/4349738.html 【Opencv 小工具】鼠标选区信息获取
#http://www.cnblogs.com/yuliyang/p/4344370.html Chrome的网络调试
#http://www.cnblogs.com/yuliyang/p/4271674.html winscp配置
#http://www.cnblogs.com/yuliyang/p/4271623.html switchomega配置
#http://www.cnblogs.com/yuliyang/p/4271571.html gem install走代理,速度刚刚的
#http://www.cnblogs.com/yuliyang/p/4266157.html fedora下的dropbox

其中下面表示 找到 div下的 a节点,其中 a 的属性有 class='postTitle2'

1
results = dom.xpath('//div/a[@class="postTitle2"]')

找到节点后输出 href 属性和内容 text

以下代码与上面的 node.attrib[“href”]结果一样,不过下面这种只能获取一种值,这里是 href,上面是获得节点,节点都获取了,各种属性获取就很简单了

1
results = dom.xpath('//div/a/@href')

北邮人 bt 魔力值 刷刷刷

python 刷byrBt魔力值

听说byrBt 魔力值可以换邀请,为了复习下 python 爬虫,写了个刷魔力值的脚本

废话不多说,先看效果图(跑在树莓 pi 上)

刷个250赞


其中 210参数是 bt 页面的 page 参数 215也是,意思是 220 到 220(开区间)的100个帖子都去点个赞

注意 没带 cookie 过去的话,是得不到信息的

源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import sys,os
import requests
import lxml.html
import re

#发送 get 请求到 bt page 页面
def send_get_request(page):
# My API (GET http://bt.byr.cn/torrents.php)
try:
r = requests.get(
url="http://bt.byr.cn/torrents.php",
params = {
"inclbookmarked":"0",
"incldead":"0",
"spstate":"0",
"page":page,
},
headers = {
"Origin":"http://bt.byr.cn",
"Accept":"*/*",
"Accept-Encoding":"gzip, deflate",
"Content-Type":"application/json",
"Referer":"http://bt.byr.cn/torrents.php?inclbookmarked=0&incldead=0&spstate=0&page=0",
"Cookie":"__utma=226719182.774470804.1420038474.1420038474.1420038474.1; __utmz=226719182.1420038474.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); c_secure_login=bm9wZQ%3D%3D; c_secure_ssl=bm9wZQ%3D%3D; c_secure_pass=bc49df6a5ed037c1c647353edd8f40dd; c_secure_tracker_ssl=bm9wZQ%3D%3D; c_secure_uid=MTc2OTgy; Hm_lvt_9ea605df687f067779bde17347db8645=1426764695,1426933310,1428201991,1428215228; Hm_lpvt_9ea605df687f067779bde17347db8645=1428215565",
"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36",
"Accept-Language":"zh-CN,zh;q=0.8,en;q=0.6",
"Proxy-Connection":"keep-alive",
}
)
# print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
return r
# print('Response HTTP Response Body : {content}'.format(content=r.content))
except requests.exceptions.RequestException as e:
print('HTTP Request failed')

#对页面里的 id 发送 点赞 post 哈哈哈
def send_request(id_data):
try:
r = requests.post(
url="http://bt.byr.cn/thanks.php",
headers = {
"Origin":"http://bt.byr.cn",
"Accept":"*/*",
"Accept-Encoding":"gzip, deflate",
"Content-Type":"application/json",
"Referer":"http://bt.byr.cn/details.php?id=173108&hit=1",
"Cookie":"__utma=226719182.774470804.1420038474.1420038474.1420038474.1; __utmz=226719182.1420038474.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); c_secure_login=bm9wZQ%3D%3D; c_secure_ssl=bm9wZQ%3D%3D; c_secure_pass=bc49df6a5ed037c1c647353edd8f40dd; c_secure_tracker_ssl=bm9wZQ%3D%3D; c_secure_uid=MTc2OTgy; Hm_lvt_9ea605df687f067779bde17347db8645=1426764695,1426933310,1428201991,1428215228; Hm_lpvt_9ea605df687f067779bde17347db8645=1428215565",
"Content-Length":"9",
"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36",
"Accept-Language":"zh-CN,zh;q=0.8,en;q=0.6",
"Proxy-Connection":"keep-alive",
},
data = "id="+id_data
)
print id_data ,
print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
# print('Response HTTP Response Body : {content}'.format(content=r.content))
except requests.exceptions.RequestException as e:
print('HTTP Request failed')


id_list = []

if len(sys.argv) < 3:
print "Usage:bt_magic startPage stopPage"
sys.exit()

for i in range(int(sys.argv[1]),int(sys.argv[2])):
dom = lxml.html.fromstring(send_get_request(i).content) #解析 page
for link in dom.xpath('//tr/td/a/@href'): # select the url in href for all a tags(links) #获取 页面 url
m = re.match(r'^details.php\?id=(\d*)',link)
if m:
id_list.append(m.group(1)) #获取 id

print "sum: ",id_list.__len__()

for i in id_list:
send_request(i) #开始刷

restart

start here

阿里的一道笔试题

分布式系统中的 RPC 请求经常出现乱序情况,写一个算法将一个乱序的序列保序输出

对于 [1,2,5,8,10,4,3,6,9,7] 这个序列,输出是

1
2
3
4
5
1
2
3,4,5
6
7,8,9,10

3 到来的时候已经发现 4,5 已经到来了,所以 3,4,5 一起输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python
l = [1,2,5,8,10,4,3,6,9,7]
# l = [ 3,8,2,5,1,4,7,9,6,10]
appeared_ex_print = []
waitfor = 1

while waitfor <= 10:
if l[0] == waitfor:
print l[0],
l.remove(waitfor)
if appeared_ex_print.__len__() > 0:
while (waitfor + 1) in appeared_ex_print:
print waitfor + 1 ,
appeared_ex_print.remove(waitfor + 1)
waitfor +=1
print '\n'
waitfor += 1
else:
appeared_ex_print.append(l[0])
l.remove(l[0])

kalman filter c++ demo

使用 c++编写的一个 kalman 滤波器的例子,Qt图表显示结果
查看源码 github source code