分类目录归档:我的生活

无聊矩阵

这些天线性代数的课就在说矩阵,听得有点模模糊糊。
以前中学时候研究算法时碰到矩阵都会跳过,因为看不懂一堆数字表示什么意义。不过倒是觉得很有趣。

假设一个字符串:
a b c d e f g h i j k l m n o p q r s t u v w x y z

取出16个,写在一个4×4的矩阵里:
a b c d
e f g h
i j k l
m n o p

进行一次transpose, 得到
a e i m
b f j n
c g k o
d h l p

从左到右竖着读就是原字符串了。若写成字符串:
a e i m b f j n c g k o d h l p
只有a f k p还在原来的位置,因为这4个充当了对称轴。

然后以左下到右上为轴进行一次transpose,得到
p o n m
l k j i
h g f e
d c b a

此时写成字符串:
p o n m l k j i h g f e d c b a
倒过来读又是原字符串。

其实,这些大家一眼看出来的问题也没啥好研究的,只是我无聊~~

English Homework

This is my comment on the movie “August Rush”. My English is just so so, forgive me please!

It has been a long time that I was not deeply moved by such a perfect movie. After watching this movie, August Rush, I felt terribly hurt or something annoying, some kind of feeling that could not be expressed in words. But at last, I clapped, and just clapped, for the reunion of the family, for the talent of the boy and for the existence of true love in the world.

It’s a movie about music. You can hear different kinds of music from classic to folk throughout the whole movie. I have seen that how a boy with a gift for music became a well known musician. I have learned how music produced from instruments or even simple metal things in our daily life. I have also learned how music form in a musician’s sensitive mind. It called on us to realize that music is everywhere in the world.

It’s a movie about love. It was love that made me cry several times and I tried hard to hold back my tears again and again. It was incredible as well as unbelievable. I didn’t believe it was real. I just thought it must be a boring and rubbishy fiction that contains nothing valuable again. Actually, it proved I was wrong. Though it was full of coincidences, it recalled me of my family, my childhood and of the thought of love. Why did the orphan boy have such a strong desire to find his parents? Why did the mother worry the boy so terribly? Having watched the movie, I got the answers. The orphan wanted to be loved and the parents wanted to love their child. It was love that bring brought them together in the end. The director didn’t show us the final scene of their reunion, but we can guess that it must be a beginning of a happy family.

It’s such a great movie that I have never seen! The director didn’t try to make us cry only, but to let us understand the meaning of love, discover the sources of love.

Music is played for love. When music arises and love accompanies it, happiness is coming soon!

对不起,ForeverBell

[!江苏][!广东][!连云港][!上海]糟糕!由于某些原因,此文章内容已被博主屏蔽。

ForeverBell,1995,江苏XXX人,今年上初三,才艺过人,是地球上罕见的神牛!
他在学习驱动的短短两三个月时间内,写出了大名鼎鼎的fsWalker,绝对远远超越于功能渺小的UTM。接着,在发布完全模仿且远远超于Windows版的空当接龙后,又开发出可玩性极强,让人沉迷于其中而不能自拔的Linkup。
如今ForeverBell正在开发一个不一般的操作系统——FBOS,将成为中国唯一能与Windows 7对抗的PC操作系统。FB神牛的传奇将流传千古!让我这个不善言辞的人来描述FB神牛简直是对FB神牛英明的玷污,罪该万死。

详细请点击:FBOS

ForeverBell的博客点击进入

昨晚发生的那事儿

有诗一首,不过可惜不是我作的:
华工有猛男,行为真不凡。
烛光加玫瑰,表白竹园前。
行者见此景,驻足相围观。
听者闻此声,竞相跑来看。
现场加网络,顿时闹翻天。
问是谁家女,搜是何处男。
曲尽人终散,兴致却高燃。
齐坐电脑前,大家来畅谈。
人肉真强大,不久信息传。
可怜人人网,瞬间近瘫痪。
纵比XX门,盛况不输前。
灯火逐渐灭,意兴亦阑珊。
提笔于桌前,记下此瞬间。
有诗曰:“x哥纯爷们,不输宇春男。
x哥真猛男,美名华工传”

下面有图为证:
继续阅读

无聊XX了启明高中听说练习2009

今晚夜色恐怖,阴风阵阵,想起前些天口语课时发言一半时忘词了,说不下去,突然又毛骨悚然!于是把以前高中的口语训练软件下载了下了,发现需要购买注册才能使用。60块耶~~真是舍不得花,但我花了4个小时才把这1.2G的庞大软件下载下来,又舍不得删除,真矛盾,真寂寞~~

无聊之下,想起了OD,不如就……XX之。

继续阅读

Linux下动态加载链接库

必须包含头文件 dlfcn.h。

使用到dlopen, dlclose, dlsym 3个主要函数,dlerror可以获取加载中遇到的错误的字符串。

下面给出部分代码,来自最新版homeserver:

	DBG("Loading plugin [%s]", name );
#ifdef __WIN32__
	p->handle = LoadLibrary( path );
	if( p->handle ){
		p->entry = (plugin_entry) GetProcAddress( p->handle,"plugin_entry");//
		p->cleanup = (plugin_entry) GetProcAddress( p->handle,"plugin_cleanup");//
	}
	if( !p->handle || p->entry==NULL ){
		DBG("# Loading plugin: %s failed: %d", path, GetLastError() );
#else
//linux
	p->handle = (int)dlopen( path, RTLD_LAZY );
	if( p->handle ){
		p->entry = (plugin_entry) dlsym( (void*)p->handle,"plugin_entry");//
		p->cleanup = (plugin_entry) dlsym( (void*)p->handle,"plugin_cleanup");//
	}
	if( !p->handle || p->entry==NULL ){
		DBG("# Loading plugin: %s failed: %s", path, dlerror() );
#endif

homeserver的源代码下载链接:

homeserver090930

Linux下使用readdir查找文件

在Windows上一直使用_findfirst查找文件,以为是标准库里的,可以在Linux下直接使用。今晚试了一下失败了。
Linux下使用readdir来扫描一个目录下的项目。首先,需要包含头文件dirent.h。然后定义下面搜索需要的结构。

DIR* dir_info; //目录指针
struct dirent* dir_entry; //目录项信息指针

//打开一个待扫描的目录
dir_info = opendir(“./plugins”);
if( dir_info ){
        //打开目录成功
while ( (dir_entry = readdir(dir_info)) != NULL)
{
             //忽略这两个特殊项目
             if(strcmp(dir_entry->d_name, “..”)==0 || strcmp(dir_entry->d_name, “.”)==0)
continue;
             //具体操作。。。
plugin_create( srv, dir_entry->d_name );
} // while
        //使用完毕,关闭目录指针。
        closedir(dir_info);
}

可惜,我没有找到有能够在windows和linux通用的文件扫描函数。所以只好用宏定义不同平台的处理方案。

#ifdef __WIN32__

#else

#endif

博客支持RSS订阅了

花了一个晚上, 终于让我写好了RSS 2.0的生成代码。

具体格式可以参照http://en.wikipedia.org/wiki/RSS。

使用RSS,可以方便大家查看博客的新文章,不需要打开博客地址也可以在RSS Reader里看到更新信息。

其实,我主要是参照ForeverBell(此处提及仅作参考资料,无任何个人崇拜意味)博客的RSS设计。具体地址是:

http://hi.baidu.com/foreverbell_/rss

另外,发表一个大胆的假想:Google Reader订阅的RSS貌似是多个人共享的。例如我订阅了ib的RSS,发现文章Received Time不是当前时间,而是在ib发表文章时间的左右。这可能是已经订阅过的人已经收到这个文章了。嗯,如此共享一个站点的RSS,可以节约很多资源。