帐前卒专栏

Without software, we are nothing.

有道云笔记1.5正式版上线



今天晚上..或者说今天早上。反正是跨天的.有道云笔记1.5版本正式上线。开始时数据转换花了很长时间。后面基本没有出现什么大问题,主要是id不统一。整到两点钟才算正式搞好。明天早上就不准备去上班了.困…还是把这篇blog写完吧。

问题:

  1. 其实测试环境下,还是不能测试出所有到问题。因为和线上的配置不一样。
  2. 其实组内改动什么设计问题,可能牵扯到几个人,但是做设计或者真正写代码的时候,其实不知道牵扯到谁。
  3. web页面的文字链.其实没有提前做好。不知道为什么UI总是在临上线的时候才有。
  4. 技术先导的project,再让PM来设计.真的是比较痛苦。

新的功能:

  1. 客户端新浪微博帐号登录。其实根据现在的涉及还是有些bug的。比如打开两个授权页面,第一个页面其实已经不能再用来登录了。但是用户输入用户名密码还是会授权成功。至于为什么..我不告诉你~
  2. 锁屏…离线登录态….还有啥就不知道了。
  3. server端的设计有改动。
  4. 。。。。。

好了..该去睡觉了。

另外今天上线的是有道云笔记1.5正式版…..比官方稿件快7-8个小时… 另外地址是有道云笔记1.5

Windows C++程序迁移到linux



今天把程序从windows上迁移到了linux上。主要遇到到问题是: makeFile, lib库, compile error, 编码 encoding.

make file

这里其实可以使用eclipse中到cdt插件,然后就可以从eclipse中写c++。挺方便的,同时也解决了make file的问题。因为创建一个c++ 或者 c project,eclipse会自动创建一系列的makefile文件。所以让make file步骤简单无比。

lib库和include库

这里真的要注意/usr/include和/usr/lib中是否有你想要到文件。当然如果你是纯c++代码,可以尝试下只使用/usr/include/c++. 当如除了-L libpath, 还有-llibname, 这里的libname其实是libXXXX.so中的XXXX. 不过如果不会写,这里还是会费些劲。还有include路径要使用-I,每一个路径前都要有一个-I. 另外还要在eclipse run configurate中的environment中填入LD_LIBRARY_PATH,这个是你要调用的lib库(这个lib库如果不在/usr/lib中,那么就要手工将路径填入到LD_LIBRARY_PATH变量里)。并且在.bashrc中写:

1
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:your_lib_path

编码

因为windows上最常用到中文编码是GBK,而文件编码最常用到是utf-16el.这里最有可能会出错。在eclipse中或者gcc直接编译,都最好转换为UTF-8编码。文件也需要是UTF-8的编码。否则就会报”程序有游离的XXX, 忽略空字符”等诡异的错误。详见解决方法

compile error

这个可能就多种多样了。不过有c/c++基础的,应该大部分都可以搞定了。

如果使用eclipse, 直接build project就可以编译成功。然后找到main函数run就可以了。

Octopress Error, Rake Generate



Today, I met the following problem. I wrote an article, and use rake generate to generate the site. Then the console reports:

/home/chico/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse’: couldn’t parse YAML at line 3 column 17 (Psych::SyntaxError)

why?
Then I found the reason:

“\” should not be written in title of your article. If you really want to write it, use “\\”

程序中有游离的\x,忽略空字符



今天解决了linux 环境中编译c++或者c文件时产生的错误。

程序中有游离的”\xxx”
忽略空字符

以上两个错误,产生的原因和字符编码有关系。一般是文件从windows转移到linux下,然后使用c或者cc或者g++编译。产生了一系列的报警和错误信息。 解决方法如下:

1
2
3
4
1. 使用vi打开报错的文件
2. 查看其文件编码. 也就是用vi 查看encoding变量。":set fileencoding?" 
3. 如果编码不是utf-8则转换为utf-8. 使用":set fileencoding=utf-8"
4. 保存文件

当然产生这种错误的原因还有可能是由于在代码里输入了全角字符引起的。如果上面的方法不对,还需要再进一步排查cat -A filename

Xrange and Range in Python



简单来说

python range会生成一个list对象,然后返回list中的内容,而xrange不会生成list对象。所以xrange相对与range来说更省空间,并且速度较快。

在英文中的官方解释是:

class xrange(object)
| xrange([start,] stop[, step]) -> xrange object
|
| Like range(), but instead of returning a list, returns an object that
| generates the numbers in the range on demand. For looping, this is
| slightly faster than range() and more memory efficient.

ok. Do you understand?

Build Website in Ubuntu



This article will tell you how to build a website in ubuntu system. First you should install apache and php. These two tools can help you to build a small website, like “hello world” websit:D

// run the following commands
sudo apt-get install apache2 php5 libapache2-mod-php5
/etc/init.d/apache2 restart

important path

Then you should remember the following paths:

* /etc/init.d/apache2
* /var/www
* /etc/apache2/apache2.conf
* /etc/apache2/conf.d
* /etc/apache2/sites-enabled

Apache’s default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d

Test your php

1
vi /var/www/hello.php
1
2
3
<?php
phpinfo();
?>

Then call this file in browser (http://localhost/hello.php) DONE:D

Machine Learning



概率,贝叶斯,熵,条件熵。互信息I(X,Y)=H(Y)-H(Y|X),两个变量之间的依赖度。 今天接触了一个新的概念:学习的本质是压缩。化为经典就是大道至简

Jstack Jmap Resin



Today, I use jstack, jmap, and resin to look up why my server is deading in stress test. And I also find printing information into log is useful. You can print log in entrance of function and exit of function.
jstack is a tool which is looked up stack of system, specailly in threads. It is mainly for looking up dead lock and some functions which are executed too slowly.
jmap is a tool which is looked up current memory of system or some memery jvm can not delete immediately. You can use jstack like this:

1
jstack -l [pid]

If you know pid of the process, you can see what’s the situation of stacks in process. If you want to see the detail, looking at those stacks.
jmap is used like this:

1
jmap -heap [pid]

Today, Big niu Qiao tells me about JVM GC policy.
There are New Generation, Old Generate and Perm Generation in JVM. You can find them in jmap command. And New Generation are new objects. And Old Generation are old objects which are still be refered. Eden Space stores new generate objects. And From Space stores still alive objects after gc once. To space stores objects which are not refered and in From space before gc once. If an objects is in From Space many times, it will be moved to Old Generation by JVM. Perm Generation are static objects and Classes.
By the way, if your application runs in resin, you should look up those logs of resin, for example, jvm-default.log. The log file contains GC log information. If GC throws overMemory exception, you should modify your configuration of resin (resin.xml in resin4.0+). Modify or add:

1
<jvm-arg>-Xmx1024</jvm-arg>

This means set JVM heap space to 1G.

Git Alias



今天唐大牛教了些git的命令。顺便把他的git别名也发给我了。啥叫别名,就是

git br
==>
git branch

只需要在home目录下的.gitconfig文件中添加:

1
2
3
4
5
6
7
8
9
[alias]
  st = status -s
  ci = commit
  l = log --oneline --decorate -13
  ll = log --oneline --decorate
  co = checkout
  br = branch
  rb = rebase
  dci = dcommit

以后就可以使用别名了。

孔府,孔庙,孔林



今天跟姐和姐夫逛了下曲阜。三孔很小的时候去过,现在基本什么记忆都没有了。当年好像破破烂烂。现在好像好一点了。很多翻修的痕迹,如果过去不砸,也就不用修了。跟着导游看了看,貌似只有题字有看的必要。翻修的有些差,就如同翻修的长城。
在孔林里听说只要姓孔就可以埋到孔林里。孔老师看来很有希望…