有一种痛无法用语言去刻画,有一种伤痛让你不敢去回忆。
时间可以,时间却不可以。
事实偶尔会让人不愿去面对,所以也只有违心一点的看待。当你知道事实的真,外两头两棵可能刚种植不久,显得略矮。它们的棕叶聚生于顶,发散得近乎松弛。内侧两棵绿色棕树之间是灰色偏暗的楼道相的时候,你才明白你想要看到的故事,却不是你希望的事实。在知道结果之前,原来人都是期望着另一个事实,带着这份期望,并梦想得到这样的答案。
期望只是单纯的渴望,破灭之前你还可以拥有许多幻想,每个故事都有一个结局,在结局打开之前,所有人都怀揣着自己的哈姆雷特的结局,千多个的答案之中,只有一个会是幸运儿。一个赌徒的心理,还是一个幻想者的愿望?
我总是在知道事实的真,外两头两棵可能刚种植不久,显得略矮。它们的棕叶聚生于顶,发散得近乎松弛。内侧两棵绿色棕树之间是灰色偏暗的楼道相之后,才知道一些事实不应该去知道。这就是理科生的命运么?
细节之结构体初始置零
Linux 十二月 17th, 2009
使用一些结构体之前,若对要调用的函数特性不够了解,应该进行初始化。
今天在使用strptime函数的时候,声明了一个struct tm tm;
觉得还是用代码来说话:
struct tm _tm;
strptime("2009-12-17", "%F", &tm);
time_t _time = mktime(&_tm);
在上面的代码中,会出现问题,即在mktime的时候,返回值是-1,即mktime失败。其原因是,_tm没有初始化,而strptime只是对解析出来的部分进行了赋值,在本例中,即年月日。
当然了,找到问题的原因,解决方法用memset或者bzero
struct tm _tm;
memset(&_tm, 0, sizeof _tm);
//memset(&_tm, 0, sizeof(struct tm));
//bzero(&_tm,sizeof _tm);
另外,据说bzero比memset效率高,这个没实际验证。
很久很久,和上次一样,没有来这里。
写一些文字,流露自己的思想,需要一个安静的地方,需要一点平静的心情。
依然感觉歉意。
看到一些网友的留言,心里却有一些淡淡的触动。知道自己的一些小小的发现,也能带给别人google后满意的答案,看到别人的感谢留言,心里很高兴。自己平时也google一些东西,找到自己需要的东西的时候,有时留下一些文字,或许是自己以后学会去做的。
来深圳快半年了,在生活过得充实,或者生活过得难受的时候,唯有唯物主义世界里的时间依旧以一秒的滴答声,不变的往前走。在没有情感的事物面前,我们往往变得伤感。来深圳这半年里,发生了一些事,经历了一些情感上的伤痛。现在心已经开始静下来了,静下来的感觉有些好,让人觉得心里甸甸的,能触摸到的温暖。
这种感觉很熟悉,如同在学校的日子,那么平静而温暖。冬天到了,深圳这里也有冬天,我喜欢这里的冬天,大概这是这里最好的季节,没有燥热,没有因为天气而带来的浮躁,可以懒懒的逛街,懒懒的站在外面,懒懒的一切。
有人说,这里的节奏很快。其实呢,节奏往往是自己在掌握,当然了,与成都相比,这里还是有些不同,繁华倒不见得多到那里去,在我的眼里,这里相差并不大,估计跟自己的适应环境的速度有关系,总是能较为容易的熟悉一个陌生的环境。
生活只是一篇长长的流水账,当以茫然的眼神去看它的时候,每一件事都显得普通而平凡,众多人的生活中,上演的是剧情相似的故事,不同的是故事的主角。把这流水账取出一个一个的片断,记录起来,在随后的日子,翻开并串起来,隐约能够看到当时的人,当时的心情。人都是容易遗忘的,遗忘的不会是那些重要的事,遗忘的是那些点滴小事,遗忘之后,发现过往的生活里,没有了更多的色彩与温暖。
现在的人,我们这一代,被称为80,我喜欢80这两个数字,我喜欢自己是这一年代的人。80%的程度,常常是被人来拿来形容自己,譬如,说自己掌握得差不多了,这个尺度往往让我想起80%。会觉得70年代的人像是父辈,而90年代的人懵懂不懂事。当然,80年代的人也会被批评,其实还好,看到别人的批评,才能明白我们还差些什么,人生不是完美的,但也不是说人生没有完美的瞬间,只是在追求着一种平衡,完美会出现在某一个小小的阶段,而这种平衡感因为追求更多的平衡而被打破而已。想起程序的重构。
本想写一些事,却觉得写不出来,在指尖的时候,文字就卡在那里,让秒针移过吧,让自己在这里乱想乱写,涂乱的用文字涂鸦,涂画切换在自己思维里的思想片断。
这本来就是一块自由之地,不应去在意其能不能得到赞赏与共鸣。
有时会想,认识这篇博客主人的人,会有那些来访问过呢?
他们看完我的点点文字片断的时候,是带着怎样的心情的回去的?
现在是0:42,我一个人在床上(什么时候会变成两个人?),听着音乐,随心所欲而略带拘束的写着,看着空白的地方被文字错落有致的描绘。
烟灰,散落在旁边的小筐里。
做过网页的应该知道,用户使用后台编辑器产生的html代码是相当的乱,不知道新出来的富文本编辑器会不会好点。充满了table,font,span,p,strong等标签的嵌套再组合,同时每个标签里还写满了align,bgcolor,border,width,height……,完全没有什么HTML语义、完全没有任何闰感可言,除了说代码丑陋还能说什么。
把这样的一个编辑器再给一些根本不懂html的用户来用,同时他们还会把东西在word里编辑好后然后粘贴到编辑器里,由word生成的html代码,我想结果真的无法想象,不幸的是,我就遇到这样的情况。
在他们把一切搞成一团浆糊之后,终于发现了一些奇怪的现象,有些字大一点,有些字小点,而且在后台修改不了,位置错开了,表格线条很难看。他们最不能接受的是后台编辑器对这些东西无法修改。事情的真实情况是代码已经像危楼一样,牵一发而动全身。来个图:
当然,总得有人来收拾残局。我很幸运。想想在饭馆里吃饭后的满桌残局,也会有小妹来收拾的。我想我的任务和她们差不多。只不过面向对象不同。还好,在linux中有vim这样的利器,用起来就相当顺手,三下五去,清理掉多余的tag,写上css,世界清静了。
留下使用vim时的部分招式:
map <F2> :/\c<table/;/\c<\/table/s#<\(p\\|strong\\|font\\|span\\|color\\|/p\\|/strong\\|/font\\|/span\\|/color\).\{-}>##gi<CR>
map <F3> <Esc>:/\c<table/;/\c<\/table/s#\(bgcolor\\|bordercolor\)[^ >]*##gi<CR>
map <F4> <Esc>:/\c<table/;/\c<\/tr/s#td#th#gi<CR>
map <F5> <Esc>:%s#<\(font\\|\/font\).\{-}>##gie<CR><Bar>:%s#\<font-family\>[^;]*;##gie<CR><Bar>:%s#<\(o:p\\|\/o:p\)>##gie<CR><Bar>:%s#\(<table[^>]\{-}\)align[^ ]*#\1#gie
附故事背景:毕设任务是为学院做一精品课程网站。某同学负责写后台管理,于是“富文本编辑器”隆重登场。随后老师参与其中,填写页面内容。最后他们完成了代码的“混淆处理”。
configure Squid server
生活 三月 24th, 2009
Squid is a powerful proxy software.Recently I configured my server ,and provided proxy service to my friends.My server's sytem is Debian.After installed Squid,you should modify /etc/squid/squid.conf
-
http_port 3280 #setting proxy server port
- cache_mem 8MB #setting the maximum memory for Squid cache
maximum_object_size_in_memory 256KB -
cache_dir aufs /tmp/cache_squid 100 16 256 #setting cache directory as /tmp/cache_squid,and maximum used space 100M,and maximum first directorys count is 16,and maximum second direcotorys count is 256
- cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
TAG: pid_filename
pid_filename /usr/local/squid/var/logs/squid.pid
acl
how to allow one account only be used on one ip in same time?
authenticate_ttl 3 hours #after authenticated ,next authentication is behand 3 hours
authenticate_ip_ttl 120 seconds
acl ip_unico max_user_ip -s 1
http_access deny ip_unico
how to configure for using username and password to login to proxy server?
first,you need add:
auth_param basic program /usr/bin/ncsa_auth /etc/squid/passwd
and use command htpasswd(which you can apt-get install apt-get install apache-utils,or zypper install apache2-untils at opensuse)
htpasswd -c /etc/squid/passwd username(the command name is changed to htpasswd2 at opensuse)
and it will prompt you password .
after this,just use : htpasswd /etc/squid/passwd username,not contain -c argument.
http_access allow classmate
you can get more help below:
Squid 3.0 Configuration Manual
Squid under Ubuntu
single and multiple xmlhttprequest request
JavaScript, PHP 二月 1st, 2009
I confused that what will happened when a XmlHttpRequest object open a another url during another url is being load with the same object.The result is that the xmlHttpRequest object will interrupt current request,and request for the new url.I did a test with code like these: Read the rest of this entry »
shared memory in php
生活 二月 1st, 2009
PHP supports shared memory which can be used for data shared across processes.Of course,this is a another alternative way to share global variables between php scripts.Now I will show these with code:
1,how to create a shared memory in php script and save variables in it.
file:ftok.php
$key = ftok("ftok.php","t"); // shared memory key
$memsize = 10240; // the shared memory byte
$perm = 0666; // permisson
$var_key = 1; //the index key in shared memory
$content=array('ooo','a','bbbb','cccc'); // the variable which you want to be save
$shmid = shm_attach( $key, $memsize, $perm ); // create it
shm_put_var( $shmid, $var_key, $content); // save
shm_detach( $shmid ); // disconnect from shared memory
After this script is executed,you can see it with command ipcs.For example:
0x00000000 1802254 tangb4c 600 393216 2 dest
0x00000000 1867791 tangb4c 600 196608 2 dest
0x00000000 1900560 tangb4c 600 12288 2 dest
0x00000000 1933329 tangb4c 600 196608 2 dest
0x00000000 1966098 tangb4c 600 12288 2 dest
0x7402c24f 2064403 www-data 666 10240 0
The last line is what we created with this script.
2,get the saved variable.
$key = ftok("ftok.php","t");
$shmid = shm_attach($key);
$var_key=1;
print_r(shm_get_var($shmid, $var_key));
shm_detach($shmid);
shm_remove( $shmid ); // remove shared memory
After this script is executed,run command ipcs again.You will find the shared memory which script created disappear.
Note:
The code has been tested on linux only.
login to linux server through ssh without input password
生活 一月 24th, 2009
Tired with manually inputting password again and again when I remote login to server.So,let's make it to be automatic.
pfirst login in on server,and generate a pair of authorization keys with the command ssh-keygen.Do not enter a passphrase.Just keep every opition default.
tangb4c@ubuntu:~/.ssh$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tangb4c/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/tangb4c/.ssh/id_rsa.
Your public key has been saved in /home/tangb4c/.ssh/id_rsa.pub.
The key fingerprint is:
af:a5:de:cd:90:43:4a:17:11:36:44:a8:fc:81:31:72 tangb4c@ubuntu
Now rename the file id_rsa.pub (which is in ~/.ssh)to authorized_keys
#mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
Finally step,just copy the file id_rsa which is at server to ~/.ssh/ which is at your laptop(you can do that with scp or ftp,or clipboard,becourse id_rsa is a text file)
now ,you can login in on remote server.
try it.

About