Saturday, December 15, 2012

Setup remote Git repository

suppose the remote server is
suppose the repository is xxx.git

1. set up remote git repository
$mkdir ~/git-rep
$cd ~/git-rep
$mkdir xxx.git
$cd xxx.git
$git init --bare

2. on your local machine, add a remote repository aliases
$git remote add [ALIASES_NAME]
# check
$git remote -v

3. push your copy to the remote repository
# check branch
$git branch
$git push [ALIASES_NAME] master

4. Undo git add before the first commit
$git rm -r --cached .

5. repo inside a repo
$git submodule add [URL]
$git submodule init
$git submodule update

if you got an error: "bash: git-receive-pack: command not found", try
$git push [ALIASES_NAME] master --receive-pack=[REMOTE_PATH]/git-receive-pack

to avoid it, dump enviroment in .ssh/environment
env > .ssh/environment

Please note that setting up PATH in either .bashrc and .bash_profile does NOT work!

Sunday, December 9, 2012

Remotely Shutdown Virtualbox VM

1. List the running vms: 
    VBoxManage list runningvms

2. Close the running vm
    vboxmanage controlvm "VM name" savestate
    savestate can also be resume, reset, or poweroff

Saturday, December 8, 2012

How to access files from Ubuntu 12.10?

1. sudo apt-get install davfs2

2. sudo dpkg-reconfigure davfs2

    In the screen select Yes

3. sudo cp -r /etc/davfs2/ ~/.davfs2

4. sudo chown -R [ubuntu username] ~/.davfs2/

5. edit ~/.davfs2/secrets. add this line at the end of the file: [ username] [ password]

6. edit ~/.davfs2/davfs2.conf. uncomment:
    use_locks 0

7. sudo adduser [ubuntu username] davfs2

8. mkdir ~/

9. edit /etc/fstab. add this line at the end of the file: /home/[ubuntu username]/ davfs _netdev,rw,user 0 0

10. reload fstab
      mount -a

Wednesday, November 28, 2012

Install VirtualBox in Ubuntu 12.10

  1. echo "deb $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
  2. wget -q -O- | sudo apt-key add -
  3. sudo apt-get update
  4. sudo apt-get install virtualbox-4.2

Saturday, November 17, 2012

How to send an email using telnet

> telnet 25

# handshake

# set from
mail from:

# set to
rcpt to:

# set cc if you want to send the email to multiply receivers
rcpt to:

# email content
# show in the email
from: sender
to: receiver
cc: receiver1; receiver2; ...
subject: hello world
date: 17 Nov 2012
hello world!
# need "." in a separate line to terminate the email content

# quit telnet connecton

Saturday, November 10, 2012

Making Eclipse's Java code formatter ignore comments

Use /*- (note the hyphen) at the beginning of the block comment, and the formatting won't be affected if you format the rest of the file.

 * foo
 *    line1
 *        lin2

Friday, November 9, 2012

Extract one file from tarball archieve

1. extract foo.txt from foo.tar.gz

  tar -zxvf foo.tar.gz foo.txt

2. extract path/foo.txt from foo.tar.gz

  tar -zxvf foo.tar.gz path/foo.txt

3. extract path/foo.txt from foo.tar.gz to dstpath

  tar -zxvf foo.tar.gz -C dstpath path/foo.txt

3. extract path/foo.txt from foo.tar.gz to dstpath, without creating directory

  tar --transform 's/.*\///'  -zxvf foo.tar.gz -C dstpath path/foo.txt

Wednesday, November 7, 2012

Sort Nautilus Bookmarks

If only locations are provided:

sort ~/.gtk-bookmarks -o ~/.gtk-bookmarks

If names are provided:

sort ~/.gtk-bookmarks -o ~/.gtk-bookmarks -k 2

Thursday, November 1, 2012

Wednesday, October 31, 2012

Automatically change backgrounds in Xfce 4.10

  1. download a list of background pictures
  2. right click on the desktop, and choose "Desktop Settings..."
  3. under "Background" tab, choose "Image list" on the right
  4. click "+" to add background pictures to the list
  5. choose "Change the background (in minutes)", and adjust the minutes
  6. if you have one monitor, choose "Stretched" for "Style"; if you have two monitors, choose "Tiled", and choose "Stretch this background across all monitors"

Tuesday, October 30, 2012

Install Xfce 4.10 in Xubuntu 12.04

sudo add-apt-repository ppa:xubuntu-dev/xfce-4.10
sudo apt-get udpate
sudo apt-get dist-upgrade

Tuesday, October 23, 2012

Firefox Tip: Delete One Item From History

It is especially helpful if you type Gogle instead of Google, which makes Gogle recorded in Firefox history.

1. Enter the partial name in the url bar, say "Gog"
2. Select the error url
3. Shift + Delete

Thursday, August 23, 2012

Inkscape doesn't open on ubuntu 12.04

inkscape keeps crashing while loading, and the error message doesn't give any hint.

Emergency save activated!
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at
with a detailed description of the steps leading to the crash, so we can fix it.

The problem is that I substituted its icon in .icons. Then a conflict took place... Now, I've just undo that and inkscape return to work.

Tuesday, August 21, 2012

How to do Research At the MIT AI Lab

English version (html):

English version (pdf):

Chinese version (pdf):

Tuesday, July 10, 2012

Penn Treebank Format Parsing Grammar

start with tree_list

tree_list := tree
           | tree_list tree
tree      := ( node )
node      := leaf
           | TOKEN node_list
leaf      := TOKEN TOKEN
           | leaf TOKEN
node_list := ( node )
           | node_list ( node )
TOKEN     := ([^\)\(\r\n \t]+)

Dowload: JLex codeJCup code

Sunday, July 8, 2012

jEdit, one instance only on Ubuntu

Whenever I open an additional file once jEdit is already running on Ubuntu, jEdit opens an additional window into which it loads the file. How to solve it?

1. find the file "/usr/share/jedit/"
2. add "-background -reuseview" between ~.jEdit and "$@"

Tuesday, July 3, 2012

Friday, June 29, 2012

Compile SRILM

1. mkdir %SRILM%
2. mv srilm.tgz %SRILM%
3. cd %SRILM%
4. chmod -R 777 .
5. modify Makefile
    5.1 $ sbin/machine-type, suppose it returns i686
    5.2 in common/Makefile.machine.i686
          GCC_FLAGS = -m64 -mtune=i686 -Wreturn-type -Wimplicit
          insert NO_TCL = X
          delete TCL_INCLUDE, TCL_LIBRARY
6. make MACHINE_TYPE=i686-m64 World

Sunday, May 27, 2012

Saturday, May 19, 2012

Compile fnTBL

1. check cpu type
    less /proc/cupinfo

2. change makefile $FNTBL/src/Makefile
    delete "-march=pentium4" or change it to "-march=XXX"

3. change source file $FNTBL/src/, line 883
    change "static_cast<unsigned int>" to "static_cast<unsigned long int>"

4. compile
    > make all

Wednesday, May 2, 2012


Wednesday, April 4, 2012

Proxy Firefox through a SSH tunnel

Have you ever wanted to visit sites during the day from a location that denied access to those sites? What you need is the ability to create a secure and encrypted ssh connection to tunnel your browser traffic through. If you have access to a remote machine by way of ssh, you can set up Firefox to visit these sites.

The following method is only tested on Windows XP, with cygwin installed.

LOCAL_PORT: localhost port for ssh tunnel
SERVER_NAME: remote machine

1. set up firefox proxy
  • preferences --> advanced --> network --> settings
  • choose SOCKS v5
  • manual proxy configurations:
  • SOCKS 
    • Host:
    • No Proxy for: localhost,
  • leave the rest of entries BLANK
2. set up firefox DNS
  • open "about:config" page in Firefox
  • search "network.proxy.socks_remote_dns", set the value to "true"
3. establish ssh tunnel
   ssh -C2qTnN -D LOCAL_PORT username@SERVER_NAME

Sunday, March 11, 2012

Saturday, March 10, 2012

verb list whose VBN and VBD are same


Wednesday, March 7, 2012

Find top 100 files and move them

  1. ls -1 -tr | grep "pattern" | head -100 | xargs -I FILE mv FILE dst_dir
  2. find "pattern" | head -100 | xargs -I FILE mv FILE dst_dir

Friday, February 24, 2012

Mu-ming Poo's Letter

Mu-ming Poo is head of the Division of Neurobiology, Department of Molecular and Cell Biology at University of California, Berkeley, California, USA. He is also director of the Institute of Neuroscience, Chinese Academy of Sciences, Shanghai, China.

I cannot attest to the provenance of this, but I’ll quote anyway:

To all lab members:

Over the past several months, it has become clear to me that if there is no drastic change in the lab, Poo lab will soon cease to be a productive, first-rate lab that you chose to join in the first place. Lab progress reports over the past six months have clearly shown the lack of progress in most projects. One year ago, when we first moved to Berkeley, I expressed clearly to everyone my expectation from each one in the lab. The most important thing is what I consider to be sufficient amount of time and effort in the lab work. I mentioned that about 60 hr working time per week is what I consider the minimal time an average successful young scientist in these days has to put into the lab work. There may be a few rare lucky fellows like Florian, who had two Nature papers in his sleeve already, can enjoy life for a while and still get a job offer from Harvard. no one else in the lab has Florian\'s luxury to play around.

Thus I am imposing strict rules in the lab from now on:
  1. Every one works at least 50 hr a week in the lab (e.g., 8+ hr a day, six days a week). This is by far lower than what I am doing every day and throughout most of my career. You may be smarter or do not want to be as successful, but I am not asking you to match my time in the lab.
  2. By working, I mean real bench work. This does not include surfing on the computer and sending and receiving e-mails for non-scientific matters unrelated to your work (you can do this after work in the lab or at home), and excessive chatting on nonscientific matters. No long lunch break except special occasions. I suggest that everyone puts in at least 6 hr concentrated bench work and 2+ hr reading and other research-related activity each day. Reading papers and books should be done mostly after work. More time can be spent on reading, literature search and writing during working hours when you are ready for writing a paper.
  3. I must be informed in person by e-mail (even in my absence from the lab) when you are absent from the lab for a whole day or more. Inform me early your vacation plan. Taking more than 20 working days out of one year is the maximum to me. In fact, none of you are reporting any vacation and sick leave on your time sheet (against the university rule, although I have been signing the sheets), but you know roughly how many days you were not here.
On the whole, I understand and accept the fact that you may not fulfill the above requirements all the time, due to health reasons, occasional personal business. But if you do not like to follow the rules because it is simply a matter of choice of life style, I respect your choice but suggest you start making plans immediately and leave the lab by the end of January 31. I will do my best to help you to locate a lab to transfer or to find a job. If you do accept the conditions I describe above, I am happy to continue to provide my best support to your work, hopefully more than I have done in the past. I will review the progress of everyone in the lab by the end of June of 2002. I expect everyone to have made sufficient progress in the research so that a good paper is in sight (at least to the level of J. Neuroscience). If you cannot meet this goal at that time, I will have to ask you to prepare to leave my lab by the end of August.


Monday, February 20, 2012

Reading Notes for Writing in the Sciences (Ch 05)

The Review Article

Research reviews typically present a synthesis of findings rather than a synthesis of view.

Direct quotations are rarely found in research reviews.

Review in this context means to synthesize or characterize a body of information, not simply to point out flows.

Locating the Literature

Research reviews focus on primary sources -- original reports of individual studies published in professional research journals -- as opposed to secondary sources such as textbooks or magazine articles written for non-expert audiences.

``forward'' from an article, by identifying other sources in which it was later cited.

Summaries and headlines from PLoS (

Reading Previous Research
  • What does the field already know about this topic?
  • What kinds of studies have been done?
  • What methods have been used, and how useful have they turned out to be?
  • What has been found?
  • What kind of information is till needed?
Identifying Trends and Patterns

The grid: research question, methods, and principal results

Organizing the Review
  • Introduce your discussion by establishing the significance of the topic
  • Organize the body of review to reflect the clusters or subtopics you have identified, using headings if the review is length.
  • Use topic sentences at the start of paragraphs and sections to highlight similarities and differences and points of agreement and disagreement.
  • Conclude with an overview of what is known and what is left to explore.
Citing Sources in the Text

The Council of Science Editors identifies three primary citation systems used in scientific journals: name-year, citation-sequence, and citation-name.

For works with more than two authors, use ``et al.'' or ``and others''

  • Ann M. Penrose, Steven B. Katz. Writing in the Sciences (3rd edition). Longman. 2009

Sunday, February 19, 2012

.bash_profile vs .bashrc

When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

If you’ve already logged into your machine and open a new terminal window, then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

Most of the time you don’t want to maintain two separate config files for login and non-login shells. You can fix this by sourcing .bashrc from your .bash_profile file, then putting PATH and common settings in .bashrc. To do this, add the following lines to .bash_profile:

if [ -f ~/.bashrc ]; 
    then source ~/.bashrc

Now when you login to your machine from a console .bashrc will be called.


Saturday, February 18, 2012

SSH Tips

All changes are within file ~/.ssh/config

Multiple Connections

Often it’s useful to have multiple connections to the same server.

ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r

Repeated Connections

If you find yourself making multiple consecutive connections to the same server then enablepersistent connections.

ControlPersist 4h


If currently you type a password when making an SSH connection, you can make connecting much more pleasant by setting up SSH keys.

$ ssh-keygen
$ ssh-copy-id

Hostname Aliases and Usernames

You can also define hostname aliases in SSH config, though this can involve listing each hostname. If your username on a remote server is different from your local username, specify this in your SSH config as well.

Host host1 host2 host3
   User username


Tuesday, February 14, 2012

Reading Notes for Writing in the Sciences (Ch 04)

  • introduction
  • methods and materials: past tense, active or passive voice
  • results: past tense
  • discussion
  • references
Common Moves in Research Article Introductions
  • establish topic and significance
  • establish need for present research
  • introduce the present research
Reporting Results
  • the major generalization(s) you are making about your data -- such generalizations are often stated in topic sentences at the beginning of paragraphs.
  • in pact form, the data supporting the generalization(s)
    • refer readers to the visual explicitly
    • tell them what patterns to notice
Discussion Trends and Implications
  • briefly summarize the major findings
  • acknowledge the advantages and limitations of the methods
  • explain the implications of the findings
  • outline the research questions that remain
Most Common Words
  • verbs: 
    • suggest, indicate, show, demonstrate
  • adverbs and adverbial phrases:
    • possibly, probably, very likely, necessarily, certainly, without doubt, presumably, in all probably, hypothetically, maybe, so far as the evidence suggests, as far as we can determine
  • modal auxiliary verb:
    • may, might, would, could, should, must, can, shall
  1. the topic will be introduced in present tense, usually in a sentence or two; 
  2. the background and/or need for the study will be outlined in another few sentences; 
  3. methods and results will be briefly described in past tense; and 
  4. the major conclusions and implications of the study will be stated in present tense.
How Scientists Read Reports
  • Readers typically began by scanning the title and abstract of an article and then looking for the data, focusing on the tables and graphs in which the data are summarized. Only after examining the data themselves did these scientists read the results sectin provided by the authors.
Checklist for Writers of Research Reports:
  • importance of the research
  • originality of the work
  • analysis of previous literature
  • appropriateness of the approach and experimental design
  • adequacy of experimental techniques
  • soundness of conclusions and interpretations
  • relevance of discussion
  • clarity of presentation and organization of the article
  • demonstration of reproducibility
  1. Ann M. Penrose, Steven B. Katz. Writing in the Sciences (3rd edition). Longman. 2009

Sunday, February 12, 2012

Noun Phrase Similarity Rules

  1. integer: [-+]?\d+
  2. rational number: \d+[/]\d+
  3. finite decimal representation: [-+]?[0-9]*[.][0-9]+([eE][-+]?[0-9]+)?
  4. suffix hyphen: \w+[-]
  5. prefix hyphen: [-]\w+
  6. infix hyphen: \w+[-]\w+
  7. [A-Z]{2,}
  8. [A-Z]+\d+
  9. [a-z]+\d+
  10. [a-z]+[A-Z]+
  11. [a-z]+[A-Z]+\d+
  12. [A-Z]+[a-z]+\d+
  13. [a-z]+\d+[A-Z]+
  14. [a-z]+\d+[a-z]+\d+
  15. [A-Z]+[a-z]+[A-Z]+\d+
  1. integer: [-+]?\d+
  2. rational number: \d+[/]\d+
  3. finite decimal representation: [-+]?[0-9]*[.][0-9]+([eE][-+]?[0-9]+)?
  4. suffix hyphen: \w+[-]
  5. prefix hyphen: [-]\w+
  6. infix hyphen: \w+[-]\w+
  7. [A-Z]{2,}
  8. [A-Z][\w \\\/-]*\d
  9. [a-z][\w \\\/-]*\d
  10. [a-z0-9]+[A-Z]+
  11. [a-zA-Z]+\d+[a-zA-Z]+
counter example of combining 3 and 4:  
p53 and TAFII40 and TAFII60

Wednesday, February 8, 2012

Tuesday, February 7, 2012

Varying Sentence Beginnings

1. Non-finite and verbless clause
1.1. gerund-participle
Using histidine - tagged recombinant TR6 , we screened soluble forms of TNF - ligand proteins with immunoprecipitation .

counter example:
Immunoblotting experiments indicate that GRB2 associates with ...

1.2. past-participle
Based on the experiences of all the authors , we emphasized cell cycle inhibitors such as p16 and p21 and regulators of apoptosis such as p53 and members of the bcl - 2 family .

1.3. to-infinitival
To examine whether GRB2 is also a component of ras signaling in mammalian cells , microinjection studies were performed .

2. dependent clause
As previously shown with reticulocyte lysate - reconstituted steroid receptor heteroprotein complexes , the reconstituted pp60 src multiprotein complex contains hsp70

Although both unstimulated and activated human T cells express high affinity IL - 7R , only activated T cells can proliferate to IL - 7 .

3. preposition phrase
In addition , hsp90 in the lysate complexes with wild - type pp60v - src .

From Scatchard analyses , the Kd :s for binding of aFGF and bFGF to hFGFR - 1 were estimated to 25 pM and 41 pM , respectively .

4. adverb
Interestingly , GRB2 exhibits striking structural and functional homology to the C. elegans protein sem - 5 .

5. noun phrase (an object)
The letter , I read it to to you.

  1. Rodney Huddleston, Geoffrey Pullum, etc. The Cambridge Grammar of the English Language. page 51,  604, 1173