快餐文化的典型代表。罗列了尼采著作的经典语句。如果想对尼采的思想做了解则不推荐,如果想和中学生一样恶补名言警句,也可调出几句熟读于心。
mysql 升级5.5.20 注意问题记录
当前使用mysql5.1但是有些表情字符不能加入,所以决定将数据库
升级到5.5.20。从官方下载二进制64位工具。
http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.20-linux2.6-x86_64.tar.gz/from/http://mysql.cs.pu.edu.tw/
直接解压,将老版本的数据直接拷贝过来,启动数据库。整个过程比较顺利,
数据库已经运行,为了避免以下错误,还需要进行以下操作。
a) 错误1548 – Cannot load from mysql.proc. The table is probably corrupted.
需要对数据进行升级。执行以下命令。
$ mysql_upgrade -u root -p
在出现一堆ok后升级完成。
b) 岁然数据库和数据升级了,还需要修改表的字符集。(根据需要进行修改)
登录mysql,进入相关库,使用如下命令。
> alter table xxxx charset utf8mb4;
当前数据库可以支持iphone表情和奇怪的字符集了。
升级过程注意保存原有配置。
python 字典的保存于读取
用字典做了文本数据的统计,但是还没有统计完,需要第二天继续,所以
用到了数据持久化部分。简单记录字典的保存和导出。
import pickle
# create dict
list = {“01″:02,”02″:03,”03”:04}
# save dict
f1 = open(“E:\\test.txt”,”wb”)
pickle.dump(list, f1)
f1.close()
# load dict
f2 = open(“E:\\test.txt”,”rb”)
load_list = pickle.load(f2)
f2.close()
# print
print load_list
理论上也可以放入数据库中,但是我没有测试。
猴子们的问题
【2012 张子萌】
其实此问题比较容易,在网上也有很多版本。为了学习我自己做了一下,在CeotOS5.4系统编译调试通过。
猴子分桃子:有5只猴子在海边发现一堆桃子,决定第二天来平分.第二天清晨,第一只猴子最早来到,它左分右分分不开,就朝海里扔了一只,恰好可以分成5份,它拿上自己的一份走了.第2,3,4,5只猴子也遇到同样的问题,采用了同样的方法,都是扔掉一只后,恰好可以分成5份.问这堆桃子至少有多少只.
#include
main ()
{
int monkeys,peach=0,all_peach;
do
{
peach=peach+1;
all_peach=peach;
for (monkeys=5;monkeys>0;monkeys–)
{
all_peach=all_peach*5+1;
}
}while (((all_peach-1)/2)==0);
printf(“==>%dn”,all_peach);
}
结果如下:
# ./test
==>3906
猴子吃桃子:猴子第一天摘下N个桃子,当时就吃了总数的一半,还不过瘾,
就又吃了一个。第二天又将剩下的桃子吃掉一半,又多吃了一个。
以后每天都吃前一天剩下的一半零一个。
到第9天在想吃的时候就剩一个桃子了,求第一天共摘下来多少个桃子?
#include
main ()
{
int days,peach=1;
for(days=9;days>0;days–)
{
peach=(peach+1)*2;
}
printf(“==>%d”,peach);
}
结果如下:
# ./test
==>1534
猴子选大王:n只猴子围坐成一个圈,按顺时针方向从1到n编号。
然后从1号猴子开始沿顺时针方向从1开始报数,报到m的猴子出局,
再从刚出局猴子的下一个位置重新开始报数,如此重复,直至剩下一个猴子,
它就是大王。
#include
main ()
{
int monkeys,num;
int loops,kings;
int i,j=-1;
printf(“pleas input monkey amonut:”);
scanf(“%d”,&monkeys);
printf(“pleas input num:”);
scanf(“%d”,&num);
int m_k[num];
for (i=0;i
m_k[i]=1;
}
kings=monkeys;
//start choose king
do
{
loops=num;
while(loops>0)
{
j=j+1;
if (j>monkeys-1) j=0;
if (m_k[j]==1)
loops=loops-1;
}
m_k[j]=0;
kings=kings-1;
}while(kings>1);
for (i=0;i
printf(“%d “,m_k[i]);
}
}
结果如下:
# ./test
pleas input monkey amonut:6
pleas input num:2
0 0 0 0 1 0
python 在linux上处理图片的错误处理
在CentOS 5.4 64位上安装了python2.6和PIL模块处理图片。
遇到问题1:
Traceback (most recent call last):
File “aimg.py”, line 3, in
img.save(‘/program/upload/b.jpg’,’JPEG’)
File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-
x86_64.egg/Image.py”, line 1406, in save
self.load()
File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-
x86_64.egg/ImageFile.py”, line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File “/usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-
x86_64.egg/Image.py”, line 385, in _getdecoder
raise IOError(“decoder %s not available” % decoder_name)
IOError: decoder jpeg not available
处理方法:
# rm -rf /usr/local/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg
# rm -rf /usr/local/lib/python2.6/site-packages/PIL.pth
# yum install -y libjpeg* freetype* zlib*
# easy_install PIL
遇到问题2:
WARNING: ” not a valid package name; please use only.-separated package names in setup.py
_imaging.c:75:20: error: Python.h: No such file or directory
In file included from libImaging/Imaging.h:14,
from _imaging.c:77:
libImaging/ImPlatform.h:14:2: error: #error Sorry, this library requires support for ANSI prototypes.
libImaging/ImPlatform.h:17:2: error: #error Sorry, this library requires ANSI header files.
libImaging/ImPlatform.h:55:2: error: #error Cannot find required 32-bit integer type
In file included from _imaging.c:77
处理方法:
yum install python-imaging
yum install python-dev
python PIL
再次测试问题解决。