Something relates to Computer Science and Technology, something relates to China and something I am not sure!
Wednesday, October 31, 2012
Using the C++ Math Library
http://radio.feld.cvut.cz/matlab/toolbox/mathlib/cppmathug/working5.html
Monday, September 10, 2012
Leave Fedora, and more than pain left
I got a Lenovo IdeaPad laptop last week with Intel i5 processor. As been tortured by Linux with NVidia Optiums for a long time, I highly expect to have a well-drived Linux machine. In the past few years, Intel has been spending a significant amount of efforts on Linux and collaborate with Linux developers to provide up-to-date drivers to the community. Been affected by Intel`s reputation, I choose this Core Ivy Bridge i5 machine without hesitation.
After finishing the installation of new Fedora 17, I found there is not network interface, and only a local loopback. After few investigation, I found the wireless hardware actually is a Intel 2200N, and as far as I know, those drivers have been integrated into kernel 2.4. Then, after searching for 2 hours, what happened became more and more clear. It seems a bug only happened between Ivy Bridge processor and Intel wireless lan. So threads said that a conflict may caused by “acer_mod”, but in my case, no mod related acer is loaded. Then I do not know what to do next.
Then I connect wired lan to my laptop and plan to update the kernel, which may bring some good luck… But LAN also do not work. Atheros LAN also need driver! Ok, at that time, I gave up! I think if Fedora cannot handle it, why do not I try Debian/Ubuntu. So I download Ubuntu 12.04, and then, the wireless works.
I have to say that, as a fun of Fedora for 7 years, Fedora has been more and more inactive. Comparing to Ubuntu community, supports, user experiences and OS itself all have felled behind. I love Fedora, but I have to give it up and use Ubuntu. It may be a good choice, but feel complicated.
Friday, August 3, 2012
愤怒,偏见和猜疑都将阻碍有效的交流
愤怒:我喜欢用自己的感觉来揣度别人的想法,如果猜对了,就沾沾自喜,加强自己的偏见;如果猜错了,就恼羞成怒,不愿意承认,认为自己不会错,从而产生偏见;
偏见:我喜欢用自圆其说来预测别人的想法,有些事自圆其说了,我甚至不会怀疑,有些事不能自圆其说,我就不愿意相信,即使现在,我的脑海里还有一个声音在浮现“这世界上怎么会有不能自圆其说的事”!
猜疑:它是偏见的一种极端表现,对于我认为不能发生的事,即使发生了,我也认为其中定有内因,只是自己没有发现;对于自己认为可能发生的,就深信不疑,不发生我也认为有人从中作梗...
自己的问题最好能自己发现,在主动改正,不然有你好受的!今天是不输房子部署地的关系,明天,估计就不会这么轻松了!
Saturday, July 28, 2012
How to install a C/C++ library on a Linux which you cannot use “su” or “sudo”
If you are working with a remote server, you may not have administrator privilege, or “sudo”, to install a library like “yum install XXXXX” or “configure->make->make install”. But if you really need a C/C++ library and no one you known has administrator privilege, the following steps may save you, in most cases. I will use GNU Scientific Library(GSL) as an example to show you how to get it working in your own directory without administrator privilege.
1. Download GSL source code and input “-prefix=[PATH]” when running “configure”. This operation tells the source code that you want to put the library files in [PATH]. Once the source code is compiled, run “make install”. All the library files generated will be copied to [PATH].
2. Tell the compiler and linker where is the library. For GCC/G++, we could use “-L” to input a library path and “-I” to input a include path to the compiler. So, in your make file, we could define two lines as follows:
GSL_INCLUDE = /home/hanyu/library/gsl/include/
GSL_LIB = /home/hanyu/library/gsl/lib/
Then put those two flags in your make file as follows:
$(CC) -I$(GSL_INCLUDE) -L$(GSL_LIB)
After doing the steps above, you should successfully compile your code which depends on GSL. However, when you run your program, you may receive a error like “cannot find XXXX.so…”. To fix this, please do the following step.
3. Add the library folder to “LD_LIBRARY_PATH”. Put the following lines at the bottom to your “.bashrc” and log off:
LD_LIBRARY_PATH=/home/hanyu/library/gsl/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
Then, log in again. Your program should be executed properly.
Thursday, July 26, 2012
【转】30种编程语言的比较选择问题
本文涉及到的编程语言:C、C++、Java、C#、Prolog、VB、Scala、Clojure、Haskell、Ada、Python、Ruby、Pascal(Delphi)、Fortran、Lisp、matlab、Perl、Erlang、Boo、Tcl、Bash、C shell、Objective-C、PHP、PL-SQL、Transact-SQL、ASP、JSP、Lua、smalltalk、R、D
涉及到的工具:sed、awk、grep
我们现在学一门语言,大部分是要用到了才学(基本上是中国的公司用什么我们学什么),基于兴趣的不多。
比如,大头肯定是C++和java,因为这个最容易混饭吃。最近多玩用了Erlang,还有不少公司跟风上了Erlang,让这个沉默了好久的语言忽然被明星了。
大公司一般除了C++外,都会招Java,事实上,互联网公司,Java占了半壁江山(当然,没选java架构的除外,有不少.net族的)。所以,生活在贫困线上的广大中国程序猿很少有人会去看看诸如scala之类的玩意。不过作为胶水,python、perl还是有一定的用户量的。
似乎,我们生活中只有这么几种语言。。。
貌似,遇到一个问题,我们该选择什么语言呢?虽然每个语言本质上都是图灵完备的,但是能用prolog写出来的东西,如果用别的语言写,会无比痛苦。这就是不同语言存在的原因:不同的问题,不同思考方式(编程范式)。
- 解决问题case:已知大量事实,和事实之间的约束,要求挖掘关系。
例如,汉诺塔、地图着色、数独问题、八皇后问题等这种考验智商,并且需要从已知规则中发现模式的问题。拥有一大堆已知案例的应用(例如大部分的人工智能情况)
- 应用程序case:从小到超大型应用程序,非完全互联网应用
这也是大部分软件公司遇到的情况。一般有几种没办法分出高下的解决方案:C++,Java,C#,VB。当然,这里面可以有CLR和JVM的不同衍生。例如,理论上,你也可以用scala来代替(不过估计大型公司不会冒这个险)。还是在理论上,你也可以用函数式编程的Clojure和Haskell来做(估计没人会那么傻)。还是在理论上,也可以用Ada这种强悍的通用语言,但估计没人愿意接收比C++还复杂的编程语言。理论上(基本只能在理论上),不嫌弃的话smalltalk也行。还是在理论上,python、ruby等配合一定的图形界面库也可以胜任(但项目大到一定的程度是,你会欲哭无泪)。
但是,我另起一行。有个语言:D语言。我个人不认为不可以列入首选名单。但是貌似知名度不行啊。。。。企业支持少啊。。。。。确实是门优秀的语言。C++太尾大不掉,需要一种语言,让C++成为纯粹的C++。
稍小一点规模的,无法接收面向对象的程序员,有不少用C的。虽然OOP程序员看他们像是不开化的人,但是他们有他们的哲学(我从嵌入式开发过来,相当长时间内也拜托不了C,总本能的排斥OOP)
- 解决问题case:程序规模不是很大的偏数学问题
曾经很多人用Pascal(包括扩展的Delphi),曾经很多人用Fortran,但是都明显在退步。大型通用语言(C++、Java、C#)表明了他们在各种环境的适应能力。lisp系列也在一些问题上展现出古老的魅力。(但这个语言远没有《黑客与画家》的作者给我们描述的那样神奇,个人认为)
另外,读研的一般都用过matlab。这个工具,两个字:强大!不过仅指科学计算方面。脱离了这个方面,就得考虑合不合适了,毕竟固定的矩阵思维不是啥情况都有效的。
- 特殊应用case:需要大量处理字符串的应用
首选利器是Perl,不过如果你习惯了sed、awk、grep,也能很方便的完成相同的功能,但perl是吸收三家所长做的。
其次是C++,别拍我。诸位用过regex吗?就是boost里的那个,最近被并入C++11啦。有了正则表达式的C++,处理字符,无敌了很多哇。
- 特殊应用case:需要一个胶水,粘结不同语言写出来的程序
首选是python。俩字:精简(呀,这么说一个强大的语言有点太轻浮了,但比起ruby,确实简单呐。。。)(另外Boo在.net是可以用来取代python)
其次是ruby。俩字:复杂
毕竟,没有rails,ruby根本火不起来。事实证明,python的哲学很对。当然两种语言有很多细节的不同,甚至在编程范式上不同(真想不明白白ruby支持多种范式怎么可能是个优点?市场证明了python的纯粹)
- 特殊应用case:自动化测试
不用问了,肯定是tcl了。
由于这个特殊应用,所以个人用户基本用不到,大部分是嵌入式公司。华为、数通、迈普等。。。
- 特殊应用case:系统底层
这个肯定是C了。操作系统,驱动,底层软件,大部分都是C写的,调用API,如果不用微软的Activex之类的技术,还是得老老实实用C API的。
- 特殊应用case:系统管理
这个系统管理,一般指linux的。首选肯定是各种shell啦:Bash、C shell
- 特殊情况case:苹果平台
我们没得选。。。。objective-C
- 特殊领域:嵌入式
大部分都是C了。不过andriod平台和苹果平台就得听话了。
- 特殊应用:网页
嵌入网页内的,最火的肯定是PHP(后端)和javascript(前端)了。前者代替了古老的cgi。
但是,java系的jsp内嵌java,asp内嵌C#,都是php的强劲对手。
通用语言在各个方面咄咄逼人。
- 特殊应用:数据库
就是比哪个SQL版本更被人接收。标准sql自然不必说,根据排名,PL(SQL)/Transact-SQL上榜。
- 特殊应用:并行,分布式
并行越来越重要了。
首选Erlang。
但是,基于已有的条件,还是考虑选用通用语言的并行优化。C++、Java、C#等都在这方面做了很多优秀的工作。
- 特殊应用:特定语言的功能增强
不用问了,我想说的是Lua。用C++写实现,用Lua写逻辑是好多游戏的经典开发策略。(当然像Unity用的javascript,Unreal用的自己的。)
在通用大型语言的基础上学会用Lua加速,是一种很有趣的实践。
特殊应用:人工智能
人工智能上,prolog和lisp是宠儿。
R语言有时也被用于数据挖掘(但是太慢了)
Sunday, July 22, 2012
追忆曲艺背后的那段乡情...
How to download ringtone from AudioDraft Nokia Tune Contest
I got a new Nokia Lumia 900 and want to use one ringtone(I like Progressive Nokia most) from Nokia Tune Contest. After searching the web, there is not a good guide to tell you how to download them. So I write the following steps, attached screenshot, and hope you enjoy the great works from the contest.
1. Use Google Chrome to open the front page of the contest at Audiodraft;
2. Open JavaScript console;
3. Open Source tab and open “script_player.js”, then set a break point at line 73;
4. play the ringtone you want to download by clicking the little triangle in Audiodraft; then the console will look like the follows; click the variable “data” and copy the link in it.
5. paste the link to a new tab and you could download the ringtone, which is a mp3 file. You could use it as your ringtone by synchronizing it with Zune. Please read this to learn how to set mp3 file as your ringtone on Nokia WP phones.