星期二, 六月 19, 2012

Extract all URL from a file or website

Frequently one may want to extract all the URL in a webpage.  There are many ways to do this.  Below is an example:
#!/usr/bin/env bash
gawk 'BEGIN{
RS=""
IGNORECASE=1
}
{
  for(o=1;o<=NF;o++){
    if ( $o ~ /href/){
      gsub(/.*href=\042/,"",$o)
      gsub(/\042.*/,"",$o)
      print $(o)
    }
  }
}' 
Pipe the webpage to this script will do the job.

星期一, 六月 11, 2012

Intel compiler 12.1 on Ubuntu 12.04 LTS

I finally deleted my windows on my U110. When installing the Intel compiler icc/icpc 12.1, it gives the following error:
/usr/include/features.h(324): catastrophic error: cannot open source file "bits/predefs.h"
  #include
This is because in the new system, the includes and libraries were put under the hierarchy name.  Including the full path will solve the problem.  So insert the following lines in the .bashrc file in you home:
source /opt/intel/composerxe/bin/compilervars.sh ia32
alias icpc="icpc -B/usr/lib/i386-linux-gnu -I/usr/include/i386-linux-gnu"
alias icc="icc -B/usr/lib/i386-linux-gnu -I/usr/include/i386-linux-gnu"
On a 64 bit machine, you may change i386-linux-gnu to something else.

星期一, 六月 04, 2012

迷信一把

今天是某事件23周年,沪市上证指数开盘 23 46.98 点,更神奇的是沪市收盘暴跌 64.89 点,真神一般的行为艺术。有趣的是中国各大网站正在拼命删除含这几个数字的帖子,像某浪微薄的蜡烛图标/表情符号都给临时删除了。真是人算不如天算。

星期五, 六月 01, 2012

Enabling Emacs colors in a terminal

My Emacs editor on titan don't forward color schemes by default.  I make it before and then forgot it after some migration.  Put the following in ~/.emacs will solve the problem.
;; turn on font-lock mode
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)