2010
02.23
ok, this is one word blog. maybe i should put on my twitter…
learned a nifty tool called ‘cgvg’ under linux could help you grep and open file conveniently.
‘cg <key_word>’ lists your interested stuff like grep but with better look, then
‘vg <number>’ takes you to the corresponding line of the file
very handy, cheers!
2009
11.28
Category:
c /
Tags: no tag /
I admit that I’m not export on c, so a simple fancy declaration in c would make hairy, for example:
char *(*(**foo [][8])())[];
Eli gave an brilliant blog about that. After reading that, I’m now a little bit confident in front of those fancy declarations. It’s worth reading. Moreover, cdecl is another way to decode those declarations when you got stuck. However, the tool gives me some kind of comfort for it manifests I’m not alone who is frustrated with the declarations
2009
11.12
Category:
linux /
Tags: no tag /
When I was trying to connect my ’synergyc’ through ssh tunnel to my laptop, I got the following error:
channel 2: open failed: administratively prohibited: open failed
This was caused by settings in sshd. Check sshd_config(5) for more information. However, it’s easy to fix. Just add the line below into your /etc/ssh/sshd_config file.
AllowTcpForwarding yes
However, I get weird behavior when I enable synergy such as my mouse doesn’t work well. Sometime I need to click more than one time in task bar to switch between windows…
2009
11.10
Wow, today I know how to move and resize windows under awesome. Ok, I admit that I had not spent a little time to rtfm. Check it here and search ‘move’ ‘resize’ ‘floating’ in the doc. To summarize:
- Toggle your client ( e.g eclipse, gimp …) to floating status by ‘Mod4 + Control + space’
- To move a window, hold on Mod4 and use Button1(usually it’s the left button of your mouse) to put the window wherever you want to
- To resize a window, hold on Mod4 and use Button3(usually it’s the right button of your mouse) to play with it
That’s all for today. Next time, I’ll rtfm first if there are any functions I would like.
2009
11.08
今天读到一篇关于常见软件版权相关称谓(如自由软件,免费软件,共享软件,商业软件,私有软件等)定义文章,讲的很清楚。
以前对于自由软件的理解有些错误,实际上GPLed的软件只是属于自由软件的一部分,而GPL的目的实际上是保证软件自由的持续性,也就是有GPL保护的软件所衍生出的软件也必须遵从GPL协议,即也是GPLed的自由软件。而非GPL的自由软件如X Window System,其他人员是可以在该软件基础之上构建非自由软件的。
这里可以找到关于协议兼容性的一些说明,通常在你构建一个程序,而该程序所依赖的程序又是在不同的协议下发布的,则你需要考虑这些软件许可协议的兼容性问题。GNU网站有个关于常见各类件协议的列表与介绍,可以为你选择软件协议时提供一些参考。Wikipedia的Frees software license条目中列举一些特例,例如Apple Public Source License 1.x系列仅被OSI认可,而没有得到FSF和Debian的承认。GNU网站上有对于拒绝承认APSL是自由软件协议的解释原因。
虽然说对于一些细节上的区别有时候可能还是说不太不清楚,但目前在大的方向上已经对开源与自由软件对有了较为正确与深入理解。总结一下,FSF的宗旨在于推广赋予人们在使用软件时的自由(用FSF的话讲a social movement),而Copyleft软件协议是这一自由精神的法律保障,GPL则是GNU发布的一个Copyleft软件协议。理论上是存在除GPL以外的copyleft软件协议的。这里需要说明,所谓GPL-Compatible协议并不是指与GPL具有同样copyleft性质的软件协议,而是指在将GPL-Compatible协议发布下的软件与GPL协议下发布的软件合并时不存在问题的这些软件协议。OSI则是从软件开发或者说更加实践的角度来推广开放源代码这项软件开发的方法学(a development methodology),虽然很多协议得到FSF和OSI的认可,但是应该说两个社区的philosophy是不同的。
总的来说,我认为作为一名从事软件开发的工作者,搞清楚自己行业的规范和一些基本法律概念是有必要的。而开源运动和自由软件运动是目前任何一名软件开发工作者所不能忽视两个重要话题。对于开源与自由软件我们不应该只是一味的拿来主义或者无视法律知识产权的对其滥用,我们更需要理解其运动背后的一些东西,使其在中国得到更好发展。
Reference
- Various Licenses and Comments about Them
- Frequently Asked Questions about the GNU Licenses
- Categories of Free and Non-Free Software
- Open Source Licenses
- The Open Source Definition
- The Problems with older versions of the Apple Public Source License
2009
11.05
A great article about coroutine in C is here. I like the example which employs the controversial goto (first version), embedding unmatched braces in macros, case within sub-blocks and etc. to implement the coroutine idea. It’s ugly and awesome! Maybe we can deduce a conversation law about ugly code here, i.e. “ugly codes never disappear, they only transfer from one place to another. ”
Any coding standard which insists on syntactic clarity at the expense of algorithmic clarity should be rewritten. If your employer fires you for using this trick, tell them that repeatedly as the security staff drag you out of the building.
Gee, I must clap for the Simon’s humor and wisdom~~~
Reference
- Coroutine on wiki
- Duff’s Device on wiki
- Simon Tatham’s C oriented comprehensive introduction to coroutines
TODO
- Dan Sugalski’s less formal explanation of coroutines, including a discussion of how to handle resumption with different parameters.
- Softpanorama coroutine page Contains extensive assembler coroutines links.
2009
11.03
CTex安装包中的WinEdt对于干接触Latex的人来说绝对是个好东东,不过貌似WinEdt现在变成共享软件,30天试用到期后需要购买注册,目前个人用户的价格是40刀。如果真的像用WinEdt的话,建议不要使用破解软件,尊重作者的知识产权,这样我们才会有更多像WinEdt这样提高我们工作效率的好用的软件。如果不想花钱我推荐Vim+Vim-LaTex+CTex(支持中文环境的MikeTex)。
Windows下Vim-LaTex的默认输出格式是dvi,可以在_vimrc中加入下面的代码变为pdf,另外默认的pdf编译对于bibtex的支持有些问题,可以修改用texify编译,配置如下:
if s:MSWIN
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_CompileRule_pdf='texify --pdf $*'
endif
The command line for using bibtex is just as follows:
$ latex yourfile.tex
$ bibtex yourfile
$ latex yourfile.tex
$ latex yourfile.tex
or for short you can just run:
texify --pdf yourfile.tex
Reference
- Latex@yo2.cn
- Ctex论坛关于bibtex的贴
2009
11.03
众所周知Springer是德国最大的科学领域的出版商,这个词的在德语中指的是国际级象棋中的马,所以我们总是在看到Springer这个单词的同时也看到那个代表国际象棋中马的图标。马在国际象棋中是跳跃前进的,这也许是其名字寓意吧。马的解释是Matthias告诉我的,寓意是我瞎猜的。
2009
11.02
在还没搞明白SOA怎么改变我们的生活的时候,云计算的概念开始火热起来。IT是个喜欢炒作概念的领域,但是无论如何我相信搜狗的云输入法会改变我们未来的生活。不知道为什么越来越觉得搜狐有谷歌的潜质,或者说从某些方面两家公司有相似之处,信仰技术是互联网的本质。希望搜狐能再接再厉。
2009
11.01
Wordpress的安装
安装环境:ubuntu 904, apache2, php5, mysql5.0
# Install Apache2
sudo apt-get install apache2
# Install PHP5 and the PHP5-CLI
sudo apt-get install php5 libapache2-mod-php5 php5-cli
# Install MySQL 安装过程中会会提示设置root密码
sudo apt-get install mysql-server
# Install php/apache mysql
sudo apt-get install php5-mysql
然后依次配置apache2,测试php在apache2上是否正常运行,最后按照wordpress安装说明为其建立mysql数据库。之后的步骤是从wordpress官方网站上下载最新的发行版本,解压放在apache2相关的目录中,具体布置参考官网doc。
安装中遇到的问题
- 一开始忘记mysql的root密码,可以在网上找到reset的方法,也可以purge掉mysql然后从新安装。
- 只装了php5没有装libapache2-mod-php5,自己想当然的把wordpress设置成cgi的目录,然后瞎改一通文件权限,结果遭遇error 500。关于php文件权限,好像和cgi不一样,安装了libapache2-mod-php5后,php文件不需要有x权限直接被解释执行。因此,不需要单独配置。
- 遇到打开我的domain/blog时出现下载文件的提示"You have choosen to open which is a application/x-httpd-php",但是打开domain/blog/wp-admin时却没问题。一直以为php脚本配饰,还有执行权限的问题,搞了半天结果是Firefox缓存的问题,是之前没有装libapache2-mod-php5访问的缓存,清空缓存后恢复正常。
- 关于permalink的设置
sudo a2enmod rewrite sudo service apache2 restart
- 在wordpress的安装目录下也就是index.php目录下touch一个.htaccess文件,并设置其权限
- 根据文档,将所有apache配置中的目录的AllowOverride设为All
Theme的安装
wordpress所有的theme都存放在$BASEDIR/wp-content/themes目录下面,其下的每个子目录代表一个主题的所以相关文件。你可以直接从dashboard中搜索安装,这种方式有点类似于从ubuntu的库中安装软件。另一种安装方法是先从网上下载到自己喜欢的主题压缩包(zip或者其他格式),然后将这个文件解压放在那个themes目录下。之后你便可以从你的dashboard中进行选择设置了。
Reference
- Wordpress Official Manul
ps: 貌似wordpress对于中文的支持还不错,我装的是英文版,发布和浏览中文的blog都没有问题。