2013年9月21日星期六

zsh: jekyll command not found

重启系统后,运行jekyll命令显示

jekyll: commmand not found

使用如下命令解决问题:
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

参考:http://stackoverflow.com/questions/15409418/after-installing-jekyll-getting-bash-jekyll-command-not-found

2013年9月9日星期一

ubuntu 12.40 安装jekyll

先安装rvm

curl -L https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
rvm install 1.9.3
rvm use 1.9.3
rvm rubygems latest

然后替换 RubyGems 的到淘宝镜像:

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem sources -l


然后安装jekyll,在安装jekyll前先安装rdoc,否则会失败,

gem install rdoc
gem install jekyll

安装完毕

参考:
1.http://ruby-china.org/wiki/install-rails-on-ubuntu-12-04-server

2013年9月8日星期日

java.lang.IllegalStateException: Cannot forward after response has been committed in servlet 错误

写jsp程序时遇到这个错误,一般错误的原因是sendredirect后没有返回

protected void doPost() {
    if (someCondition) {
        sendRedirect();
    }
    forward(); // This is STILL invoked when someCondition is true!
}

解决方法是加一个return或加一个else分支:

protected void doPost() {
    if (someCondition) {
        sendRedirect();
        return;
    }
    forward();
}

protected void doPost() {
    if (someCondition) {
        sendRedirect();
    }else{
    forward(); 
}
}

但是我的代码中sendRedirect是最后一句代码,后面跟着return,居然还有这个运行错误.

原因在于jsp中response具有缓存大小的限制,如果达到这个限制,那么所有HTTP response headers和写入的html代码都会发送回客户端,也就是response is committed.虽然你没有显式指定返回.

检查了一下我的代码,原来我为了测试用如下代码向response写入了很多单词:
  PrintWriter out = response.getWriter();
  
  for( String str: result )
   out.print(str + " ");
  out.println(result.size());
  out.close();

注释掉这段代码之后就可以正常运行了.

参考:
1.http://stackoverflow.com/questions/2123514/java-lang-illegalstateexception-cannot-forward-after-response-has-been-committe/2125045#2125045
2.http://stackoverflow.com/questions/12693975/java-lang-illegalstateexception-cannot-call-sendredirect-after-the-response-h

2013年9月2日星期一

ubuntu12.04 安装 texlive和texstudio

二者都是从ppa安装,因为源里面版本可能会旧一些.

sudo add-apt-repository ppa:texlive-backports/ppa
sudo add-apt-repository ppa:blahota/texstudio
sudo apt-get update
sudo apt-get install texlive-xetex texstudio

安装时间挺长,耐心等待.

安装完后,我还安装了几个包,如下:

sudo apt-get install texlive-fonts-recommended         
sudo apt-get install texlive-lang-cjk         
这两个包是和中文,字体相关的,没装之前编译tex文件会出错,装了之和就没问题了.

最后,安装了苹果下面的"Hiragino Sans GB" 字体

下载之后,如下操作:
sudo mkdir /usr/share/fonts/applefonts
sudo chmod 777 /usr/share/fonts/applefonts
sudo mkfontscale     
sudo mkfontdir     
sudo fc-cache -fsv 


ok了.
参考:
1.https://launchpad.net/~blahota/+archive/texstudio/
2.https://launchpad.net/~texlive-backports/+archive/ppa
3.http://lzuzyy.blog.ubuntu.org.cn/content/texlive2012texstudio%EF%BC%88texmaker252%EF%BC%89%E7%9A%84%E4%B8%AD%E6%96%87%E9%85%8D%E7%BD%AE