高考段子

1
2
3
4
5
6
7
8
9
10
11
12
13
在考试时,携带一瓶白磷悬浊液,涂抹在试卷局部,交卷时夹在其他人的试卷中间,应该不会引起老师的注意,最多也只会觉得有个学生不小心将试卷弄湿了。收上去的试卷通常不是立即批阅而是先存放起来,随着水分蒸发,白磷自燃,将所有考卷付之一炬 。 嗯…同时,在试卷背面擦上一层生石灰,生石灰遇水可以放出大量热,在白磷燃烧时,如果监考老师用水扑火,那么就恭喜了!!全市的试卷统一烧毁!!随手传递正能量

给高考生的忠告:
1、反复检查文具
2、正确填涂答题卡
3、你的闹钟要调好
4、也许你会紧张但一定要冷静
5、考试之前在座位上闭目养神
6、不要在不会做的题上停留太久
7、上午考试完后睡个午觉
8、其实前七条第一个字连起来才是给各位的忠告

同学们,高考不要紧张,轻装上阵,因为:四年后你们会明白,你们今天的所有的努力,并没有什么卵用。改变你们命运的不是知识文化,主要是爹妈 ,长相 ,还有你们村是不是要拆迁了..今天的所努力成果只能决定你未来4年在哪座城市打LOL、WOW,不过我个人建议你们还是好好考,因为大城市网速快一点,而且能打4年。

隐藏“QQ软件已被破坏或部分文件丢失”弹窗

干掉了QQProtect,结果还有其他校验,老是弹窗提示“QQ软件已被破坏或部分文件丢失”,让重新安装。。
无奈暂时写了个小程序,可以隐藏安全弹窗,作为临时替代方案

代码很简单没啥东西,代码备份:

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <windows.h>
using namespace std;

int main(){
HWND hwQQSafe = FindWindow("TXGuiFoundation","QQ安全中心");
cout<<hwQQSafe;
ShowWindow(hwQQSafe,IsWindowVisible(hwQQSafe)?SW_HIDE:SW_SHOW);
return 0;
}

《Essent C++》习题 2.5 2.6

做了《Essent C++》的一个简单习题练习,结果却出现了莫名其妙的编译错误。。

先贴题目:

练习2.5
实现一个重载的max()函数,让它接受以下参数:(a) 两个整数 (b)两个浮点数 (c)两个字符串 (d)一个整数vector (e)一个浮点数vector (f)一个字符串vector (g)一个整数数组,以及一个表示数组大小的整数值 (h)一个浮点数数组,以及一个表示数组大小的整数值 (i)一个字符串数组,以及一个表示数组大小的整数值。最后,编写main()测试这些函数。

练习2.6
以template 重新完成练习2.5,并对main()做适度的修改。

很容易完成重载函数,求元素最大值可以用泛型算法max_element,直接写好代码如下

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
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

inline int max(int v1,int v2)
{ return v1>v2?v1:v2; }
inline double max(double v1,double v2)
{ return v1>v2?v1:v2; }
inline string max(const string &v1,const string &v2)
{ return v1>v2?v1:v2; }
inline int max(const vector<int> &vec)
{ return *max_element(vec.begin(),vec.end()); }
inline float max(const vector<float> &vec)
{ return *max_element(vec.begin(),vec.end()); }
inline string max(const vector<string> &vec)
{ return *max_element(vec.begin(),vec.end()); }
inline int max(int v[],int len)
{ return *max_element(v,v+len); }
inline double max(double v[],int len)
{ return *max_element(v,v+len); }
inline string max(string v[],int len)
{ return *max_element(v,v+len); }

int main(){

cout<<max(1,3)<<endl
<<max(1.1,3.1)<<endl
<<max("2333","233")<<endl;

const int len = 3;
int a[len] = {1,5,6};
float b[len] = {1.1,5.2,6.0};
string c[len] = {"322","223","233"};

cout<<max(a,len)<<endl
<<max(b,len)<<endl
<<max(c,len)<<endl;

vector<int> va(a,a+len);
vector<float> vb(b,b+len);
vector<string> vc(c,c+len);

cout<<max(va)<<endl
<<max(vb)<<endl
<<max(vc)<<endl;

return 0;
}

运行测试,输出结果为:

1
2
3
4
5
6
7
8
9
3
3.1
233
6
6
322
6
6
322

OK,继续练习2.6,以template重写以上代码,简单分析可以看出,9个函数可以简单的归纳为为种:给定两值求最大值、vector中的元素求最大值、array中的元素求最大值,对代码稍作改动,将9个max函数重写为3个重载template函数,运行

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
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

template <typename type>
inline type max(type v1,type v2)
{ return v1>v2?v1:v2; }

template <typename type>
inline type max(const vector<type> &vec)
{ return *max_element(vec.begin(),vec.end()); }

template <typename type>
inline type max(type v[],int len)
{ return *max_element(v,v+len); }


int main(){

cout<<max(1,3)<<endl
<<max(1.1,3.1)<<endl
<<max("2333","233")<<endl;

const int len = 3;
int arra[len] = {1,5,6};
float arrb[len] = {1.1,5.2,6.0};
string arrc[len] = {"322","223","233"};
cout<<max(arra,len)<<endl
<<max(arrb,len)<<endl
<<max(arrc,len)<<endl;

vector<int> veca(arra,arra+len);
vector<float> vecb(arrb,arrb+len);
vector<string> vecc(arrc,arrc+len);
cout<<max(veca)<<endl
<<max(vecb)<<endl
<<max(vecc)<<endl;

return 0;
}

编译运行不料,却显示报错信息如下:

D:\code\cpp\essential c++\2.6.cpp||In function int main()’:| D:\code\cpp\essential c++\2.6.cpp|32|error: call of overloadedmax(int, int)’ is ambiguous| D:\code\cpp\essential
c++\2.6.cpp|12|note: candidates are: type max(type, type) [with type =
int]|
D:\MinGW\bin..\lib\gcc\mingw32\3.4.5……..\include\c++\3.4.5\bits\stl_algobase.h|173|note:
const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]|
D:\code\cpp\essential c++\2.6.cpp|33|error: call of overloaded
`max(double, double)’ is ambiguous| D:\code\cpp\essential
c++\2.6.cpp|12|note: candidates are: type max(type, type) [with type =
double]|
D:\MinGW\bin..\lib\gcc\mingw32\3.4.5……..\include\c++\3.4.5\bits\stl_algobase.h|173|note:
const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = double]| ||===
Build Failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

注:这里我使用的CodeBlocks + MinGW,未测试其他编译环境

冥思苦想不得,发到群里求助,有人说了一句“using namespace std?”,于是顿时想起可能是与标准库冲突了,删去为偷懒而写的using namespace std的代码,编译运行正常。

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
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using std::max_element;
using std::vector;
using std::string;

template <typename type>
inline type max(type v1,type v2)
{ return v1>v2?v1:v2; }

template <typename type>
inline type max(const vector<type> &vec)
{ return *max_element(vec.begin(),vec.end()); }

template <typename type>
inline type max(type v[],int len)
{ return *max_element(v,v+len); }


int main(){
using std::cout;
using std::cin;
using std::endl;

cout<<max(1,3)<<endl
<<max(1.1,3.1)<<endl
<<max("2333","233")<<endl;

const int len = 3;
int arra[len] = {1,5,6};
float arrb[len] = {1.1,5.2,6.0};
string arrc[len] = {"322","223","233"};
cout<<max(arra,len)<<endl
<<max(arrb,len)<<endl
<<max(arrc,len)<<endl;

vector<int> veca(arra,arra+len);
vector<float> vecb(arrb,arrb+len);
vector<string> vecc(arrc,arrc+len);
cout<<max(veca)<<endl
<<max(vecb)<<endl
<<max(vecc)<<endl;

return 0;
}

后记

后来发现其实编译的报错信息是有指出具体代码的,

D:\MinGW\bin..\lib\gcc\mingw32\3.4.5……..\include\c++\3.4.5\bits\stl_algobase.h|173|note: const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]|

就是这一行,当时没仔细看没有想到是命名冲突的问题。。。

贴吧签到助手API整合版

由于大量站点恶意修改版权,且淘宝贩卖猖狂,kookxiang决定放弃贴吧签到助手的后续维护支持,如果百度改版不保证本程序能正常使用
希望你可以继续关注 kookxiang 的新项目:http://qiandao.in

本站提供的API地址:http://api.mrdf.pw/kksign/(已关闭)

本整合版包基于Tieba_Sign_Stable-20140819_FINAL修改,已经打包好了所有的可用插件,能找到的模板也已经打包在内。

1.0 2014.8.31
整合API,安装向导自动同时安装API,与签到助手主体同步信息。
向KK致敬!

下载地址:http://pan.baidu.com/s/1qWnvJ0C (已失效)

OpenShift 503 自动重启Shell脚本优化版

“OpenShift是红帽公司推出的一个云计算服务平台,开发人员可以用它来构建和发布web应用。Openshift广泛支持多种编程语言和框架,如Java,Ruby和PHP等。另外它还提供了多种集成开发工具如Eclipse integration,JBoss Developer Studio和 Jenkins等。OpenShift 基于一个开源生态系统为移动应用,数据库服务等,提供支持。”  ——百度百科

OpenShift虽然访问速度对于国内来说略有不足,但其作为一个免费空间,其功能相当强大,想了解的可以自行百度,这里要说的便是其503错误问题:有时维护后会坑爹的503错误码,同时ap status变成Idle或Unkonw等等,必须手动restart app才恢复。而restart app可以通过以下方式: 1.Web面板 2.SSH Consle 3.Openshift Client tools

重启一次可能你觉得并不麻烦,但经常如此,就真的很烦了,恢复不及时还可能会导致网站用户的流失。

前文说过Openshift是支持SSH Consle的,并且可以通过linux命令行控制app。Openshift应用有个组件为cron,其与http服务是独立的,可以定时执行脚本。于是,我们便可以通过建立一个cron任务自动执行我们预先设定好的bash脚本来检测网站并执行重启操作。 因为OpenShift默认是EST时区(美国东部时间所以输出时间并不是北京时间,首先执行export TZ='Asia/Shanghai' 更改date命令的时区。

我们可以通过linux系统下自带的curl命令抓取网页,curl命令的详细用法可以在网上查到,为避免冗长不再赘述。

阅读更多...

请我喝杯咖啡吧~

支付宝
微信